I've seen this(and similar) questions explaining how to insert and get the generated ID. Unfortunately, none of the solutions that I've found so far work in my current setting.
My code is currently like the following:
rs.moveToInsertRow();
rs.updateObject(...)
rs.updateObject(...)
rs.updateObject(...)
...
rs.insertRow();
None of the inserted fields contains the ID. The ID is generated by the database. After rs.insertRow(); I want to get the ID of that row.
using rs.getObject("ID");
after inserting gives me
com.microsoft.sqlserver.jdbc.SQLServerException: The result set has no current row.
Is there any way to make this work as is, or do I have to redo this to drop the cursors and use an INSERT statement with returnkeys?