• 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 ...
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Saving Japanese Characters in Oracle Blob using Java program

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");

//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

Any help would be very helpful. Thanks.
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic