Sporadically, the last few entries of a batch are not written. I'm writing to a mysql database using JDBC. Here's a short version of my code. Does anyone have suggestions on possible causes or other diagnostics?
class DatabaseWriter{ int writeCount=0; public DatabaseWriter(){ PreparedStatement preparedStatement = connection.prepareStatement("insert into msgpersecond ( time , count , sendercompid , targetcompid ) values ( ? , ? , ? , ? )"); connection.setAutoCommit( false ); // turn off auto-Commit } public void process(Object input){ preparedStatement.setFloat( 2 , event.msgPerSecond ); preparedStatement.addBatch( ); writeCount++: if (writeCount > 50) { updateCounts = preparedStatement.executeBatch( ); connection.commit( ); preparedStatement.clearBatch( ); writeCount=0; } } } process() gets called a lot. The code usually works fine, but sometimes 3 to 20 or so records that definitely are added to the batch but don't get written. I'd greatly appreciate any suggestions. Thanks