Hello,
you can do it in two ways I guess:
one is to do a second select (which you don't want):
SELECT LAST_INSERT_ID().
another way is to use java.sql.Statement.RETURN_GENERATED_KEYS
when you create your Statement, something along these lines:
java.sql.PreparedStatement pstmt =
myconnection.prepareStatement("INSERT INTO
mytable(value)VALUES('value')",
java.sql.Statement.RETURN_GENERATED_KEYS );
pstmt.executeUpdate();
java.sql.ResultSet rs = pstmt.getGeneratedKeys();
while( rs.next())
System.out.println("My autoincrementid is: " + rs.getInt(1));
/Johan
balaraju mandala skrev:
Hello Everybody,
i want to read the latest value of a autoincrement column from a java
program. How can i do this? i want to do this in a single query insertion,
is it possible?
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.2/471 - Release Date: 2006-10-10
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]