Details
Assignee
Michael OffnerMichael OffnerReporter
Brad WoodBrad WoodPriority
NewLabels
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Details
Details
Assignee
Michael Offner
Michael OffnerReporter
Brad Wood
Brad WoodPriority
Labels
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Created 24 January 2020 at 00:21
Updated 15 November 2023 at 22:25
I found this on accident when I manually declared a datasource connection that used the JTDS driver but accidentally used the Microsoft JDBC connection string:
dsources[ "MyDSN" ] = { "class" = "net.sourceforge.jtds.jdbc.Driver", // WRONG CONNECTION STRING "connectionString" = "jdbc:sqlserver://192.168.6.13:1433;DATABASENAME=myDB", "username" = "user", "password" = "pass", "bundleName" = "jtds", "bundleVersion" = "1.3.1" };
The error was a null pointer exception which was unhelpful and difficult to track down.
lucee.runtime.exp.NativeException: java.lang.NullPointerException at lucee.runtime.db.DatasourceConnectionPool.loadDatasourceConnection(DatasourceConnectionPool.java:135) at lucee.runtime.db.DatasourceConnectionPool.getDatasourceConnection(DatasourceConnectionPool.java:101) at lucee.runtime.db.DatasourceManagerImpl.getConnection(DatasourceManagerImpl.java:73) at lucee.runtime.tag.Query.executeDatasoure(Query.java:1043) at lucee.runtime.tag.Query._doEndTag(Query.java:660) at lucee.runtime.tag.Query.doEndTag(Query.java:542) at lucee.runtime.functions.query.QueryExecute.call(QueryExecute.java:86)
If you look at the docs, you'll find this:
https://docs.oracle.com/javase/7/docs/api/java/sql/Driver.html#connect(java.lang.String,%20java.util.Properties)
Lucee does not account for getting null back when asking the driver to connect. Lucee needs to check for a null value back and throw an exception that explains that the driver has rejected the connection string. Here is the line of code in Lucee that needs to be doing this check:
https://github.com/lucee/Lucee/blob/master/core/src/main/java/lucee/runtime/db/DataSourceSupport.java#L111