java.jdbc

prepared-statement* behaves different on OpenJDK 1.6 and OS X Java 1.6.

Details

  • Type: Defect Defect
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:

Description

I'm using the Clojure library Korma to generate SQL for Postgres, which depends on clojure.java.jdbc. Recently I added a custom 'upsert' query. Using it on normal java 1.6 is fine, but on openJDK it breaks due to the use of 'java.sql.Statement/RETURN_GENERATED_KEYS'. This makes the Postgres driver add a seemingly random "RETURNING *" at the end of the query.

On normal Java 1.6 java.sql.Statement/RETURN_GENERATED_KEYS doesn't exist and then a exception is caught and everything works as expected. Sounds like the world up side down, but I'm probably missing the rational behind this.

The line that causes the weird behavior is here: https://github.com/clojure/java.jdbc/blob/master/src/main/clojure/clojure/java/jdbc/internal.clj#L315

The code that showcases the 'bug' is here:
https://gist.github.com/2e8a3d55d80707ce79e0

(Sorry for the monkey patching in the gist, if there is a better way I would love to hear it)

I guess a naive patch would be to remove the java.sql.Statement/RETURN_GENERATED_KEYS line, but there must be a reason for its existence I assume.

Activity

Hide
Sean Corfield added a comment -

RETURN_GENERATED_KEYS is required for inserts to return the generated keys. Since this works on Sun's Java 6 and with all intended databases, and is per spec, it is not going away.

Right now OpenJDK / PostgreSQL is not a supported combination, sorry.

Show
Sean Corfield added a comment - RETURN_GENERATED_KEYS is required for inserts to return the generated keys. Since this works on Sun's Java 6 and with all intended databases, and is per spec, it is not going away. Right now OpenJDK / PostgreSQL is not a supported combination, sorry.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: