How to add data with ResultSet object?
От | vasylenko@uksatse.org.ua |
---|---|
Тема | How to add data with ResultSet object? |
Дата | |
Msg-id | OFC885AEE9.8BB75F76-ONC225739F.0037180D-C225739F.0038EE0A@uksatse.org.ua обсуждение исходный текст |
Ответы |
Re: How to add data with ResultSet object?
|
Список | 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!
В списке pgsql-jdbc по дате отправления: