Class com.tnf.accm.jdbc.XYZDriver not found

Asked by Neil

Hi,
the jpype part is fine, but jaydebeapi is not able to recognise an inhouse proprietary driver. I have no problem connecting to the db using this JDBC driver and definition via DBVisualiser and SQLSquirrel.

Am I making a mistake in the definition/code below?

import jpype
import jaydebeapi
jar = r'E:\_db\xyz-jdbc-driver-2.5.jar'
args='-Dcom.companyname.xyz.jdbc.XYZDriver=%s' % jar
jvm_path = jpype.getDefaultJVMPath()
jpype.startJVM(jvm_path, args)

-- No problem up until here --

conn = jaydebeapi.connect('com.companyname.xyz.jdbc.XYZDriver', 'jdbc:xyz://172.30.2.104:2099', 'sa','')

---------------------------------------------------------------------------
java.lang.ExceptionPyRaisable Traceback (most recent call last)
<ipython-input-9-403ffa4ec25f> in <module>()
----> 1 conn = jaydebeapi.connect('com.companyname.xyz.jdbc.XYZDriver', 'jdbc:xyz://172.30.2.104:2099', '','')

C:\_data\_installs\WinPython-32bit-2.7.5.3\python-2.7.5\lib\site-packages\jaydebeapi\dbapi2.pyc in connect(jclassname, *args)
    178 # DB-API 2.0 Module Interface connect constructor
    179 def connect(jclassname, *args):
--> 180 jconn = _jdbc_connect(jclassname, *args)
    181 return Connection(jconn)
    182

C:\_data\_installs\WinPython-32bit-2.7.5.3\python-2.7.5\lib\site-packages\jaydebeapi\dbapi2.pyc in _jdbc_connect_jpype(jclassname, *args)
     69 return jpype.JArray(jpype.JByte, 1)(data)
     70 # register driver for DriverManager
---> 71 jpype.JClass(jclassname)
     72 return jpype.java.sql.DriverManager.getConnection(*args)
     73

C:\_data\_installs\WinPython-32bit-2.7.5.3\python-2.7.5\lib\site-packages\jpype\_jclass.pyc in JClass(name)
     52 jc = _jpype.findClass(name)
     53 if jc is None :
---> 54 raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name)
     55
     56 return _getClassFor(jc)

java.lang.ExceptionPyRaisable: java.lang.Exception: Class com.companyname.xyz.jdbc.XYZDriver not found

Question information

Language:
English Edit question
Status:
Solved
For:
JayDeBeApi Edit question
Assignee:
No assignee Edit question
Solved by:
Bastian
Solved:
Last query:
Last reply:
Revision history for this message
Best Bastian (baztian) said :
#1

Replace
args='-Dcom.companyname.xyz.jdbc.XYZDriver=%s' % jar
with
args='-Djava.class.path=%s' % jar

Please report back if that works. Also note that I've just released a new version of JayDeBeApi that makes it easy to setup the classpath. In your case using JayDeBeApi 0.1.4 you could either

define the CLASSPATH environment variable
set CLASSPATH=E:\_db\xyz-jdbc-driver-2.5.jar
and replace your code with just these two lines

import jaydebeapi
conn = jaydebeapi.connect('com.companyname.xyz.jdbc.XYZDriver', ['jdbc:xyz://172.30.2.104:2099', 'sa',''])

or if you don't want to have a CLASSPATH environment variable

import jaydebeapi
conn = jaydebeapi.connect('com.companyname.xyz.jdbc.XYZDriver', ['jdbc:xyz://172.30.2.104:2099', 'sa',''], r'E:\_db\xyz-jdbc-driver-2.5.jar')

Revision history for this message
Neil (nialloceallaigh) said :
#2

Thanks Bastian, that solved my question.

Revision history for this message
Neil (nialloceallaigh) said :
#3

Great stuff. Thanks very much Bastian, that update works exactly as you have described - when you don't want to have a CLASSPATH env variable (I will try the other two methods as well though and let you know if they work).