O'Reilly logo

Java Programming with Oracle JDBC by Donald Bales

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CLOBs

For the most part, a CLOB behaves just like a BLOB, except it exists specifically for storing character data and is subject to National Language Support (NLS) character conversion. Whereas an oracle.sql.BLOB object has methods for handling binary data, an oracle.sql.CLOB object has methods for reading and writing both ASCII and Unicode (character) data. If you use the ASCII methods -- getAsciiStream( ) , setAsciiStream( ) , and getAsciiOutputStream( ) -- the driver translates the client character set of ASCII to and from the database’s character set. If you use the character methods -- getCharacterStream( ) , setCharacterStream( ) , getCharacterOutputStream( ) , and putChars( ) -- the driver translates the client character set of Unicode to the database’s character set. The database will handle the data as ASCII if the database character set is ASCII; otherwise, the database will perform NLS character set translations to maintain the Unicode characters if the database uses, for example, the UTF-8 character set.

You can just as easily store text in a BLOB, so why should you use a CLOB instead of a BLOB? The most compelling reason to use a CLOB is its NLS abilities, that is, its abilities to handle NLS character set conversions. And to access these, you need a database that uses a UTF-8 character set, and you need to use the character methods. The only advantage to using the ASCII methods is that they are more efficient. However, if you code your applications with the character ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required