I’m using java to do batch inserts into a mysql table:
cnx = lconnect.openConnection();
mStatement = cnx.createStatement();
boolean firstTime = true;
PreparedStatement preparedStatement = null;
preparedStatement = cnx.prepareStatement(strQuery);
preparedStatement.setString(param1);
preparedStatement.setString(param2);
....
preparedStatement.addBatch();
preparedStatement.setString(param1);
preparedStatement.setString(param2);
preparedStatement.addBatch();
preparedStatement.setString(param1);
preparedStatement.setString(param2);
preparedStatement.execute();
Is there any way to really know the number of inserted lines ?
I think my piece of code it’s working (?) by the number of lines in the DB does not match with the number of lines supposed to be inserted, so I’m thinking I have a problem with y inserts maybe.
You have to call
executeBatch(). The returned array contains the information you want.From the JavaDoc: