pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Primary Key Error Updating Rows in ResultSet
3+ messages / 2 participants
[nested] [flat]

* Primary Key Error Updating Rows in ResultSet
@ 2004-11-30 05:41 Peter Smith <smithp@internode.on.net>
  2004-11-30 06:12 ` Re: Primary Key Error Updating Rows in ResultSet Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Peter Smith @ 2004-11-30 05:41 UTC (permalink / raw)
  To: pgsql-jdbc

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




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Primary Key Error Updating Rows in ResultSet
  2004-11-30 05:41 Primary Key Error Updating Rows in ResultSet Peter Smith <smithp@internode.on.net>
@ 2004-11-30 06:12 ` Kris Jurka <books@ejurka.com>
  2004-11-30 10:03   ` Re: Primary Key Error Updating Rows in ResultSet Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Kris Jurka @ 2004-11-30 06:12 UTC (permalink / raw)
  To: Peter Smith <smithp@internode.on.net>; +Cc: pgsql-jdbc



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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Primary Key Error Updating Rows in ResultSet
  2004-11-30 05:41 Primary Key Error Updating Rows in ResultSet Peter Smith <smithp@internode.on.net>
  2004-11-30 06:12 ` Re: Primary Key Error Updating Rows in ResultSet Kris Jurka <books@ejurka.com>
@ 2004-11-30 10:03   ` Kris Jurka <books@ejurka.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Kris Jurka @ 2004-11-30 10:03 UTC (permalink / raw)
  To: Peter Smith <smithp@internode.on.net>; +Cc: pgsql-jdbc



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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2004-11-30 10:03 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-11-30 05:41 Primary Key Error Updating Rows in ResultSet Peter Smith <smithp@internode.on.net>
2004-11-30 06:12 ` Kris Jurka <books@ejurka.com>
2004-11-30 10:03   ` Kris Jurka <books@ejurka.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox