• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Saving Japanese Characters in Oracle Blob using Java program

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Every time you till, you lose 30% of your organic matter. But this tiny ad is durable:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic