Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module-jni: failure to load some jdbc drivers due to class loader handling errors from native Java #4740

Closed
davidnich opened this issue Aug 3, 2023 · 0 comments

Comments

@davidnich
Copy link
Contributor

when Qore methods wrapping native java are used from Java, dynamic dispatch needs to be used to create jdbc connections in order for the class loader context to be set correctly in Java

otherwise errors of the following type can occur even with valid URLs and a valid classpath:

java.sql.SQLException: No suitable driver found for jdbc:sqlserver://rippy;port=1433;encrypt=false
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:706)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:190)
	at org.qore.jni.QoreObjectBase.create0(Native Method)
	at org.qore.jni.QoreObjectBase.<init>(QoreObjectBase.java:19)
	at org.qore.jni.QoreObject.<init>(QoreObject.java:22)
	at org.qore.jni.QoreJavaClassBase.<init>(QoreJavaClassBase.java:10)
	at QoreURLClassLoader//qore.Qore.SQL.AbstractDatasource.<init>(Unknown Source)
	at QoreURLClassLoader//qore.Qore.SQL.DatasourcePool.<init>(Unknown Source)
	at QoreURLClassLoader//DsTest.main(DsTest.java:19)
@davidnich davidnich added this to the 1.17.1 milestone Aug 3, 2023
@davidnich davidnich self-assigned this Aug 3, 2023
@davidnich davidnich added this to To do in Qore Development via automation Aug 3, 2023
davidnich added a commit to qorelanguage/module-jni that referenced this issue Aug 3, 2023
…ctions to ensure that they do not fail when called from native Java -> Qore -> Java

re-use the module's classloader when the classloader is used as the initial class loader from native Java
davidnich added a commit to qorelanguage/module-jni that referenced this issue Aug 3, 2023
…ctions to ensure that they do not fail when called from native Java -> Qore -> Java (#173)

re-use the module's classloader when the classloader is used as the initial class loader from native Java
@davidnich davidnich added the fixed label Aug 3, 2023
Qore Development automation moved this from To do to Done Aug 3, 2023
davidnich added a commit to qorelanguage/module-jni that referenced this issue Aug 4, 2023
davidnich added a commit to qorelanguage/module-jni that referenced this issue Aug 7, 2023
…er context when creating jdbc connections
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

1 participant