java.sql.SQLException:不允许操作:在将数据插入Oracle clob数据类型时,不能在批处理中使用streams类型

Tin*_*iny 11 spring jsp hibernate clob oracle10g

我正在使用Hibernate Tools 3.2.1.GA和Spring 3.0.2版.我想将数据插入到Oracle(10g)数据库字段中clob,如下所示.

Clob c=Hibernate.createClob(request.getParameter("someTextFieldValueOnJSPPage");
pojoObj.setSomeClobProperty(c);
Run Code Online (Sandbox Code Playgroud)

它工作得很好但是当我尝试使用CKEditor插入数据流时, 我的JSP页面上的demo(CKEditor只是呈现HTML <textarea></textarea>元素)可能涉及格式化文本以及图像,flash等,它会抛出以下异常.

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.exception.GenericJDBCException: could not update: [model.Cms#1]
Run Code Online (Sandbox Code Playgroud)
org.hibernate.exception.GenericJDBCException: could not update: [model.Cms#1]
Run Code Online (Sandbox Code Playgroud)
java.sql.SQLException: operation not allowed: streams type cannot be used in batching
Run Code Online (Sandbox Code Playgroud)

如何解决该异常?这是Oracle驱动程序问题还是其他什么问题?我正在使用ojdbc14.jar,Oracle JDBC Driver version - 9.0.2.0.0.


更新:

使用该Clob类型的实体之一是

public class Cms  implements java.io.Serializable
{
     private BigDecimal cmsId;
     private Clob aboutUs;     //I'm currently dealing with this property.
     private Clob contactUs;
     private Clob privacyPolicy;
     private Clob returnPolicy;
     private Clob shippingPolicy;
     private Clob termsOfUse;
     private Clob exchangeLinks;
     private Clob disclaimer;
     private Clob aboutProducts;
     private Clob purchasingConditions;
     private Clob faq;

    //Parameterized constructor(s) along with the default one as and when needed.

    //Getters and setters.
}
Run Code Online (Sandbox Code Playgroud)

在我的Spring控制器类中,我使用以下代码Clob在Oracle中的类型上执行插入.

Cms c=new Cms();
c.setCmsId(new BigDecimal(0));
c.setAboutUs(Hibernate.createClob(request.getParameter("txtAboutUs")));
session.save(c);
session.flush();
session.getTransaction().commit();
model.put("status", "1");
model.put("msg","Insertion done successfully.");
//setParameter(cb);
Run Code Online (Sandbox Code Playgroud)

model简直是Map model,在正式参数submit()时,一个提交按钮被调用在Spring控制器类方法是单击JSP页面上.


我在Spring控制器类中使用以下简单方法检索数据

private void getData(Map model)
{
    Session session=NewHibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();
    List<Cms>list=session.createQuery("from Cms order by cmsId desc").list();
    model.put("list", list);

    session.flush();
    session.getTransaction().commit();
}
Run Code Online (Sandbox Code Playgroud)

试图像这里提到的那样做但无济于事(我面临与该问题中指定的相同的例外).

Tin*_*iny 18

问题中提到的异常是由于旧版本的Oracle驱动程序似乎无法与Oracle clob数据类型一起使用.我在用Oracle JDBC Driver version - 9.0.2.0.0.我下载了一个新版本在这里Oracle JDBC Driver version - 10.2.0.5.0它工作得很好,我在所有的情况下应用.

在互联网上的某个地方,有人说如果CKEditor持有的数据在插入Oracle clob数据类型时被转换(编码)为base64,那么该方法将在不更新驱动程序的情况下工作(意味着旧版本的Oracle驱动程序)(显然需要在从数据库中检索数据时从base64解码).

但我确实没有付诸实践,因为我下载的驱动程序的新版本对我来说很好.所以,我不确定后来的方法,我将它留给读者.