0 Replies Latest reply on May 13, 2018 4:32 PM by Harsha Rav

    JBoss AS 6.4 with MSSQL database driver 6.2 (sqljdbc62.jar)

    Harsha Rav Newbie

      Hi,

       

      We upgraded from MSSQL JDBC driver version 4.0 to 6.2 and we are facing issues.

       

      Below is an exception for this INSERT statement (_DT are date fields (datetime, null allowed is true) )

       

              INSERT INTO SOME_TABLE

              (

                      SOME_PK

                      ,SOME_ID

                      ,NAME

                      ,DESC

                      ,UPLD_DT

                      ,START_DT

                      ,END__DT

                      ,COUNT

                      ,PATHT

                      ,C_DT

                      ,C_ID

                      ,M_DT

                      ,M_ID

              )

              VALUES

              (

                      ?

                      ,?

                      ,?

                      ,?

                      ,GETDATE()

                      ,?

                      ,?

                      ,?

                      ,?

                      ,GETDATE()

                      ,?

                      ,NULL

                      ,NULL

              )

       

      Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Implicit conversion from data type varbinary to date is not allowed. Use the CONVERT function to run this query.

              at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:258)

              at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1535)

              at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:467)

              at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:409)

              at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7151)

              at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2478)

              at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:219)

              at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:199)

              at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:356)

              at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:493)

              at org.springframework.jdbc.core.JdbcTemplate$3.doInPreparedStatement(JdbcTemplate.java:845) [spring-jdbc.jar:3.1.0.M2]

       

       

       

      I wrote a simple Java console application to execute the same above query, using MSSQL JDBC driver version 4.0 and also 6.2. And in both cases there were no issues.

      Data was inserted successfully.

       

      Hence I am led to believe there is something 'extra' happening with in JBoss AS 6.4 that is causing this exception.

       

      Just to follow the exception message's suggestion, I used convert function in the Java console application and it works.

      Now now I have the inserts working with or without CONVERT function with the Java console application but the same does not work with used within Web app running on JBoss AS 6.4.

       

      Any advise most welcome.

       

              INSERT INTO SOME_TABLE

              (

                      SOME_PK

                      ,SOME_ID

                      ,NAME

                      ,DESC

                      ,UPLD_DT

                      ,START_DT

                      ,END__DT

                      ,COUNT

                      ,PATH

                      ,C_DT

                      ,C_ID

                      ,M_DT

                      ,M_ID

              )

              VALUES

              (

                      1234

                      ,100

                      ,'Some name'

                      ,'Some desc'

                      ,GETDATE()

                      ,CONVERT(datetime, '')

                      ,CONVERT(datetime, '')

                      ,2345

                      ,'/some/path/'

                      ,GETDATE()

                      ,'Some_C_ID'

                      ,CONVERT(datetime, '')

                      ,NULL

              )