您的位置:首页 > 编程语言 > Java开发

java 中如何执行插入操作后返回自增id

2017-01-10 10:10 513 查看
参考JAVA 的API

Interface  java.sql.Statement

int executeUpdate(String sql,  int autoGeneratedKeys)

Executes the given SQL statement and signals the driver with the
given flag about whether the
auto-generated keys produced by this Statement object
should be made available for retrieval.


sql要是insert语句

int key = statement.executeUpdate(sql, Statement.RETURN_GENERATED_KEYS);//
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql java sql