Unable to convert between java.util.Date and TIMESTAMP

When creating a DB SQLTag with a datetime datatype, I get an exception:

[quote]java.sql.SQLException: Unable to convert between java.util.Date and TIMESTAMP.
at net.sourceforge.jtds.jdbc.Support.convert(Support.java:565)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setObjectBase(JtdsPreparedStatement.java:286)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setObject(JtdsPreparedStatement.java:589)
at org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:162)
at com.calmetrics.gateway.sqltags.db.DatasourceTagProvider.insertTagDeep(DatasourceTagProvider.java:1335)
at com.calmetrics.gateway.sqltags.db.DatasourceTagProvider.addTags(DatasourceTagProvider.java:1152)
at com.calmetrics.gateway.servlets.Gateway.runSQLTagAdd(Gateway.java:1115)
at com.calmetrics.gateway.servlets.Gateway.doPost(Gateway.java:310)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at com.calmetrics.gateway.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
FactoryPMI v3.1.3 (build 1621)
Java: Sun Microsystems Inc. 1.6.0_04[/quote]

Timestamp is not the correct datatype to use in SQL Server anyway. So I don’t know why it says this. The correct datatype should be datetime for SQL Server.

The “TIMESTAMP” here is refering to the name of the JDBC SQL type abstraction for datetimes/timestamps. We’re looking into this error, hang tight…

Turns out this is due to an oddity in the behavior of the JTDS driver that we use to connect to SQL Server. This won’t happen in FactoryPMI 3.1.4, which will be released early next week.

Thanks,

We got Microsoft’s JDBC driver working, but it has a similar problem:

[quote]com.microsoft.sqlserver.jdbc.SQLServerException: The Java type java.util.Date is not a supported type.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
at com.microsoft.sqlserver.jdbc.AppDTVImpl$SetValueOp.executeDefault(Unknown Source)
at com.microsoft.sqlserver.jdbc.DTV.executeOp(Unknown Source)
at com.microsoft.sqlserver.jdbc.AppDTVImpl.setValue(Unknown Source)
at com.microsoft.sqlserver.jdbc.DTV.setValue(Unknown Source)
at com.microsoft.sqlserver.jdbc.Parameter.setValue(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setObject(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setObject(Unknown Source)
at org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:162)
at com.calmetrics.gateway.sqltags.db.DatasourceTagProvider.insertTagDeep(DatasourceTagProvider.java:1335)
at com.calmetrics.gateway.sqltags.db.DatasourceTagProvider.addTags(DatasourceTagProvider.java:1152)
at com.calmetrics.gateway.servlets.Gateway.runSQLTagAdd(Gateway.java:1115)
at com.calmetrics.gateway.servlets.Gateway.doPost(Gateway.java:310)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at com.calmetrics.gateway.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)[/quote]

Ezekiel, our resident Java expert, says this is because you gotta use the java.sql.Timestamp to wrap the date into the timestamp. (Whatever that means.)

Anyway, I’ll wait for 3.1.4 and use the JTDS driver.

Nice, you guys are good. Looks like JTDS used the official driver as a functional spec.... (other database drivers do accept java.util.Date)

Ezekiel is right, which is exactly the workaround that we used in version 3.1.4. Well, actually we wrapped it in a java.sql.Date, but that works too.