项目大体上使用spring 和 hibernate开发。annotation在配置hibernate 的时候设置了一个类的属性为@Lob,
如下:
@Lob
public String getContext() {
return context;
}
我数据库用的oracle 9i,不过我把驱动升级oracle 10G为ojdbc14.jar,听说这样可以在hibernate中用String来操作Clob类型数据。
在Spring中我有添加数据库配置信息:<prop key="hibernate.connection.SetBigStringTryClob">true</prop>
听说这样就可以用String保存大的文本字段。不用处理clob与String之间的转换。
当文本大于1000个字符的时候报错:org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)


Caused by: java.sql.BatchUpdateException: ORA-01483: DATE 或 NUMBER 赋值变量的长度无效 at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10768)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:294)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 87 more

解决方案 »

  1.   

    在数据库中,表字段Context 的类型 为 Clob。
    可能甚么地方配置有问题,请高手指教一二!
      

  2.   

    在数据库中,表字段Context 的类型 为 Clob。
    可能甚么地方配置有问题,请高手指教一二!
      

  3.   

    我也有这种问题,最近在做接口,接口与系统之间通过message进行通信,
    我是先把bean的数据转化成xml格式的字符串,然后保存到message中,但是保存的时候出现了上面的问题
    在网上查了下,有的说是驱动的问题,驱动包我也换成了最新的,但问题依旧存在!
    请各位高手指点!
      

  4.   

    我也有这问题,但奇怪地是我添加很少的数据没是(几十汉字),很多也没事(3000汉字)。如果我添加大概1500左右汉字就报上面的错误了。
    org.springframework.jdbc.UncategorizedSQLException: Hibernate flushing: Could not execute JDBC batch update; uncategorized SQLException for SQL
      

  5.   

    如果说是配置问题,应该没什么关系。因为在hbm文件type=text对应数据库CLOB类型。