How to add data with ResultSet object?

From: vasylenko(at)uksatse(dot)org(dot)ua
To: pgsql-jdbc(at)postgresql(dot)org
Subject: How to add data with ResultSet object?
Date: 2007-11-26 10:21:49
Message-ID: OFC885AEE9.8BB75F76-ONC225739F.0037180D-C225739F.0038EE0A@uksatse.org.ua
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi!

I hava base table

CREATE TABLE forcehol
(
w_id integer NOT NULL,
bday date NOT NULL,
duration integer NOT NULL,
eday date NOT NULL DEFAULT (now() + '1 mon'::interval),
CONSTRAINT "force_PK" PRIMARY KEY (w_id, bday),

);

and have ths child of it

CREATE TABLE adminhol
(
-- Inherited: w_id integer NOT NULL,
-- Inherited: bday date NOT NULL,
-- Inherited: duration integer NOT NULL,
-- Inherited: eday date NOT NULL DEFAULT (now() + '1 mon'::interval),
CONSTRAINT "admin_PK" PRIMARY KEY (w_id, bday),

) INHERITS (forcehol) ;

I have pushed a lot of data into forcehol and adminhol

I use "SELECT * from ONLY forcehol" to see raws.

Now about the question:

Using library postgresql-8.2-505.jdbc3.jar I have such class

class A{

private Connection conn;
private ResultSet rs;

public A(){

try{
//make coonnection to DB
...
//get result
Statement stat =
conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs = stat.executeQuery("SELECT * from ONLY forcehol");
//now, I'm trying to add new row into the forcehol table

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
--> //here we have exception with the text "No primary key found for table ONLY"
rs.moveToInsertRow();

rs.updateObject(1,...);
//....
rs.updateObject(4,...);
rs.insertRow();
}
catch(SQLException ex)
{
System.out.print(ex.getMessage()+"\n");
}

}
}

How can I beat such exception about unccorect analysing of my query with
ONLY syntax?
ResultSet keep the nesessary rows, but I can't insert, udate or dalete
any new rows.

Thanks a lot!

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Jonathan Mast 2007-11-26 20:24:04 Queries with 'AND' clauses not returning results
Previous Message Kris Jurka 2007-11-24 06:36:55 Re: Fw: java.lang.IndexOutOfBoundsException when commit long transaction