Programming experience ---- clever solution to Oracle NClob read and write problems, experience bit by bit nclob

Source: Internet
Author: User
Tags sql client

Programming experience ---- clever solution to Oracle NClob read and write problems, experience bit by bit nclob

In a recent new project, we tried to use NCLOB in the Oracle database to save large xml strings.

In the Automatic Code Generation Tool (through the JDBC driver, read the database table structure and automatically generate the corresponding java code, including adding, deleting, modifying, querying by PAGE, searching by primary key and other foreground html/js and background code java), map NCLOB fields to the String type.

Run the code and no error is reported. Use the SQuirreL SQL client to view the data and detect that the data is not saved successfully.

I searched the internet and mentioned the additional attributes of using SetBigStringTryClob to connect to the database. I always feel silly. It is also stupid to use the setStringForClob method.

 

Finally, on the Oracle official website, find a better solution:

Upgrade the Oracle JDBC driver and use the java JDBC standard setString function!

 

URL:

Http://docs.oracle.com/cd/E11882_01/java.112/e16548/oralob.htm#JJDBC28534

It mentioned:

In Oracle Database 11g release 2 (11.2),setBytes,setBinaryStream,setString,setCharacterStream, AndsetAsciiStreamMethodsPreparedStatementAre extended to enhance the ability to workBLOB,CLOB, AndNCLOBTarget columns.

...

TheSetBigStringTryClobConnection property of Oracle Database 10g Release 1 (10.1) is no longer used or needed.

 

...

----------------------------

Indicate the source for forwarding. Watch out for me to touch your stomach at night. I'm jacklondon, at, cnblogs.com.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.