通过getGeneratedKeys获取记录的主键
生活随笔
收集整理的這篇文章主要介紹了
通过getGeneratedKeys获取记录的主键
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
Connection con=null;PreparedStatement ps=null;ResultSet rs=null;try {//建立連接con= JDBCUtils.getConnection();//創(chuàng)建語句 String sql="insert into t_user values('test','123',null,null)";ps = con.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);ps.executeUpdate();rs= ps.getGeneratedKeys();//獲取主鍵集合if (rs.next()) {System.out.println(rs.getInt(1));//獲取主鍵}
?
轉(zhuǎn)載于:https://www.cnblogs.com/changshuo/p/3280122.html
總結(jié)
以上是生活随笔為你收集整理的通过getGeneratedKeys获取记录的主键的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 理财通余额+是什么
- 下一篇: 怎么提高花旗银行信用卡的额度 临时额度和