Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

id of the new field in my table

 
Grégoire Berclaz
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I insert into a table new informations. I like to know the id of this. How can I do?
@+
Greg
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What database and what driver are you using?
 
Grégoire Berclaz
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A mySQL database with a jdbc connection
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you should be able to do
SELECT LAST_INSERT_ID() right after your INSERT statement.
Depending on your JDBC driver version you might be able to use the public int executeUpdate(String SQL, int autoGeneratedKeys) method. This only works with JDBC 3.0 specifications though.
If you aren't already, I highly recomend using the Connector-J Driver.
Good luck.
 
Grégoire Berclaz
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic