title: Getting autoincremented Id from JDBC
body: <p>Facing some exception without any clue message. </p>
  
  <p>Here is my JDBC</p>
  
  <pre><code>            statement = con
                      .getConnection()
                      .prepareStatement(
                              "insert into  p3triplets set source_material= ? , process= ? ,target_material= ? , user_id = ?",
                              statement.RETURN_GENERATED_KEYS);
              statement.setString(1, pTriplet.getSource_Name());
              statement.setString(2, pTriplet.getProcessName());
              statement.setString(3, pTriplet.getTargetName());
              statement.setLong(4, user.getId());
              int i = statement.executeUpdate();
              generatedKeys=statement.getGeneratedKeys();
              long genId = generatedKeys.getLong(1);  //Exception
              for (p3TripleChild p3childTriple : childsDummyList) {
                  if (p3childTriple.getId() == 0) {
                      p3childTriple.setId(genId);
                  }
              }
  </code></pre>
  
  <p>And the exception is </p>
  
  <pre><code>java.sql.SQLException
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
      at com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:815)
      at com.mysql.jdbc.ResultSetImpl.getLong(ResultSetImpl.java:2835)
      at com.mysql.jdbc.ResultSetImpl.getLong(ResultSetImpl.java:2830)
      at com.mtc.server.TripleServiceImpl.saveTriplet(TripleServiceImpl.java:161)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
      at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
      at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
      at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
      at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
      at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.Server.handle(Server.java:324)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
      at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
      at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
      at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
  </code></pre>
  
  <p>What I am missing ?</p>
  
  <p>Id generated in database, but unable to get it back.</p>