我寫了一個Java代碼中插入當前日期,但是當我嘗試運行它發生異常:如何插入日期
public void Session_Table_Update (String Update_User) throws SQLException{
String SQL_Statement = null;
error_Message = null;
if (ds == null) throw new SQLException(error_Database = "No data source");
Connection conn = ds.getConnection();
if (conn == null) throw new SQLException(error_Database = "No connection");
try {
conn.setAutoCommit(false);
boolean committed = false;
try {
SQL_Statement = "INSERT INTO USERS (LAST_LOGIN) VALUES (?,?,?) WHERE USERZ ="+ Update_User;
PreparedStatement insertQuery = conn.prepareStatement(SQL_Statement);
insertQuery.setString(3, "2.2.2011");
insertQuery.executeUpdate();
conn.commit();
committed = true;
} finally {
if (!committed) conn.rollback();
}
}
finally {
conn.close();
}
return;
}
你能不能幫我解決這個問題?
您使用的數據庫是? – 2011-12-16 12:56:08
更重要的是,你會得到什麼例外?它們通常包含整個答案。 – BalusC 2011-12-16 12:58:48