mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix timestamp bug
This commit is contained in:
@@ -265,15 +265,14 @@ public class HandleHelper {
|
||||
* @throws SQLException SQL异常
|
||||
*/
|
||||
private static <T> Object getColumnValue(ResultSet rs, int columnIndex, int type, Type targetColumnType) throws SQLException {
|
||||
Object rawValue;
|
||||
Object rawValue = null;
|
||||
switch (type) {
|
||||
case Types.TIMESTAMP:
|
||||
try{
|
||||
rawValue = rs.getTimestamp(columnIndex);
|
||||
} catch (SQLException ignore){
|
||||
// issue#776@Github
|
||||
// 当数据库中日期为0000-00-00 00:00:00报错,按照普通日期获取
|
||||
rawValue = rs.getDate(columnIndex);
|
||||
// 当数据库中日期为0000-00-00 00:00:00报错,转为null
|
||||
}
|
||||
break;
|
||||
case Types.TIME:
|
||||
|
@@ -5,6 +5,7 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* MySQL操作单元测试
|
||||
@@ -26,11 +27,11 @@ public class MySQLTest {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 事务测试<br>
|
||||
* 更新三条信息,低2条后抛出异常,正常情况下三条都应该不变
|
||||
*
|
||||
*
|
||||
* @throws SQLException SQL异常
|
||||
*/
|
||||
@Test(expected=SQLException.class)
|
||||
@@ -56,4 +57,11 @@ public class MySQLTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void getTimeStampTest() throws SQLException {
|
||||
final List<Entity> all = Db.use("mysql").findAll("test");
|
||||
Console.log(all);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ user = looly
|
||||
pass = 123456
|
||||
|
||||
[mysql]
|
||||
url = jdbc:mysql://looly.centos:3306/test_hutool?useSSL=false
|
||||
url = jdbc:mysql://looly.centos8:3306/hutool_test?useSSL=false
|
||||
user = root
|
||||
pass = 123456
|
||||
|
||||
|
Reference in New Issue
Block a user