我正在使用 JDBC 更新我的 MySQL 数据库中的一行:
pConnection.setAutoCommit(true);
PreparedStatement pstmt = pConnection.prepareStatement("update mg_build_queue " + //
"set buildsetid=?,locale=?,areacode=?,distversionid=?,platformid=?,version=?," + //
"priority=?,buildstatus=?,computername=?,buildoutput=?,started=?,finished=?, packageid=?, lockcounter=0 where buildid=?" //
);
pstmt.setInt(1, mBuildSet.getId());
pstmt.setString(2, Locale.localesToString(mLocales, ","));
pstmt.setString(3, mAreaCode.toString());
pstmt.setInt(4, mDistVersionId);
pstmt.setInt(5, mPlatform);
pstmt.setInt(6, mVersion);
pstmt.setLong(7, mPriority);
pstmt.setInt(8, mBuildStatus);
pstmt.setString(9, mComputerName);
pstmt.setString(10, mBuildOutput);
pstmt.setTimestamp(11, timeToTimestamp(mStarted));
pstmt.setTimestamp(12, timeToTimestamp(mFinished));
pstmt.setInt(13, mResultPackageId);
pstmt.setInt(14, mBuildId);
LOGGER.debug("Updating data for mg_build_queue: " + pstmt);
pstmt.execute();
LOGGER.debug("Updated " + pstmt.getUpdateCount() + " rows.");
这将生成以下输出:
2012-05-24 09:54:33,211 [Thread-1] DEBUG com.buildmaster.BuildQueueEntryImpl - Updating data for mg_build_queue: com.mysql.jdbc.JDBC4PreparedStatement@35e09eab: update mg_build_queue set buildsetid=201,locale='FR',areacode='XX',distversionid=95,platformid=4604,version=65807,priority=33652480,buildstatus=1,computername='MY_COMPUTER-C:\\BUILDS',buildoutput='',started='2012-05-24 09:54:33',finished='2012-05-24 19:45:27', packageid=0, lockcounter=0 where buildid=122418
2012-05-24 09:54:33,214 [Thread-1] DEBUG com.buildmaster.BuildQueueEntryImpl - Updated 1 rows.
我看不出有什么例外。如果我在 DBVisualizer 中查询条目,我只会看到旧值。如果我在 DBVisualizer 中手动运行命令(从上面复制和粘贴),我可以看到更新的值。
为什么会这样?