jubincn

导航

2012年3月19日 #

mysql获取刚插入(添加)记录的自动编号id

摘要: 转自:http://hi.baidu.com/zuccxy/blog/item/037fb71eebf0848186d6b6cd.html我们在写数据库程序的时候,经常会需要获取某个表中的最大序号数,一般情况下获取刚插入的数据的id,使用select max(id) from table 是可以的。但在多线程情况下,就不行了。下面介绍三种方法(1) getGeneratedKeys()方法:程序片断:Connection conn = ; Serializable ret = null; PreparedStatement state = .; ResultSet rs=null; try { 阅读全文

posted @ 2012-03-19 21:12 jubincn 阅读(6572) 评论(0) 推荐(0)