......
ResultSet rs =stmt.executeQuery("select @@identity");
int nId=0;
if (rs.next())
nId=rs.getInt(1);
ResultSet rs =stmt.executeQuery("select @@identity");
int nId=0;
if (rs.next())
nId=rs.getInt(1);
调试欢乐多
insert into table(id) values(XXX);
return XXX
conn.setAutoCommit(false);
insert into tableName
select max(uniqueidentifier) from tableName;
conn.setAutoCommit(true);
在jdbc3中的特性:
Statement stmt = conn.createStatement();
stmt.executeUpdate("INSERT INTO authors (first_name, last_name) " +"VALUES ('George', 'Orwell')",Statement.RETURN_GENERATED_KEYS); ResultSet rs = stmt.getGeneratedKeys();
if ( rs.next() ) {
// Retrieve the auto generated key(s). int key = rs.getInt();}