小编Jac*_*ess的帖子

How can I get auto generated keys and set the resultset type?

I have this SQL statement:

con = cpds.getConnection();
            con.setAutoCommit(false);
            SQL = "INSERT INTO person(accountID,addressID,lastName,firstName,middleName,suffix,gender,birthDate, [language], ethinicity) "
                    + "VALUES(?,?,?,?,?,?,?,?,?,?)";
            PreparedStatement stmt = con.prepareStatement(SQL,ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
Run Code Online (Sandbox Code Playgroud)

What I want to be able to do is get the generated keys for this statement. Now I have done this before, but without setting the resultset typescroll parameter. It seems that there is no argument that does this either:

PreparedStatement stmt = con.prepareStatement(SQL,ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY, Statement.RETURN_GENERATED_KEYS)
Run Code Online (Sandbox Code Playgroud)

What I want to know is this: How can I …

java sql resultset prepared-statement

4
推荐指数
1
解决办法
3130
查看次数

标签 统计

java ×1

prepared-statement ×1

resultset ×1

sql ×1