Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2011
    Rep Power

    Default Not able to retrieve primary key generated during insertion of row.


    I'm trying to get the primary key generated using ResultSet.getGeneratedKeys() method on Oracle 11g using JDBC code. I tried ojdbc14.jar and oddbc6.jars but still getting exception as given below:

    java.sql.SQLException: Invalid column type: getLong not implemented for class oracle.jdbc.driver.T4CRowidAccessor
    at oracle.jdbc.driver.DatabaseError.throwSqlException (
    at oracle.jdbc.driver.DatabaseError.throwSqlException (
    at oracle.jdbc.driver.Accessor.unimpl( 58)
    at oracle.jdbc.driver.Accessor.getLong( 496)
    at oracle.jdbc.driver.OracleReturnResultSet.getLong(O

    The code snippet is as follows:

    connection = DriverManager.getConnection(DB_URL,USER,PASS);

    ResultSet rs = ps.getGeneratedKeys();
    if ( {
    long newId = rs.getLong(1);

    Please let me know if I'm missing out something or give any pointers for the issue.

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Rep Power

    Default Re: Not able to retrieve primary key generated during insertion of row.

    a) Is the data type you are accessing a long type? It seems, based upon the exception, the driver you are using does not support the getLong method...have you tried others? b) Do you pass the Statement.RETURN_GENERATED_KEYS flag when creating the Statement (or, I presume, the PreparedStatement)?

Similar Threads

  1. JPA Primary Key from two foreign key
    By peterbo in forum New To Java
    Replies: 6
    Last Post: 06-29-2014, 11:30 AM
  2. JPA Composite Primary Key
    By The_S in forum Advanced Java
    Replies: 2
    Last Post: 02-06-2009, 07:30 AM
  3. How to generate primary key in EJB
    By naresh_m in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 07-17-2008, 10:41 AM
  4. Replies: 0
    Last Post: 05-14-2008, 10:46 AM
  5. how to determine the primary key
    By osval in forum JDBC
    Replies: 1
    Last Post: 08-07-2007, 03:31 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts