0

I am trying to import data from a a local derby database into python using the jaydebeapi. I am running python 3.6 from PyCharmCE:

import jaydebeapi as jdbc

conn = jdbc.connect("org.apache.derby.jdbc.ClientDriver", "jdbc:derby://address:port/db_name", ["user", "pwd"], "path/to/derbyclient-10.14.2.jar")
curs = conn.cursor()

curs.execute("select ITEM from TABLENAME")
rec = curs.fetchone()[0]

curs.execute("select BLOB from TABLENAME")
rec = curs.fetchone()[0]

curs.close()
conn.close()

While everythong goes well for the first query, i am having troubles with the data blob. I receive the following runtime error:

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

The blob data size is approx. 200kB. At runtime the rec variable is of type org.apache.derby.client.am.ClientBlob - found that a bit puzzling ...no idea if it contributes to the solution.

Thx in advance for any hints!

gemixl
  • 3
  • 4
  • Can you gather more information? Does your python interface produce any log files? Class `org.apache.derby.client.am.ClientBlob` is an appropriate class to be used in the client code when retrieving a data blob, so you'll need to try to look deeper to figure out the actual problem. The Derby code will throw a SQLException if it has a problem; can you figure out where that exception is caught and print it out? – Bryan Pendleton Jun 14 '20 at 15:56
  • Thanks @BryanPendleton: I tried to find out more about the terminating error. I think I can factorize the problem now. The error code seems to be related to my IDE. The code terminates fine, if I run it inside the shell. There remains the problem, that I am clueless what to do with the `org.apache.derby.client.am.ClientBlob` object. I try to extract the data, but I failed to turn it into a stream or anything alike. How can I cast it in a way that python will give me access to the data? – gemixl Jun 15 '20 at 20:13
  • You shouldn't need to cast it. The Derby `ClientBlob` implements the Java SQL Blob interface https://docs.oracle.com/javase/7/docs/api/java/sql/Blob.html It's a standard part of the Java JDBC API. So you simply invoke the Blob Interface's methods on it. – Bryan Pendleton Jun 17 '20 at 15:50

1 Answers1

0

This seems to be an issue of JPype 0.7.5 (and maybe before). This might be fixed in the upcoming 0.7.6.

Also it might be worth trying the JayDeBeApi 1.2.3 if you haven't done so yet.

bastian
  • 1,122
  • 11
  • 23