We are retrieving data from an oracle database using Jython and JDBC but a BLOB field isn't returning the blob data. Instead of the actual blob data, we are seeing fields that look like this:
oracle.sql.BLOB@10e8881
If we do the same query in Razor SQL using a JDBC connection, we can see the blobs in the result text and they look fine. (We do not see the "oracle.sql.Blob" in the fields at all.)
This is the Python code and the SQL doing the query:
cur = connect_to_database()
query = "SELECT * FROM {} WHERE ROWNUM = 1".format(table_name)
cur.execute(query)
results = cur.fetchall()
print results
When we print the results, one of the columns has the value we show above. We aren't seeing the binary blob.
Here's how we are executing our Python script:
C:\jython2.7.0\bin\jython.exe C:\path_to_our_script.py
How do we get the actual binary data in the blob returned rather than the "oracle.sql.blob@" text we are seeing?
Object.toString()of Java. A blob object is just a handle to get data out of a database blob, it is not the value of the blob itself. You would need to call thejava.sql.Blobmethods to get the actual data.