Insert clob data using Java + Oracle

Source: Internet
Author: User

To use Java + Oracle to insert clob data, follow these steps:
1. Insert data into the database. For the clob field, leave it empty. Example: insert into test values (1, empty_clob ())";
2. Retrieve the inserted clob field from the database and assign it to the Oracle. SQL. clob type variable. For example
String sqll = "select content from test where id = 1 for update ";
Resultset rss1_stmt.exe cutequery (sqll );
If (RSS. Next ()){
Clob = (oracleresultset) RSS). getclob (1 );
3. assign a value to the clob data and update it to the database.
For example:
Clob. putstring (1, "ddddddddddddddddddddddddddddddddddd ");
SQL = "Update test set content =? Where id = 1 ";
Preparedstatement pstmt = con. preparestatement (SQL );
Pstmt. setclob (1, clob );
Pstmt.exe cuteupdate ();

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.