简体   繁体   中英

postgres 9 | jdk 7.45 | irregular “No results were returned by the query”

this thing is making me stupid for nothing since yesterday (googled a lot without finding any other developer with the same problem). I'm upgrading an application server written in java (jdk5), which uses postgresql 7, to jdk7 using postgresql 9.

the simple & absurd issue:

an INSERT and a SELECT in the same statement:

insert into table(a,b) values('a','b') ; select currval('table_pkey_id')

nothing special, seems simple and clear.. but with postgresql-9.3-1100.jdbc3.jar does not work more, throws the error in subject.

the sql statement works as usual using pgadmin, returning the id of the inserted line. but making the same query using javam with pg9/java7, it throws the error like if I use executeQuery on a simple insert statement.

stmt=cnn.createStatement(rst.TYPE_SCROLL_INSENSITIVE,rst.CONCUR_READ_ONLY);
stmt.executeQuery(sql);

org.postgresql.util.PSQLException: No results were returned by the query."

why god?! I want and need to fix this issue WITHOUT breaking in 2 sql statements the one above. seems a really stupid bug in executeQuery implementation.

please feedback. thanks.

max

I think you would do better to change to:

insert into table(a,b) values('a','b') RETURNING id;

RETURNING is now supported in all supported versions of PostgreSQL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM