2

Recently, jaydebeapi updated and i now cannot connect with my old code. https://github.com/baztian/jaydebeapi

This is the docs from the jaydebeapi source on connection:

>>> import jaydebeapi
>>> conn = jaydebeapi.connect('org.hsqldb.jdbcDriver',
...                           'jdbc:hsqldb:mem:.',
...                           ['SA', ''],
...                           '/path/to/hsqldb.jar',)
>>> curs = conn.cursor()

And this is how i am doing it:

 53     curs, conn = None, None
 54     try:
 55         thisdir = os.path.dirname(os.path.abspath(__file__))
 56 
 57         join = os.path.join
 58         conn = jaydebeapi.connect('com.teradata.jdbc.TeraDriver',
 59                                   ['jdbc:teradata://%s/CHARSET=UTF8' % system, username, password],
 60                                   jars=[join(thisdir, 'lib/tdgssconfig.jar'),
 61                                         join(thisdir, 'lib/terajdbc4.jar')])
 62 
 63 
 64         curs = conn.cursor()

Error i got:

  join(thisdir, 'lib/terajdbc4.jar')])
      File "/app/.heroku/python/lib/python2.7/site-packages/jaydebeapi/__init__.py", line 380, in connect
        jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
      File "/app/.heroku/python/lib/python2.7/site-packages/jaydebeapi/__init__.py", line 199, in _jdbc_connect_jpype
        return jpype.java.sql.DriverManager.getConnection(url, *dargs)
    RuntimeError: No matching overloads found. at native/common/jp_method.cpp:121

My code was working before but with the new updates, it stopped. Can someone show me what changes i need to make to my code?

jxn
  • 7,685
  • 28
  • 90
  • 172

1 Answers1

3
conn = jaydebeapi.connect('com.teradata.jdbc.TeraDriver',
                          'jdbc:teradata://%s/CHARSET=UTF8' % system,
                          [username, password],
                          jars=[join(thisdir, 'lib/tdgssconfig.jar'),
                                     join(thisdir, 'lib/terajdbc4.jar')])

should do the trick. With JayDeBeApi 1.0.0 you are now able to specify connection properties as a dictionary:

conn = jaydebeapi.connect('com.teradata.jdbc.TeraDriver',
                          'jdbc:teradata://%s',
                          {'user': username, 'password': password,
                           'CHARSET': 'UTF8'},
                          jars=[join(thisdir, 'lib/tdgssconfig.jar'),
                                     join(thisdir, 'lib/terajdbc4.jar')])

The changelog informs about potential incompatibilities. Parameters to the connect method have changed and should be clearer then before. The documentation is also correctly updated.

Look at

>>> help(jaydebeapi.connect)

connect(jclassname, url, driver_args=None, jars=None, libs=None)
    Open a connection to a database using a JDBC driver and return
    a Connection instance.

    jclassname: Full qualified Java class name of the JDBC driver.
    url: Database url as required by the JDBC driver.
    driver_args: Dictionary or sequence of arguments to be passed to
           the Java DriverManager.getConnection method. Usually
           sequence of username and password for the db. Alternatively
           a dictionary of connection arguments (where `user` and
           `password` would probably be included). See
           http://docs.oracle.com/javase/7/docs/api/java/sql/DriverManager.html
           for more details
    jars: Jar filename or sequence of filenames for the JDBC driver
    libs: Dll/so filenames or sequence of dlls/sos used as shared
          library by the JDBC driver
bastian
  • 1,122
  • 11
  • 23