Closed wzymaster closed 7 years ago
have similar problem
I have the same problem as well
My case is worse... :-( Although I have JRE installed and the library on the CLASSLIB path, the JDBC driver it is not found and I always have an exception.... I also try to use jaydebeapi.connect, but then I do have the following error:
Traceback (most recent call last):
File "./dash.py", line 23, in
Don't know the ibmdbpy module. Please report the problem there. Jaydebeapi as all other db api drivers always requires you to call connect before using it.
I fixed this issue by passing the url. I used to not be able to connect and would get the following error:
java.lang.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class com.ibm.db2.jcc.DB2Driver not found
Here is an example:
jdbc_driver_name = 'com.ibm.db2.jcc.DB2Driver'
jdbc_driver_loc = 'path/to/db2jcc4.jar'
url = '{0}:user={1};password={2};;'.format(host, login, psw)
conn = jaydebeapi.connect(jclassname=jdbc_driver_name, url=url, jars=jdbc_driver_loc)
I'm still having this issue and am really stumped. I've tried passing the url like genomics-geek above and I've tried keeping the url separate from the driver_args. The weird thing is that I am able to use these connection parameters exactly in R and it works, so why wouldn't it in Python?
EDIT: my computer was logged off over night. Upon logging back in, I am able to establish the JDBC connection. I'm not sure why that is.
Please post a code snippet
Am 28.02.2017 1:59 vorm. schrieb "dfalkson" notifications@github.com:
I'm still having this issue and am really stumped. I've tried passing the url like genomics-geek above and I've tried keeping the url separate from the driver_args. The weird thing is that I am able to use these connection parameters exactly in R and it works, so why wouldn't it in Python?
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/baztian/jaydebeapi/issues/22#issuecomment-282907826, or mute the thread https://github.com/notifications/unsubscribe-auth/ACWQrV7wzm1Xpc3jrvWML5MoB86tUdoZks5rg3F_gaJpZM4HuKnP .
I have the same problem, any fix for jupyter? The code works great in a native python script, but fails within my notebook.
$ jupyter-notebook --version
5.6.0
$ python3 --version
Python 3.7.0
import jaydebeapi
import sys,os,os.path
conn = 'jdbc:db2://host:port/db:sslConnection=true;sslTrustStoreLocation=ertTrustStore;sslTrustStorePassword=jgjgjg;'
class_name = 'com.ibm.db2.jcc.DB2Driver'
sql = 'Select * table A fetch first 100 rows only'
login = ['user','pass']
jars = 'db2java/db2jcc4.jar'
conn = jaydebeapi.connect(class_name, conn, login, jars)
jars
is within the same directory as the notebook. But still, this code won't work in jupyer notebook.
Any ideas?
@baztian , I am also seeing a failure running inside a Jupyter notebook vs a standalone python script where it works fine. I can't seem to figure out the difference. Here is the code run in the notebook:
# create JDBC connection to the netezza database
import jaydebeapi
!echo 'JAVA_HOME: '$JAVA_HOME
print("Driver name: " + driverName + "\nDriver path: " + driverFileName)
!ls -altr $driverFileName
!ls -daltr $driverDir
print("jaydebeapi version: " + jaydebeapi.__version__)
mpwconn = jaydebeapi.connect(jclassname=driverName, url=connectionString, driver_args={'user': uid, 'password': pwd},jars=driverFileName)
JAVA_HOME: /opt/ibm/java-x86_64-80
Driver name: org.netezza.Driver
Driver path: /home/dsxuser/drivers/nzjdbc-3.jar
-rwxr-xr-x 1 dsxuser dsxuser 359254 Oct 16 16:55 /home/dsxuser/drivers/nzjdbc-3.jar
drwxr-xr-x 2 dsxuser dsxuser 4096 Oct 16 15:09 /home/dsxuser/drivers
jaydebeapi version: 1.1.1
---------------------------------------------------------------------------
java.lang.RuntimeExceptionPyRaisable Traceback (most recent call last)
<ipython-input-37-03b494b3284a> in <module>()
11 #!md5sum $driverFileName
12
---> 13 mpwconn = jaydebeapi.connect(jclassname=driverName, url=connectionString, driver_args={'user': uid, 'password': pwd},jars=driverFileName)
14
15 curs = mpwconn.cursor()
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/jaydebeapi/__init__.py in connect(jclassname, url, driver_args, jars, libs)
379 else:
380 libs = []
--> 381 jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
382 return Connection(jconn, _converters)
383
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/jaydebeapi/__init__.py in _jdbc_connect_jpype(jclassname, url, driver_args, jars, libs)
188 return jpype.JArray(jpype.JByte, 1)(data)
189 # register driver for DriverManager
--> 190 jpype.JClass(jclassname)
191 if isinstance(driver_args, dict):
192 Properties = jpype.java.util.Properties
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/jpype/_jclass.py in JClass(name)
53 jc = _jpype.findClass(name)
54 if jc is None:
---> 55 raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name)
56
57 return _getClassFor(jc)
java.lang.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class org.netezza.Driver not found
curs = mpwconn.cursor()
Is there any other information that I can provide to shed some light on why it can't find the class?
I am trying to connect to Netezza using the following code
import jaydebeapi
conn = jaydebeapi.connect(jclassname= "org.netezza.Driver",
url="jdbc:netezza://XXX.XXX.XXX.XXX:5480/DB",
driver_args=["sroy", "xxxx"],
jars= "/Users/roysu001/nzjdbc3.jar")
its giving me
java.lang.RuntimeExceptionPyRaisable Traceback (most recent call last)
<ipython-input-29-fa62ef797f95> in <module>()
2 url="jdbc:netezza://159.127.220.71:5480/PSTPLRDMDB01",
3 driver_args=["stpl_sroy", "Euler_pi_3.14"],
----> 4 jars= "/Users/roysu001/nzjdbc3.jar")
/anaconda3/lib/python3.7/site-packages/jaydebeapi/__init__.py in connect(jclassname, url, driver_args, jars, libs)
379 else:
380 libs = []
--> 381 jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
382 return Connection(jconn, _converters)
383
/anaconda3/lib/python3.7/site-packages/jaydebeapi/__init__.py in _jdbc_connect_jpype(jclassname, url, driver_args, jars, libs)
188 return jpype.JArray(jpype.JByte, 1)(data)
189 # register driver for DriverManager
--> 190 jpype.JClass(jclassname)
191 if isinstance(driver_args, dict):
192 Properties = jpype.java.util.Properties
/anaconda3/lib/python3.7/site-packages/jpype/_jclass.py in JClass(name)
71 jc = _jpype.findClass(name)
72 if jc is None:
---> 73 raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name)
74
75 return _getClassFor(jc)
java.lang.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class org.netezza.Driver not found
I am on Python 3 and Mac @baztian any idea
I get the same error. How to fix this?
I am trying this in my Python notebook in Jupyter 3.0 and unfortunately, it always complains that an error like :
Here is my source code:
It seems like that JayDeBeApi has problem to retrieve DB2 driver class, however, this jar file is actually in presence at '/usr/local/lib/db2jcc4.jar'.
However, if I manually inject a line of "jaydebeapi.connect('com.ibm.db2.jcc.DB2Driver', connection_string,'/usr/local/lib/db2jcc4.jar')" like the below, everything works fine :
I am just wondering why db2 driver can't be recognized by default unless I explicitly invoke jaydebeapi.connect() function. Why ?