我不使用 Statement 来执行查询。这些方法看起来像
public static int insertIntoUserTable (String username, String password) {
String query = "insert into user (username, password) values (?, ?)";
QueryRunner run = new QueryRunner(FeedDbDataSource.getDataSource());
ResultSetHandler<User> resultHandler = new BeanHandler<>(User.class);
try {
run.insert(query, resultHandler, username, password);
} catch (SQLException e) {
// handle
}
return ;
}
如何获取插入行的 id(无需从用户那里进行额外的 select * ...)?