This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
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.
 
 
subject: Saving Japanese Characters in Oracle Blob using Java program
 
Similar Threads
Blob Clob
storing and retrieving file in JSP?
Please help me complete steps to upload an image
Urgent..Pls.. Problem storing BLOB in Oracle
Problem in uploading big images