2 Replies Latest reply on Apr 25, 2003 9:21 AM by Wes

    problem gettting generated keys / autoincrement field

    Wes Newbie

      If there is a better forum for this question, please let me know.

      I just came across a feature of JDBC where you can (apparently) get back the generated key / autoincrement field that was used for your insert into the db.

      using the following:
      PreparedStatement statement = conn.prepareStatement("insert into table (field) values (?)", Statement.RETURN_GENERATED_KEYS);

      But when I run this code in jboss/jetty, I get the following exception on the prepareStatement call:
      java.sql.SQLException: JDK1.4 method not available in JDK1.3
      at org.jboss.resource.adapter.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:302)
      I located the source and found were the exception is created:
      public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
      return new WrappedPreparedStatement(this, mc.getConnection().prepareStatement(sql, autoGeneratedKeys));
      catch (SQLException e)
      return null;
      } // end of try-catch
      throw new SQLException("JDK1.4 method not available in JDK1.3");

      Also found the ant build file for jboss/connector... apparently it does global search and replace operations on the .jpp sources, once for jdbc2 and once for jdbc3. It seems to be commenting or uncommenting the throw of the exceptions.

      Beyond that, I'm stuck... I don't understand how jboss determines which version of the generated java files to run.

      I'm definitely using jdk1.4, I added an echo of JAVA_HOME to the top of run.bat, and it showed C:\j2sdk1.4.0_01

      I'm using:
      jboss 3.2
      mysql (mysql-connector-java-3.0.6-stable-bin.jar)