Subject Problem While Reading BLOB OBJECT-Jaybird Driver - binary to char conversion.
Author cistechselvin <cistechselvin@yahoo.com>
I am trying to read the Blob fields from Firebird database and i
received the data only in the form of binary. Now i want to read and
convert them in to character to compare the string as a search. Can
any one give me the idea hot can I approach?

My Environment:

Win 98–java–Firebird on FreeBSD.

The issues are.

1)I did not open up the stream since the file is too small.
2)I tried to open up the connection with FBDriver.connect() method.
By setting the properties (user,password).

public String query="Select BLOB_OBJECT from BLOB_MASTER where
blob_type='txt' and FILE_NAME='"+filename+"'";
float flo_test3;
Blob b_lob;
byte [] returndata =null;
byte bindata[]= new byte [1024];
int bytesread =0;
Properties info = new Properties();

public void method(){

try{

System.out.println("Testing Firebird - Java Applications ");
System.out.println();
Class.forName("org.firebirdsql.jdbc.FBDriver");
info.load(new FileInputStream("mypro.txt"));
String
url="jdbc:firebirdsql:host/3050:/usr/firbird/Sample.gdb";
fb = new FBDriver();
connection = fb.connect(url,info);
System.out.println("Connection Established ");
System.out.println();
stmt=connection.createStatement();
System.out.println("Statement Object Created ");
System.out.println();
result=stmt.executeQuery(query);
resm =result.getMetaData();
String columntype = resm.getColumnClassName(1);
System.out.println("column type"+ columntype);
byte [] allintobyte= new byte[1];
while(result.next()){
b_lob=result.getBlob(1);
System.out.println("Blob length"+b_lob.length());
allintobyte =b_lob.getBytes(1,(int) b_lob.length());
}
System.out.println("**"+allintobyte.length);
String test = new String(allintobyte,0,allintobyte.length);
// output in binary format.
System.out.println(test);
}catch( ClassNotFoundException cln){
System.out.println("Error code 2 "+ cln);
}catch( Exception sqle){
System.out.println("Error code 3"+sqle.toString());
sqle.printStackTrace();
}finally{
try{
result.close();
stmt.close();
connection.close();
}catch(Exception e){
System.out.println("Error Code 4 "+ e.toString());
e.printStackTrace();
}
}

}

Give me your valuable suggestion to read the blob files and do
compare the String.

Thanks in advance.