2013年8月21日
摘要: 我们在写数据库程序的时候,经常会需要获取某个表中的最大序号数,一般情况下获取刚插入的数据的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.... 阅读全文
posted @ 2013-08-21 14:41 any91 阅读(1229) 评论(0) 推荐(0) 编辑