Processing of CLOB fields in Orcale, hibernate processing Clob

Source: Internet
Author: User
Tags sql error

CLOB Persistent Source in Oracle:

public void Addclob (string astable, String fieldName, String ID,
String values) throws Exception {
PrimaryKey = "ID";
String strSQL = "Select" + FieldName + "from" + astable + "WHERE"
+ PrimaryKey + "= '" + ID + "' for UPDATE";
String updatesql = "Update" + astable + "set" + FieldName
+ "=empty_clob () where" + PrimaryKey + "= '" + ID + "' and"
+ FieldName + "is null";
System.out.println ("strsql=" +strsql);
System.out.println ("updatesql=" +updatesql);
Statement PS = conn.createstatement ();
Ps.executeupdate (Updatesql);
Oracle.sql.CLOB CLOB = null;
This.conn.setAutoCommit (FALSE);
ResultSet rs = stmt.executequery (strSQL);
if (Rs.next ()) {
CLOB = (CLOB) rs.getclob (1);
Writer OutStream = Clob.getcharacteroutputstream ();
Char[] C = Values.tochararray ();
Outstream.write (c, 0, c.length);
Outstream.flush ();
Outstream.close ();
}
This.conn.commit ();
}

Then the CLOB in the Orcale is mapped to what type hiberbate the. hbm.xml file and the class in Pojo.

In my program, Pojo is a string type and. Hbm.xml corresponds to text in the database for the CLOB is a way to read on the Internet
And I run the program appears 80781 [http-8080-1] WARN util. Jdbcexceptionreporter-sql error:17090, Sqlstate:null
80781 [http-8080-1] ERROR util. Jdbcexceptionreporter-Operation not allowed: streams type cannot is used in batching
80796 [Http-8080-1] ERROR def. Abstractflushingeventlistener-could not synchronize Database
Org.hibernate.exception.GenericJDBCException:could not insert: [ Com.viceasy.wlhk.information.bean.NewsPublicNotice]

With this drive Ojdbc14.jar the CLOBL type in the database is mapped to the text type in the. hbm.xml
Pojo is string type but in. hbm.xml add a length= "100000"
It's okay.

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.