作者在 2011-04-07 21:00:53 发布以下内容
Connection con=new GetConn().getCon();
String sql="insert into user(name,sex) values('abcdd',2)";
String sql2="select @@IDENTITY AS 'Identity '";
try {
PreparedStatement ps= con.prepareStatement(sql);
PreparedStatement ps2= con.prepareStatement(sql2);
ps.execute();
ResultSet rs=ps2.executeQuery();
if(rs.next()){
System.out.println(rs.getString(1));
}
String sql="insert into user(name,sex) values('abcdd',2)";
String sql2="select @@IDENTITY AS 'Identity '";
try {
PreparedStatement ps= con.prepareStatement(sql);
PreparedStatement ps2= con.prepareStatement(sql2);
ps.execute();
ResultSet rs=ps2.executeQuery();
if(rs.next()){
System.out.println(rs.getString(1));
}