I want to INSERT
several rows using a PreparedStatement
:
ps = con.prepareStatement(query,PreparedStatement.RETURN_GENERATED_KEYS);
Support for getGeneratedKeys()
on batch execution is implementation defined according to the JDBC spec. Most likely the SQL Server driver does not support it for batch execution.
I tried to look for an explicit statement on the Microsoft site, but couldn't find it. This old (2007) forum post on MSDN does state that it isn't supported: http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/6cbf5eea-e5b9-4519-8e86-f4b65ce3f8e1