Results 1 to 4 of 4
  1. #1
    abhi_iips is offline Member
    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Default auto generated keys

    how to retrieve auto generated keys after executing an insert statement, i have a filed named id which is of autonumber type, i want to get back the id generated by database management system....

    plz give me a clear code to do so.....

    tx in advance.............

  2. #2
    sandeepsai39 is offline Member
    Join Date
    Feb 2009
    Posts
    96
    Rep Power
    0

    Default

    Follow These Three steps.
    Statement stmt =connection_object.createStatement();
    String query =" insert into --------------------------";
    //inserting into database
    stmt.executeUpdate(query);
    -------------------
    //to get autogenrated keys

    rs = stmt.getGeneratedKeys();

  3. #3
    abhi_iips is offline Member
    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Default

    it throws unsupported exception...i had tried this code, even i tried it wid prepared statement.....plz give me some working code

  4. #4
    sandeepsai39 is offline Member
    Join Date
    Feb 2009
    Posts
    96
    Rep Power
    0

    Default

    check whether stmt.executeUpdate(query) sucess or not else ,check in your database specified table has autogengenerated key or not.

Similar Threads

  1. Media Keys
    By tikigod in forum New To Java
    Replies: 0
    Last Post: 01-28-2009, 11:30 PM
  2. Auto-complete/Auto-fix for custom statement
    By dark_cybernetics in forum Eclipse
    Replies: 0
    Last Post: 08-19-2008, 11:19 AM
  3. [SOLVED] auto generated numbers
    By suprabha in forum Advanced Java
    Replies: 10
    Last Post: 08-14-2008, 05:13 AM
  4. Auto generated number system?
    By javanewbie in forum New To Java
    Replies: 2
    Last Post: 08-09-2008, 05:16 AM

Posting Permissions

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