Announcement Announcement Module
Collapse
No announcement yet.
Using the OracleLobHandler to insert a clob Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using the OracleLobHandler to insert a clob

    I am using the OracleLobHandler provided by Spring to insert a clob into the database, but got a IOException:Connection aborted by peer: socket write error
    I am using struts1.2 hibernate 2.1.7 spring 1.1.2 oracle9.2.0.1.0 and wsad5.1
    Here is my applicationContext.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName">
    <value>java:comp/env/jdbc/sshDataSource</value>
    </property>
    </bean>
    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="dataSource">
    <ref local="dataSource"/>
    </property>
    <property name="mappingResources">
    <list>
    <value>Users.hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">
    net.sf.hibernate.dialect.Oracle9Dialect
    </prop>
    <prop key="hibernate.query.substitutions">true=1 false=0</prop>
    </props>
    </property>
    <property name="lobHandler">
    <bean class="org.springframework.jdbc.support.lob.Oracle LobHandler">
    <property name="nativeJdbcExtractor">
    <bean class="org.springframework.jdbc.support.nativejdbc .WebSphereNativeJdbcExtractor"/>
    </property>
    </bean>
    </property>
    </bean>
    <bean id="transactionManager" class="org.springframework.orm.hibernate.Hibernate TransactionManager">
    <property name="sessionFactory">
    <ref local="sessionFactory"/>
    </property>
    </bean>
    <bean id="userDAO" class="com.ssh.dao.hibernate.UserHibernateDAO">
    <property name="sessionFactory">
    <ref local="sessionFactory"/>
    </property>
    </bean>
    <bean id="userManager" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager">
    <ref local="transactionManager"/>
    </property>
    <property name="target">
    <bean class="com.ssh.service.impl.UserManagerImpl">
    <property name="userDAO">
    <ref local="userDAO"/>
    </property>
    </bean>
    </property>
    <property name="transactionAttributes">
    <props>
    <prop key="save*">PROPAGATION_REQUIRED</prop>
    <prop key="remove*">PROPAGATION_REQUIRED</prop>
    <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
    </props>
    </property>
    </bean>
    </beans>

    My struts-config.xml is:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
    "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
    <struts-config>
    <form-beans>
    <form-bean name="userForm" type="com.ssh.web.form.UserForm"/>
    </form-beans>
    <action-mappings>
    <action name="userForm" scope="request" path="/user" type="org.springframework.web.struts.DelegatingAct ionProxy" parameter="method">
    <forward name="success" path="/index.jsp"/>
    </action>
    </action-mappings>
    <message-resources parameter="ssh.resources.ApplicationResources"/>
    <plug-in className="org.springframework.web.struts.ContextL oaderPlugIn">
    <set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml,/WEB-INF/action-servlet.xml"/>
    </plug-in>
    </struts-config>

    My action-servlet.xml is:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    <bean name="/user" class="com.ssh.web.action.UserAction" singleton="false">
    <property name="userManager">
    <ref bean="userManager"/>
    </property>
    </bean>
    </beans>

    My Users.hbm.xml is:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
    <hibernate-mapping>
    <class name="com.ssh.dao.model.User" table="USERS">
    <id name="id" type="string" unsaved-value="null">
    <column name="USERID"/>
    <generator class="uuid.hex"/>
    </id>
    <property name="userName" />
    <property name="password" />
    <property name="describe" type="org.springframework.orm.hibernate.support.Cl obStringType"/>
    </class>
    </hibernate-mapping>

    My User.java is:
    public class User {
    private String id = null;
    private String userName = null;
    private String password = null;
    private String describe= null;

    // Set Get methods
    }

    Then in my UserHibernateDAO.java , I use getHibernateTemplate().saveOrUpdate(user) to store the user object into the database

    When I save the user object without set the describe property,it works very well, however, if I set the describe property(even only one character), it dosen't work, here is the exception stack:
    java.sql.SQLException:No more data to read from socket
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:134)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:179)
    at oracle.jdbc.dbaccess.DBError.check_error(DBError.j ava:1160)
    at oracle.jdbc.ttc7.MAREngine.unmarshalUB1(MAREngine. java:963)
    at oracle.jdbc.ttc7.MAREngine.unmarshalSB1(MAREngine. java:893)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:369)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol .java:1891)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TT C7Protocol.java:1093)
    at oracle.jdbc.driver.OracleStatement.executeNonQuery (OracleStatement.java:2047)
    at oracle.jdbc.driver.OracleStatement.doExecuteOther( OracleStatement.java:1940)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTi meout(OracleStatement.java:2709)
    at oracle.jdbc.driver.OraclePreparedStatement.execute Update(OraclePreparedStatement.java:589)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement. executeUpdate(WSJdbcPreparedStatement.java:555)
    at net.sf.hibernate.impl.NonBatchingBatcher.addToBatc h(NonBatchingBatcher.java:22)
    at net.sf.hibernate.persister.EntityPersister.insert( EntityPersister.java:464)
    at net.sf.hibernate.persister.EntityPersister.insert( EntityPersister.java:438)
    at net.sf.hibernate.impl.ScheduledInsertion.execute(S cheduledInsertion.java:37)
    at net.sf.hibernate.impl.SessionImpl.executeAll(Sessi onImpl.java:2438)
    at net.sf.hibernate.impl.SessionImpl.execute(SessionI mpl.java:2391)
    at net.sf.hibernate.impl.SessionImpl.flush(SessionImp l.java:2260)
    at net.sf.hibernate.transaction.JDBCTransaction.commi t(JDBCTransaction.java:61)
    at org.springframework.orm.hibernate.HibernateTransac tionManager.doCommit(HibernateTransactionManager.j ava:464)
    at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:376)
    at org.springframework.transaction.interceptor.Transa ctionAspectSupport.doCommitTransactionAfterReturni ng(TransactionAspectSupport.java:242)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:66)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :143)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:174)
    at $Proxy0.saveOrUpdateUser(Unknown Source)
    at com.ssh.web.action.UserAction.add(UserAction.java: 64)
    ......

    It will be great if someone can tell me what excatly should I do to solve the problem.
    Thanks in Advance.

  • #2
    Didn't you get a specific Oracle error number (ORA-XXXXX)?

    Comment


    • #3
      Yes, the ErrorCode is 17,410 and SQLState is <null>

      Comment


      • #4
        This is a problem related to Oracle, it has nothing to do with Spring. People have solved this problem by upgrading to the latest 9i thin drivers or upgrading to Oracle 9.2.0.4. Don't take this advise for granted, changing your driver or upgrading your database may not go without consequences! Also, applying any of these two solutions may not solve your problem at all yet may introduce a whole new set of problems. Check with your DBA.

        Comment


        • #5
          tentacle, thank you very much! I have upgraded to the latest 9i thin drivers(9.2.0.5), and solved the problem. But I don't know whether there will new set of problems be appear

          Comment


          • #6
            tentacle, thank you very much!
            No problem, you owe me a beer

            I have upgraded to the latest 9i thin drivers(9.2.0.5), and solved the problem. But I don't know whether there will new set of problems be appear
            Probably not, I just wanted you to think about what you're doing. An Oracle database has a mind of its own, changing _anything_ _can_ lead to disaster. Changing your driver may introduce other subtle bugs but if it solves your current problem that's already that.

            Comment


            • #7
              There's been recent talk about this in the Hibernate forum, too. I'll mention here what I did there: The Oracle 10 driver seems to handle CLOBs of any size correctly without custom UserTypes or special support from Spring. It works fine for Oracle 9i databases, as well. Although batching must be disabled in Hibernate.

              Comment

              Working...
              X