//得到插入数据的id(statement还有很多关键字需要研究)
public void getLastID(){
try{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql="insert into user(name,pwd) values(?,?)";
pstmt = conn.prepareStatement(sql,java.sql.Statement.RETURN_GENERATED_KEYS);
pstmt.executeUpdate();
rs = pstmt.getGeneratedKeys();
if(rs.next()){
int id= rs.getInt(1);
}
}catch(Exception e){}
}