This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Blob? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Blob?" Watch "Blob?" New topic


moh sak
Ranch Hand

Joined: May 11, 2005
Posts: 78
hi all,

i'm trying to retrive a pic from the database using the getBlob method but the following exception pops up :


at sun.jdbc.odbc.JdbcOdbcResultSet.getBlob(

and i don't know what it's mean . any way this is my code that i use to retrive the picture :

public byte[] getBlob() throws SQLException {
String SQLCommand = "SELECT user_pic FROM USERS where user_id = ? ";
Blob blob = null;
byte[] bytes = null;
PreparedStatement pstmt = dbUtil.prepareStatement(SQLCommand);
if (pstmt == null) {
throw new SQLException("Erorr In Preparing Update Statement In UsersDAO");
pstmt.setInt(1, 1010);
ResultSet rs = pstmt.executeQuery();
//ResultSetMetaData md = rs.getMetaData();
while ( {
blob = rs.getBlob(1);
bytes = blob.getBytes(1, (int) (blob.length()));
return bytes;

any one can help me ?? please i realy need help

thanx in advance.
[ June 11, 2005: Message edited by: Bear Bibeault ]
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

The error message means exactly what it says: that the getBlob() method is unsupported by your driver. You could change drivers to one which does support this method. What database are you using?

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
moh sak
Ranch Hand

Joined: May 11, 2005
Posts: 78
hi thanx for you'r replay , i'm using microsoft sql server .

is there any way to do it ? i'm using the jdbc dbc bridge !!???
It is sorta covered in the JavaRanch Style Guide.
subject: Blob?
Similar Threads
save image into database blob
Reading From a Binary Large Object(BLOB)
ClassCastException when casting my resultset to OracleResultSet
Using Clobs in SQLServer- Please help!
ERROR: java.lang.OutOfMemoryError: Java heap space