0
這是我的映射。爲什麼jTDS無法將SQL Server datetime轉換爲java.sql.Timestamp?
@Column(name = "someDateTime") // which is `datetime` in SQL Server table
public java.sql.Timestamp getSomeDateTime() {
return someDateTime;
}
URL is spring.datasource.url=jdbc:jtds:sqlserver://myUrl:1433/bizproj;socketTimeout=21600
我使用jTDS 1.3.1和Hibernate 5.0.9以及Spring Boot 1.4與SQL Server連接。
我運行到時從SQL Server該列加載內容
Caused by: java.sql.SQLException: Value 2009-02-25 07:51:54.2730000 +00:00 cannot be converted to TIMESTAMP.
at net.sourceforge.jtds.jdbc.Support.convert(Support.java:516) ~[jtds-1.3.1.jar:1.3.1]
at net.sourceforge.jtds.jdbc.JtdsResultSet.getTimestamp(JtdsResultSet.java:1182) ~[jtds-1.3.1.jar:1.3.1]
at net.sourceforge.jtds.jdbc.JtdsResultSet.getTimestamp(JtdsResultSet.java:1334) ~[jtds-1.3.1.jar:1.3.1]
at org.hibernate.type.descriptor.sql.TimestampTypeDescriptor$2.doExtract(TimestampTypeDescriptor.java:76) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:47) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:238) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:234) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:224) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:300) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2727) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1729) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1655) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
at org.hibernate.loader.Loader.getRow(Loader.java:1544) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:727) ~[hibernate-core-5.0.9.Final.jar:5.0.9.Final]
的價值,排在數據庫以下錯誤是2009-02-25 07:51:54.273
我可能失去了一些東西,但我即使經過一些調查後仍無法弄清楚。我嘗試了joda時間和jadira,但異常沒有改變。任何指導非常感謝。