none
Problem with Microsoft SQL Server 2005 JDBC Driver :JDBC Driver Version 1.2

    Dotaz

  • I am using Microsoft SQL Server 2005 JDBC Driver  : JDBC Driver Version 1.2 (sqljdbc1.2.jar) driver to my Java application. Previously we were using jtds1.2.jar(jtds) driver. As we have migrated from MS SQL 2000 to MS  SQL 2005 we need to upgrade database driver in our java application. Doing so, we face difficulties in executing stored procedures through hibernate. This was not case when we were using jtds driver. Now it throws exception :

     

    WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: null

    15:23:14,713 INFO [STDOUT] 15:23:14,713 ERROR [JDBCExceptionReporter] The statement did not return a result set.

    15:23:14,713 ERROR [STDERR] org.hibernate.exception.GenericJDBCException: could not execute query

    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)

    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)

    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)

    at org.hibernate.loader.Loader.doList(Loader.java:2147)

    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)

    at org.hibernate.loader.Loader.list(Loader.java:2023)

    at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)

    at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)

    at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)

    at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:150)

    at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:780)

    at com.ge.lease.dao.services.AuditReportService.createAuditReport(AuditReportService.java:59)

    at com.ge.lease.web.AuditReportController.handleRequest(AuditReportController.java:74)

    at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)

    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:717)

    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:658)

    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:392)

    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:347)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)

    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.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)

    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)

    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.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)

    at java.lang.Thread.run(Unknown Source)

    Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.

    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(Unknown Source)

    at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(Unknown Source)

    at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:236)

    at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)

    at org.hibernate.loader.Loader.getResultSet(Loader.java:1668)

    at org.hibernate.loader.Loader.doQuery(Loader.java:662)

    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)

    at org.hibernate.loader.Loader.doList(Loader.java:2144)

     

    Seems problem in converting date format.

     

    Help me out if you have any suggestion.

    18. července 2008 19:49

Odpovědi

  •  

    Hi Rajiv,

     

    Can you tell me what version of Hibernate you are using?  Also, do you know what was the query that failed to produce a ResultSet?  Per the JDBC specification, the PreparedStatement.executeQuery method should only be used for queries or stored procedure calls that are expected to return a single result set and nothing else.  The v1.2 driver enforces this requirement, where some other JDBC drivers do not.  Is it possible that the query is returning an update count rather than a ResultSet as its first (or only?) result?

     

    Regards,

    --David Olix [MSFT]

    19. července 2008 8:07
    Moderátor

Všechny reakce

  •  

    Hi Rajiv,

     

    Can you tell me what version of Hibernate you are using?  Also, do you know what was the query that failed to produce a ResultSet?  Per the JDBC specification, the PreparedStatement.executeQuery method should only be used for queries or stored procedure calls that are expected to return a single result set and nothing else.  The v1.2 driver enforces this requirement, where some other JDBC drivers do not.  Is it possible that the query is returning an update count rather than a ResultSet as its first (or only?) result?

     

    Regards,

    --David Olix [MSFT]

    19. července 2008 8:07
    Moderátor
  • Hi David,

     

    We are using Hibernate 3.  Our application only calls procedure from SQL server 2005.  Thanks David, I analyze the things and you are right that our procedure used to give scalar value sometimes.

     

    Issue given came up when procedure retuns scalar value instead of Resultset. Does it necessary to return resultset? Any work around if it can not return resultset?

     

    Many of our procedure returns scalar values so going into each one and making changes would be nightmare. Is that any other way we can handle this issue?

     

    Regards,

     

    Rajiv Bhalani

    6. srpna 2008 20:56
  • Since the procedures are stored procedures, in the scenario where only a scalar value is returned, how is the value returned?  As an output parameter?  As the return value of the stored procedure?  As "Select <scalar value>"?

     

    Depending on how the value is returned, there may be different ways to retrieve the data from the client application without changing the stored procedure itself.

     

    Regards,

    Jimmy

    8. srpna 2008 0:35
    Moderátor
  •  

    Value is return as return value of store proc ! Let me know the way to deal it.

     

    One more finding : I feel that hibernate dialect is not supported for MS SQL 2005 Driver the way it is being supported by JTDS driver. In one of procedure passing a null value as an input parameter, hibernate fails to deliver that null value through MS SQL Driver where as it works perfect with JTDS driver.

     

    Any suggestion for this ?

     

    Regards,

     

     

    8. srpna 2008 15:53
  • In the case where the stored proc only returns a return value, you'll need to call the stored proc using Execute() instead of executeQuery().

     

    I recommend posting separate forum posting regarding your question on Hibernate support, so the question will get better visibility.

     

    Jimmy

    12. srpna 2008 22:11
    Moderátor