Re: ID of last insert from DB2 table

From: Chris (chris2k01_at_hotmail.com)
Date: 02/06/05

  • Next message: Lee Fesperman: "Re: Is perl better? :((("
    Date: Sun, 06 Feb 2005 18:43:06 GMT
    
    

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Dundonald wrote:

    >
    > mark.dun...@gmail.com wrote:
    >> I may have to migrate the database a Java application uses from
    >> MySQL
    >> to DB2. I am currently assessing the impact. One item I'm
    >> currently looking at is that of obtaining the ID of an insert
    >> immediately after the operation.
    >>
    >> For example with the MySQL database I would perform the following
    >> command:
    >>
    >> long lastInsertedID =
    >> ((com.mysql.jdbc.Statement)statement).getLastInsertID();
    >>
    >> The statement variable is of type java.sql.Statement.
    >>
    >> If I port over to DB2 I am concerned I cannot replace this
    >> functionality. A method such as .getLastInsertID() is not
    >> available from java.sql.Statement.
    >>
    >> Is there a solution if I port to DB2?

    Hi,

    How about the standard method java.sql.Statement.getGeneratedKeys()? I
    know it works with MySQL, but I'm not sure about DB2 (never used it).
    It's all dependent on whether the driver implements the method or
    not.

    Chrs
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.6 (GNU/Linux)

    iD8DBQFCBmU/gxSrXuMbw1YRAlyFAKCkN9Jzq2nNzBauwfRynNrKynRDzQCdHOZO
    nkKxoVdVhDYZ8dnwTqLG3Bc=
    =Pg17
    -----END PGP SIGNATURE-----


  • Next message: Lee Fesperman: "Re: Is perl better? :((("

    Relevant Pages

    • Re: ID of last insert from DB2 table
      ... > I may have to migrate the database a Java application uses from MySQL ... > to DB2. ... > Is there a solution if I port to DB2? ...
      (comp.lang.java.databases)
    • Re: ID of last insert from DB2 table
      ... > I may have to migrate the database a Java application uses from MySQL ... > to DB2. ... > Is there a solution if I port to DB2? ...
      (comp.lang.java.programmer)
    • Re: Access DB2 From Linux
      ... pull data from tables in DB2 and put them into a MySql database. ...
      (comp.sys.ibm.as400.misc)
    • Access DB2 From Linux
      ... Is there a way to get a shell similar to the one that you get by ... pull data from tables in DB2 and put them into a MySql database. ...
      (comp.sys.ibm.as400.misc)
    • Re: ID of last insert from DB2 table
      ... >> to DB2. ... >> For example with the MySQL database I would perform the following ... >> Is there a solution if I port to DB2? ...
      (comp.lang.java.programmer)