prepared statement not returning keys; driver used(mysql-connector-java-3.1.14-bin.jar)

This is a discussion on prepared statement not returning keys; driver used(mysql-connector-java-3.1.14-bin.jar) within the MySQL Database forums, part of the Database Forums category; getGeneratedKeys() method not returning resultset containing keys after executing prepared statements in a batch The code snippet is given below ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-15-2007
dsm100@gmail.com
 
Posts: n/a
Default prepared statement not returning keys; driver used(mysql-connector-java-3.1.14-bin.jar)

getGeneratedKeys() method not returning resultset containing keys
after executing prepared statements in a batch

The code snippet is given below

String insertQuery = "INSERT INTO PRICE_LIST(ID,
SKU_CODE)VALUES(?,?)";

connection = springDataSource.getConnection();
preparedStatement = connection.prepareStatement(insertQuery);
for (int listPriceCount = 0; listPriceCount < listPrices.length;
listPriceCount++) {

preparedStatement.setInt(1, listPrices[listPriceCount]
.getID());
preparedStatement.setInt)2, listPrices[listPriceCount]
.getName());

preparedStatement.addBatch();
}

preparedStatement.executeBatch();

keySet = preparedStatement.getGeneratedKeys();

for (int listPriceCount = 0; keySet.next(); listPriceCount++) {
int key = keySet.getInt(1);
listPrices[listPriceCount].setId(key);
logger.debug("generated key: " + key);
}

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:20 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0