Results from SQLConnection.batch

41 views
Skip to first unread message

Shahji

unread,
Oct 20, 2016, 3:11:26 AM10/20/16
to vert.x

How do I access the results from SQLConnection.batch call? The handler returns List<Integer>. What are these elements in this list? The document doesn't talk much about it.

I have a few insert operations in batch and I would like to get access to each of its 'LAST_INSERT_ID'.

Paulo Lopes

unread,
Oct 21, 2016, 3:23:31 AM10/21/16
to vert.x
It all derives from the underlying JDBC API:

http://docs.oracle.com/javase/8/docs/api/java/sql/Statement.html#executeBatch--

According to the JDK documentation it returns:

an array of update counts containing one element for each command in the batch. The elements of the array are ordered according to the order in which commands were added to the batch.

Simon Falkman

unread,
Feb 10, 2017, 10:13:42 AM2/10/17
to vert.x
I'm having problems with this as well, I need to get the generated keys after a batch execution.

Isn't the key ID's retrieved with getGeneratedKeys()?
Comparing JDBCBatch.java and JDBCUpdate.java it looks like JDBCUpdate is creating the prepared statement with Statement.RETURN_GENERATED_KEYS in case of an insert.
Is this not possible for batch executions?

Thanks,
Simon
Reply all
Reply to author
Forward
0 new messages