MySQL API For JAVA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajeevbadgujar
    New Member
    • Feb 2007
    • 4

    #1

    MySQL API For JAVA

    You can use the SQL command LAST_INSERT_ID( ).
    I want to use this mysql command to retrive last inserted value.
    Can any body tell me which java method i should use.
    Hey plz help me its urgent.
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Originally posted by rajeevbadgujar
    You can use the SQL command LAST_INSERT_ID( ).
    I want to use this mysql command to retrive last inserted value.
    Can any body tell me which java method i should use.
    Hey plz help me its urgent.
    You need to create a connection using the jdbc driver (I think that's for MySQL... you might want to google it real quick), and then send it that command, with a ResultSet waiting for the response.

    Comment

    • abctech
      New Member
      • Dec 2006
      • 157

      #3
      Originally posted by rajeevbadgujar
      You can use the SQL command LAST_INSERT_ID( ).
      I want to use this mysql command to retrive last inserted value.
      Can any body tell me which java method i should use.
      Hey plz help me its urgent.
      In java.sql package go through the methods in Interface 'ResultSet'..

      You can retrieve all the records from you backend table in a ResultSet object. There is a method last() in this interface which will point the cursor to the very last record of ResultSet, you can use it to retrieve your last added record.

      Or,if your records are sequentially numbered you can also fire a query through your Java program to select the Max_ID(it will give the ID of the last added record) and then fire another query to select the record having that ID.

      Is this what you are looking for or anything else?

      Comment

      Working...