JuliaPro JDBC.destroy() not working

I am trying to use JDBC in the JuliaPro IDE, but it doesn’t seem to release the JMV from memory when the destroy() method is called. If I run the following code twice, then I get an error, but shouldn’t it work if destroy() released the JVM from memory?

Code:

using JDBC
JDBC.init()
JDBC.destroy()

Error:

ERROR: LoadError: JavaCall.JavaCallError("Unable to initialise Java VM: -1")
Stacktrace:
 [1] init(::OrderedCollections.OrderedSet{String}) at C:\Users\dburch\.juliapro\JuliaPro_v1.0.5-2\packages\JavaCall\0wJQZ\src\jvm.jl:180
 [2] init() at C:\Users\dburch\.juliapro\JuliaPro_v1.0.5-2\packages\JavaCall\0wJQZ\src\jvm.jl:156
 [3] init() at C:\Users\dburch\.juliapro\JuliaPro_v1.0.5-2\packages\JDBC\2ruzk\src\JDBC.jl:40
 [4] top-level scope at none:0
in expression starting at untitled-101b06be47b56380518cb53da02cdcaa:2

Yeah, the JNI unload does not work correctly. I thought I had documented this somewhere, but can’t find it now.

This is one of the reasons why the init is not called by default on module load – the user needs to call it explicitly. This allows you to set the required classpath before the JVM loads, since once loaded, you cannot unload it till the process restarts.

Hope this helps.

Avik

1 Like

Does this mean it won’t be possible to use two different drivers at the same time? I was trying to connect through JDBC to both a MySQL and Oracle databases (using two different JDBC drivers). I am able to use JDBC to connect independently, but connecting to both has proved to be fruitless so far.

No, you absolutely can. The trick is to set the classpath with both driver jars before you call init. So something like the below:

using JDBC
JDBC.usedriver("path_to_oracle_driver")
JDBC.usedriver("path_to_mysql_driver")
JDBC.init()

conn1 = DriverManager.getConnection(<oracle connection string>)
conn2 =  DriverManager.getConnection (<mysql connection string>)
.....
<use conn and conn2 to make queries and fetch data>
......
close(conn1)
close(conn2)

Does this not work for you?

1 Like

It worked! Thank you. You made my day/night. If you post this answer to this other post, then I’ll mark it solved: JDBC 2 Concurrent Connections

The topic on this page is different. I’ll mark your other post as the answer, since it explains what’s happening for posterity and the like.