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

