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

IllegalMonitorStateException on connection to Netezza DB #50

Open
metanoid opened this issue Sep 27, 2019 · 9 comments
Open

IllegalMonitorStateException on connection to Netezza DB #50

metanoid opened this issue Sep 27, 2019 · 9 comments

Comments

@metanoid
Copy link

I'm trying to extract data from a Netezza database.

I run the following:

using JavaCall
JavaCall.addClassPath("C:/JDBC/nzjdbc.jar")
using JDBC
JDBC.usedriver("C:/JDBC/nzjdbc.jar")
JDBC.init()
classforname("org.netezza.Driver")
hostname = "hostname"
port = "5480"
database = "db"
connectionstring = "jdbc:netezza://$(hostname):$(port)/$(database);user=$(ENV["netezza_user"]);password=$(ENV["netezza_pwd"])"
conn = JDBC.DriverManager.getConnection(connectionstring)

I get the following error:

JavaCall.JavaCallError("Error calling Java: java.lang.IllegalMonitorStateException")
in top-level scope at base\none
in getConnection at JDBC\yjpfX\src\JDBC.jl:19
in jcall at JavaCall\toamy\src\core.jl:143
in _jcall at JavaCall\toamy\src\core.jl:247
in geterror at JavaCall\toamy\src\core.jl:274 
in geterror at JavaCall\toamy\src\core.jl:294

I don't know why this is happening, and can't find clues in the documentation

@aviks
Copy link
Member

aviks commented Sep 28, 2019

Not sure what is happening here? What version of Java are you using? If you write similar code in Java directly, does it work?

@metanoid
Copy link
Author

I have:

java version "1.8.0_212"
Java(TM) SE Runtime Environment (build 1.8.0_212-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.212-b10, mixed mode)

I can try figure out similiar java code, but I'm no expert. Could you provide an example java code snippet that I could use as a template?

@metanoid
Copy link
Author

This essentially equivalent code works in R on the same machine.

library(RJDBC)

drv = JDBC(driverClass = "org.netezza.Driver",
           classPath = "C:/JDBC/nzjdbc.jar")
conn = dbConnect(drv, paste0("jdbc:netezza://DCP:5480/db;user=",username,";password=",pwd))
dbListTables(conn)
a = dbGetQuery(conn, "SELECT *
  FROM H_OD.HS_CM.HE_ATT
               limit 100")

@aviks
Copy link
Member

aviks commented Oct 4, 2019

And which version of Julia? Also, is a Java stack trace printed at all?

The trouble is, I do not have access to a netezza database, and even the driver is not freely downloadable.

@metanoid
Copy link
Author

metanoid commented Oct 4, 2019

Unfortunately no Java stack trace is shown - maybe there's a way to make Java more verbose?

julia> versioninfo()
Julia Version 1.2.0
Commit c6da87ff4b (2019-08-20 00:03 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
  JULIA_EDITOR = "C:\Users\colin37\AppData\Local\JuliaPro-1.2.0-1\app-1.40.1\atom.exe"  -a
  JULIA_NUM_THREADS = 4

@aviks
Copy link
Member

aviks commented Oct 6, 2019

Ah could you please try with Julia 1.0.x? There are some issues with threading and Julia 1.1/1.2

@metanoid
Copy link
Author

metanoid commented Oct 7, 2019

Ah could you please try with Julia 1.0.x? There are some issues with threading and Julia 1.1/1.2

Julia 1.0.5 (LTS) works for the above - thanks!

@metanoid metanoid closed this as completed Oct 7, 2019
@metanoid
Copy link
Author

Testing on Julia 1.3.0, and this is still an issue. Error message seems more informative now?

julia> cnxn = JDBC.Connection("jdbc:oracle:thin:@$(hostname):$(port)/$(service_name)", props = Dict("user" => ENV["oracle_user"], "password" => ENV["oracle_pwd"]))
Exception in thread "main" ERROR: JavaCall.JavaCallError("Error calling Java: java.lang.NoClassDefFoundError: Could not initialize class oracle.jdbc.driver.T4CDriverExtension")
Stacktrace:
 [1] geterror(::Bool) at C:\Users\username\.julia\packages\JavaCall\Iz2MQ\src\core.jl:294
 [2] geterror at C:\Users\username\.julia\packages\JavaCall\Iz2MQ\src\core.jl:274 [inlined]
 [3] _jcall(::JavaMetaClass{Symbol("java.sql.DriverManager")}, ::Ptr{Nothing}, ::Ptr{Nothing}, ::Type, ::Tuple{DataType,DataType}, ::String, ::Vararg{Any,N} where N) at C:\Users\username\.julia\packages\JavaCall\Iz2MQ\src\core.jl:247
 [4] jcall(::Type{JavaObject{Symbol("java.sql.DriverManager")}}, ::String, ::Type, ::Tuple{DataType,DataType}, ::String, ::Vararg{Any,N} where N) at C:\Users\username\.julia\packages\JavaCall\Iz2MQ\src\core.jl:143
 [5] getConnection(::String, ::Dict{String,String}) at C:\Users\username\.julia\packages\JDBC\2ruzk\src\JDBC.jl:23
 [6] #Connection#1(::Dict{String,String}, ::String, ::Type{JDBC.Connection}, ::String) at C:\Users\username\.julia\packages\JDBC\2ruzk\src\interface.jl:50
 [7] (::Core.var"#kw#Type")(::NamedTuple{(:props,),Tuple{Dict{String,String}}}, ::Type{JDBC.Connection}, ::String) at .\none:0
 [8] top-level scope at none:0

@mkitti
Copy link

mkitti commented Oct 7, 2020

I guess the question is whether oracle.jdbc.driver.T4CDriverExtension is on your classpath. If it is, is there another class that it depends on which is not? How did you set your classpath?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants