浏览代码

fix DateTime bug

Looly 5 年之前
父节点
当前提交
f540888a4c
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      hutool-db/src/main/java/cn/hutool/db/handler/HandleHelper.java

+ 7 - 1
hutool-db/src/main/java/cn/hutool/db/handler/HandleHelper.java

@@ -268,7 +268,13 @@ public class HandleHelper {
 		Object rawValue;
 		switch (type) {
 		case Types.TIMESTAMP:
-			rawValue = rs.getTimestamp(columnIndex);
+			try{
+				rawValue = rs.getTimestamp(columnIndex);
+			} catch (SQLException ignore){
+				// issue#776@Github
+				// 当数据库中日期为0000-00-00 00:00:00报错,按照普通日期获取
+				rawValue = rs.getDate(columnIndex);
+			}
 			break;
 		case Types.TIME:
 			rawValue = rs.getTime(columnIndex);