我使用的程序一樣存儲數據庫的信息:調試MysqlDataTruncation例外
try{
connection = cpds.getConnection();
pstmt = connection.prepareStatement("select setSomeData(?,?)");
//set data to the statement
res = pstmt.executeQuery();
//process data retrieved
} catch (SQLException ex) {
System.out.println("SQLException: " + ex);
ex.printStackTrace();
return null;
} finally {
try {
pstmt.close();
connection.close();
} catch (SQLException ex) {
}
}
但有時我得到這個異常:
的SQLException:com.mysql.jdbc.MysqlDataTruncation :數據截斷:BIGINT UNSIGNED值超出範圍'(tstmp @ 5 - lastEvent @ 11)'
com.mysql.jdbc.MysqlDataTruncation:數據截斷:BIGINT UNSIGNED值超出'(tstmp @ 5 - lastEvent @ 11)'
at c om.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
在com.mysql.jdbc.MysqlIO.nextRowFast(MysqlIO.java:2066)
在com.mysql.jdbc.MysqlIO.nextRow(了MysqlIO。的java:1922)
在com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:3414)
在com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:481)
在com.mysql.jdbc .MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:3120)
在com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:2288)
在com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2709)
at com.mysql.jdbc.ConnectionImpl .execSQL在(ConnectionImpl.java:2677)
在com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2134)
在com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2300)
com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:116)
是否有可能知道等的影響列中的例外,那我想存儲的價值更多信息?
例如,對於異常:.MySQLTransactionRollbackException: Deadlock found when trying to get lock;
查詢SHOW ENGINE INNODB STATUS
是非常有用的...