I am facing problem while saving Japanese characters(高く掲げられた目標 ) as a BLOB object in Oracle using a
Java program. The problem is when i retrieve and see the data saved I am getting a junk character like "???".
My code goes like this ,
stmt = Conn.createStatement();
lobDetails = stmt.executeQuery("SELECT BLOB_Column FROM BlobTable WHERE ID = 1386421 FOR UPDATE");
if(lobDetails.next())
{
//Get the Blob locator and open output stream for the Blob
Blob objBlob = lobDetails.getBlob(1);
OutputStream blobOutputStream =((oracle.sql.BLOB)objBlob).getBinaryOutputStream();
// Open the sample file as a stream for insertion into the Blob column
InputStream sampleFileStream = new ByteArrayInputStream((new
String("Test Blob 1 2 3 �� ")).getBytes("UTF-8"));
// Buffer to hold chunks of data to being written to the Blob.
byte[] buffer = new byte[10* 1024];
// Read a chunk of data from the sample file input stream, and write the chunk to the Blob column output stream.
// Repeat till file has been fully read.
int nread = 0;
// Number of bytes read
while( (nread= sampleFileStream.read(buffer)) != -1 )
{
blobOutputStream.write(buffer, 0, nread);
}
// Close both streams
sampleFileStream.close();
blobOutputStream.close();
}
Any help would be very helpful. Thanks.