Hi All,
I'm trying to transfer a pdf file from Java to Oracle to store into a table which has a data type of BLOB.
so, In order to transfer I have converted the data
to byte array so that it will be passed as BLOB. I debug and debug through Netbeans not getting any clue to resolve my error.
The error message is ERROR : java.sql.SQLException: ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at line 1. The data type that will be mapped is BLOB data type.
I have confirmed with other items that passed to the oracle procedure any they are fine with their data types.. Why becuase
only I try transfer a file getting this error if not then I'm not getting any error.
Could some one give some ideas how can I go on from here ?
Thanks
if (hasImage(block.getData(DOC_FILENAME_FD))) {
try {
File file1 = new File(block.getData(DOC_FILENAME_FD));
InputStream inputStream = new FileInputStream(file1);
//byte[] docBlob = null;
docBlob = readFully(inputStream);
}
catch(FileNotFoundException e){
}
catch(IOException e1){
}
Funciton to read the PDF and convert to byte array.
public byte[] readFully(InputStream stream) throws IOException {
byte[] buffer = new byte[1024];
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int bytesRead;
while ((bytesRead = stream.read(buffer)) != -1) {
baos.write(buffer, 0, bytesRead);
}
return baos.toByteArray();
}