aspose file tools
The moose likes JDBC and the fly likes Saving Japanese Characters in Oracle Blob using Java program Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Saving Japanese Characters in Oracle Blob using Java program" Watch "Saving Japanese Characters in Oracle Blob using Java program" New topic
Author

Saving Japanese Characters in Oracle Blob using Java program

Baski Shanmugam
Greenhorn

Joined: Feb 06, 2007
Posts: 1
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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Saving Japanese Characters in Oracle Blob using Java program
 
Similar Threads
Blob Clob
Urgent..Pls.. Problem storing BLOB in Oracle
storing and retrieving file in JSP?
Please help me complete steps to upload an image
Problem in uploading big images