摘要: 我们在写数据库程序的时候,经常会需要获取某个表中的最大序号数,一般情况下获取刚插入的数据的id,使用select max(id) from table 是可以的。但在多线程情况下,就不行了。下面介绍三种方法(1)getGeneratedKeys()方法:程序片断:Connection conn = ;Serializable ret = null; PreparedStatement state = .;ResultSet rs=null; try { state.executeUpdate(); rs = state.getGeneratedKeys(); if (rs.next()) .. 阅读全文
posted @ 2013-05-29 11:15 byfei 阅读(513) 评论(0) 推荐(0) 编辑