ResultSet returning SQL null

Hola,

I'm having an issue retrieving byte info from a DB2 database using Java.

The table I am retrieving from contains a blob field that I have inserted data into but now when I attempt to retrieve the bytes in this field all i get is 'null' (as in the string).

Having checked the ResultSet API this is returned when the value in the cursor is SQL null but there IS byte info in the field (running the query on the db directly returns a list of bytes).

I've tried varying ways of retrieving the info (getBytes(), getBinaryStream(), getBlob() ), but I get 'null' each time.

Heres a code snippet:

ArrayList mediaDetails =new ArrayList();

String queryString ="select * from media where " + lookupType +" = " + lookupValue;

if (condition !=null){

queryString += condition;

}

Statement stmt =null;

ResultSet rs =null;

try{

stmt = getMainConnect().createStatement();

rs = stmt.executeQuery(queryString);

if (rs.next()){

mediaDetails.add( rs.getString("id") !=null ? rs.getString("id") :"-");

mediaDetails.add( rs.getBytes("filedata") !=null ? rs.getBytes("filedata") :newbyte[0] );// add empty byte array if no data found

mediaDetails.add( rs.getString("filename") !=null ? rs.getString("filename") :"-" );

mediaDetails.add( rs.getString("filetype") !=null ? rs.getString("filetype") :"-" );

mediaDetails.add( rs.getString("description") !=null ? rs.getString("description") :"-" );

mediaDetails.add( rs.getString("application") !=null ? rs.getString("application") :"-" );

mediaDetails.add( rs.getString("clientid") !=null ? rs.getString("clientid") :"-" );

}

}

All the other values in the array list are as expected.

The annoying thing is that this worked fine to begin with, but now I can't retrieve the bytes.

Does anyone have any insight into this?

Thanks

[3231 byte] By [mwl@javaa] at [2007-11-27 1:36:21]
# 1
This is how I get a blob out of a DB2 database:Blob blob = rs.getBlob("PICTURE");byte[] bytes = blob.getBytes(1, (int)blob.length());
Xanxana at 2007-7-12 0:45:44 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...