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
, AndsetAsciiStream
MethodsPreparedStatement
Are extended to enhance the ability to workBLOB
,CLOB
, AndNCLOB
Target columns.
...
TheSetBigStringTryClob
Connection 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.