Thread: Suspected JDBC bug

Suspected JDBC bug

From
Jim Gray
Date:

I have a test case (attached) which has this output:

 

Connected to PostgreSQL 9.0.1

Using PostgreSQL Native Driver PostgreSQL 9.3 JDBC4.1 (build 1101)

Executing statement:   SELECT EMPNUM FROM WORKS WHERE EMPNUM > ?

Parameter value:      E1

Processing result set: 0

Returned value:       E2

 

Executing statement:   SELECT ?

Parameter value:      E9

Processing result set: 1

Returned value:       E9

Updating first result set value: E2 , with new value: E9

SQL Exception processing result set for: SELECT ?

  SQLState: 42703

  SQLCode:  0

  Message:  The column name pnum was not found in this ResultSet.

 

I have not found anything similar in the mailing lists or archives.

 

Attachment

Re: Suspected JDBC bug

From
Kris Jurka
Date:

On Fri, 27 Jun 2014, Jim Gray wrote:

>
> I have a test case (attached) which has this output:
>
>   Message:  The column name pnum was not found in this ResultSet.
>
>

The PG JDBC driver requires you to select all primary key columns to be
able to update a ResultSet.  The checking for this was not correct for
multicolumn primary keys and gave you the previous error message.  With
the attached patch it will say:

Updating first result set value: E2 , with new value: E9
SQL Exception processing result set for: SELECT ?
  SQLState: 24000
  SQLCode:  0
  Message:  ResultSet is not updateable.  The query that generated this
result set must select only one table, and must select all primary keys
from that table. See the JDBC 2.1 API Specification, section 5.6 for more
details.


Kris Jurka

Attachment