jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes Problem retrieving BLOB through resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Problem retrieving BLOB through resultset" Watch "Problem retrieving BLOB through resultset" New topic

Problem retrieving BLOB through resultset

Laryssa Fernandes

Joined: Apr 14, 2011
Posts: 5

I have a table in Oracle with BLOB data. When I try to retrieve the data using
ResultSet rs=st.executeQuery("SELECT * from NodeTable");

It gives an exception. If I put only the non BLOB column name in the SQL statement, there is no error. But if I put the BLOB column name, it gives the same error as above.
The stack trace is as below:

java.sql.SQLException: General error
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6986)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3110)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:253)
at summ.Main.main(Main.java:79)
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

That would be because the JDBC-ODBC driver doesn't support BLOB columns. But you're using an Oracle database, right? Then why not use the Oracle JDBC driver which goes with it? That driver would surely support BLOBs.
Brian Enochson

Joined: Apr 12, 2011
Posts: 14

Also retrieving a blob takes special handling. Here is some example code I have used, there are probably many examples out there if you want to Google them. And Paul is right, you want to use the Oracle JDBC Driver if your application is always going to use Oracle.

I agree. Here's the link: http://aspose.com/file-tools
subject: Problem retrieving BLOB through resultset
It's not a secret anymore!