cur.fetch issues with type conversion

Asked by Aaron Walters

I have the following connecting to Oracle 11G

import jpype
jar = r'/Users/e13188/ojdbc5.jar'
args='-Djava.class.path=%s' % jar
jvm_path = jpype.getDefaultJVMPath()
jpype.startJVM(jvm_path, args)

import jaydebeapi
conn = jaydebeapi.connect('oracle.jdbc.driver.OracleDriver', 'jdbc:oracle:thin:USER/PASS@SOMEIP/P.WORLD')

cur.curs = conn.cursor()
curs.execute("select * from DTCC_SDR_RTDD_COMM_NON_OPT")

When i do the following i get a good response with the headers of the data table.
curs.description

When i do a
curs.fetchall() (or any of the fetch methods) i get the following error. Mostly a newbie on this but it seems like it doesn't like the date time field from the database. If i select specific fields, i don't get this error. I can't tell what column is problematic either.

---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-3-4366280b3755> in <module>()
      1 curs = conn.cursor()
      2 curs.execute("select * from DTCC_SDR_RTDD_COMM_NON_OPT")
----> 3 curs.fetchone()
      4 #curs.description

/Users/e13188/anaconda/lib/python2.7/site-packages/jaydebeapi/dbapi2.pyc in fetchone(self)
    298 converter = _converters.get(sqltype)
    299 if converter:
--> 300 v = converter(v)
    301 row.append(v)
    302 return tuple(row)

/Users/e13188/anaconda/lib/python2.7/site-packages/jaydebeapi/dbapi2.pyc in _to_datetime(java_val)
    344 d = datetime.datetime.strptime(str(java_val)[:19], "%Y-%m-%d %H:%M:%S")
    345 if not isinstance(java_val, basestring):
--> 346 d = d.replace(microsecond=int(str(java_val.getNanos())[:6]))
    347 return str(d)
    348 # return str(java_val)

RuntimeError: No matching overloads found. at src/native/common/jp_method.cpp:121

Question information

Language:
English Edit question
Status:
Answered
For:
JayDeBeApi Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Bastian (baztian) said :
#2

Sorry for the late reply:
Can you please try the jpype version from https://github.com/originell/jpype You need a version that includes
https://github.com/originell/jpype/commit/6ba930287e924fbf3f43b8fdfbc47025e8d0c8a1
This is not yet released but included in the master branch. Please report if it works for you. Also ask if you need further help installing jpype.

BTW: A more recent version of JayDeBeApi is out as well which makes setup of the jdbc connection less pain (especially the classpath setup is much easier - see the docs).

Revision history for this message
Bastian (baztian) said :
#3

See my comment.

Revision history for this message
Paula Grangeiro (pgrangeiro-dev) said :
#4

Hi, Bastian.

I've had the same issue and your solution worked to me.

Thanks!

Can you help with this problem?

Provide an answer of your own, or ask Aaron Walters for more information if necessary.

To post a message you must log in.