【发布时间】:2015-12-13 16:44:23
【问题描述】:
在使用 UCanAccess JDBC 驱动程序访问 MS Access DB 时,我在处理日期时遇到了太多问题。我想检查日期/时间字段是否为空。如果有 Null 则想更新,但我不能这样做。 MSAccess 数据库中的“logout_time”字段是“日期/时间”数据类型。
String sqlString = "update user_Log set logout_time = #" +
strEndDate + "# where (user_Id ="+
userId +") & (logout_time = NULL)";
int l=stmt.executeUpdate(sqlString);
这将发送 sqlString
update user_Log set logout_time = #12/13/2015 10:33:28# where (user_Id =3) & (logout_time = NULL);
此 SQL 语句在 MSAccess Query 中执行良好。但它不能从 UCanAccess JDBC 驱动程序中执行。它会产生错误:
net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::3.0.3 incompatible data types in combination
This exception may happen if you add integers representing units of time directly to datetime values using the arithmetic plus operator but without specifying the unit of date.
In this specific case you have to use, for example, <dateColumn> + 1 DAY.
at net.ucanaccess.jdbc.UcanaccessStatement.executeUpdate(UcanaccessStatement.java:222)
【问题讨论】:
标签: ms-access jdbc ucanaccess