Thread: Primary Key Error Updating Rows in ResultSet
Hi, I'm getting the error 'java.sql.SQLException: No Primary Keys' when trying to update a resultset based on a table with a primary key. The exception appears to be occuring when I call the updateObject() method. I'm using pg74.215.jdbc3.jar & postgresql 7.4.6. Any suggestions? peter
On Tue, 30 Nov 2004, Peter Smith wrote: > I'm getting the error 'java.sql.SQLException: No Primary Keys' when > trying to update a resultset based on a table with a primary key. > It is not enough to have a primary key on the table, you must also select those columns in your ResultSet. Further, the code to determine the table in question isn't very good and is easily fooled. What is your exact SELECT statement and primary key definition? Kris Jurka
On Tue, 30 Nov 2004, Peter Smith wrote: > On Tue, 2004-11-30 at 16:12, Kris Jurka wrote: > > It is not enough to have a primary key on the table, you must also select > > those columns in your ResultSet. Further, the code to determine the table > > in question isn't very good and is easily fooled. What is your exact > > SELECT statement and primary key definition? > > The select statement I'm using is very basic: > > select targetcode, target, altcode from targets; > > targetcode is the primary key of type CHAR(3). > If you have in fact included the trailing semi-colon on the SELECT statement I believe the driver determines the table name is "targets;" instead of "targets". Either leave it off or put some whitespace between it and the tablename. Kris Jurka