Home > Database > Mysql Tutorial > mysql返回新插入的id值

mysql返回新插入的id值

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:13:28
Original
1284 people have browsed it

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 今天项目中用到:数据表id自增,当新插入一条记录后马上返回 这个插入的id值,核心代码 conn=DBUtilsC3P0.getInstance().getConnection(); Statement stmt =conn.createStatement(); stmt.executeUpdat

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

  今天项目中用到:数据表id自增,当新插入一条记录后马上返回

  这个插入的id值,核心代码

  conn=DBUtilsC3P0.getInstance().getConnection();

  Statement stmt =conn.createStatement();

  stmt.executeUpdate(sql, Statement.RETURN_GENERATED_KEYS);

  ResultSet newid = stmt.getGeneratedKeys();

  if(newid.next()){

  uid=newid.getInt(1);

  }

mysql返回新插入的id值

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template