我使用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工具(复制并从上方粘贴)运行命令,我可以看到的更新值。
这究竟是为什么?