我有這樣的SQL語句:如何獲得自動生成的鍵並設置結果集類型?
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);
我希望能夠做的就是生成的密鑰對這種說法。現在我已經完成了此操作,但沒有設置結果集typescroll參數。似乎沒有任何說法,這是否可以:
PreparedStatement stmt = con.prepareStatement(SQL,ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY, Statement.RETURN_GENERATED_KEYS)
我想知道的是:我如何設置結果集類型typescroll不敏感的,並得到生成的密鑰?