BUG? -- MS SQL Server JDBC 13.2.1 with lucee.datasource.mssql.modern=true

Set up:
Lucee version 6.2.2.91 but has also been seen with 6.2.3.35
Microsoft SQL Server JDBC Driver 13.2.1
lucee.datasource.mssql.modern=true
or
LUCEE_DATASOURCE_MSSQL_MODERN=true

The follow query produces an error with the latest MS SQL jdbc driver and when the code path protected by lucee.datasource.mssql.modern=true is enabled.

The exception shown (full exception below):
lucee.runtime.exp.DatabaseException: The result set is closed. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:250)

The issues at lucee.runtime.type.QueryImpl.fillResult(QueryImpl.java:626) seems to point to the new driver not allowing result.getMetaData() to be called on a closed ResultSet.

<!--- Minimal test cases seems to need to have a parameterized query, set a reference for the result, and then attempt to access the result --->
<cfscript>
    function getsqlobj(objectId) {
        var getObj = QueryExecute(
            "SELECT TOP 10 name FROM sys.objects where object_id > :objectId",
            {objectId: {value: objectId, cfsqltype: "CF_SQL_INTEGER"}},
            {datasource: Application.DSN, result: "testResult"}
        );
        return {query: getObj, result: testResult};
    }
</cfscript>
<cfdump var="#getsqlobj(5)#">

There are other variations such as using the new Query() cfc that does something internal that always causes the exception.

Version 6.2.2.91 stacktrace:

lucee.runtime.exp.DatabaseException: The result set is closed. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:250) at com.microsoft.sqlserver.jdbc.SQLServerResultSet.checkClosed(SQLServerResultSet.java:496) at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getMetaData(SQLServerResultSet.java:2421) at lucee.runtime.type.QueryImpl.fillResult(QueryImpl.java:626) at lucee.runtime.type.QueryImpl.(QueryImpl.java:209) at lucee.runtime.type.QueryImpl.setGeneratedKeys(QueryImpl.java:554) at lucee.runtime.type.QueryImpl.executeMSSQL(QueryImpl.java:429) at lucee.runtime.type.QueryImpl.execute(QueryImpl.java:263) at lucee.runtime.type.QueryImpl.(QueryImpl.java:239) at lucee.runtime.tag.Query.executeDatasoure(Query.java:1125) at lucee.runtime.tag.Query._doEndTag(Query.java:692) at lucee.runtime.tag.Query.doEndTag(Query.java:557) at lucee.runtime.functions.query.QueryExecute.call(QueryExecute.java:86) at onehit.colbyttest_tbd_cfm$cf.udfCall(/OneHit/colbytTest_TBD.cfm:41) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:357) at lucee.runtime.type.UDFImpl.call(UDFImpl.java:224) at lucee.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:811) at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:773) at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:2081) at onehit.colbyttest_tbd_cfm$cf.call(/OneHit/colbytTest_TBD.cfm:45) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1118) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1012) at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:213) at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:41) at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2816) at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2803) at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2774) at lucee.runtime.engine.Request.exe(Request.java:45) at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1113) at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1070) at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97) at lucee.loader.servlet.jakarta.CFMLServlet.service(CFMLServlet.java:52) at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:195) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:164) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:483) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:116) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:732) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:398) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:903) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1769) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1189) at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:658) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63) at java.base/java.lang.Thread.run(Thread.java:840) Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The result set is closed. … 56 more

what was the previous jdbc version which worked?

I’m having a look

https://luceeserver.atlassian.net/browse/LDEV-5970

1 Like

It was working with 12.6.3.jre11 and likely quite a few other older versions, some of this code is really old.

ok, interesting bug!

this modern mssql support was always a bit hacky, which triggered this bug

after some research around the web, i figured out a nice solution which both solves the issue and makes this more robust/ efficient / faster

image

This afternoon (now very late tonight, 1.57am here in Berlin) ended up being a fix a lot of database issues day!

https://luceeserver.atlassian.net/browse/LDEV-5972

try 7.0.2.8 or 6.2.5.7 SNAPSHOTs

Also added some documentation

1 Like