Hi Jeff, all! Jeff Drew wrote:
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?
I do not claim any JBDC knowledge, so I have to speculate:
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.
I do not see any handling of the records processed in the last, not completed lot of 50. Do you call a final "commit" somewhere else?
Jörg -- Joerg Bruehe, Senior Production Engineer MySQL AB, www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]