Hi,
I am trying to insert an uploaded file (media) into a blob column in oracle and I think I hit the 4k limit.
1. I have defined media as byte[] in my POJO. I don't want to define it as java.sql.Blob (ref to
articlehttp://forum.hibernate.org/viewt ... racle+blob) 'cos my user may be using some other DB instead of oracle.
2. I set the sql-type=binary in the hbm.xml map
3. I am using the oracle 10g driver (ojdbc14.jar)
4. I set this
## use streams when writing binary types to / from JDBC
hibernate.jdbc.use_streams_for_binary true
Everything works as long as the file is below 4k. Then, I start getting this error:
encountered SQLException [No more data to read from socket];
Any suggestions is most appreciated. Thanks.
Daisy
Hibernate version:
spring.1.0.2.jar so I am guessing it is Hibernate 2.0.x
Mapping documents:
<hibernate-mapping>
<class name="org.sakaiproject.tool.assessment.data.dao.grading.MediaData" table="mediaData">
<id name="mediaId" column="mediaId" type="java.lang.Long" unsaved-value="0">
<generator class="sequence">
<param name="sequence">mediadata_mediaId</param>
</generator>
</id>
<many-to-one name="itemGradingData"
class="org.sakaiproject.tool.assessment.data.dao.grading.ItemGradingData"
column="itemGradingId" />
<property name="media">
<column name="media" not-null="false" sql-type="binary"/>
</property>
<property name="fileSize">
<column name="fileSize" not-null="false" sql-type="integer"/>
</property>
<property name="mimeType">
<column name="mimeType" not-null="false" sql-type="varchar(80)" />
</property>
<property name="description">
<column name="description" not-null="false" sql-type="varchar(4000)" />
</property>
<property name="location">
<column name="location" not-null="false" sql-type="varchar(255)" />
</property>
<property name="filename">
<column name="filename" not-null="false" sql-type="varchar(255)" />
</property>
<property name="isLink">
<column name="isLink" not-null="false" sql-type="integer" />
</property>
<property name="isHtmlInline">
<column name="isHtmlInline" not-null="false" sql-type="integer" />
</property>
<property name="status">
<column name="status" not-null="false" sql-type="integer" />
</property>
<property name="createdBy">
<column name="createdBy" not-null="false" sql-type="varchar(36)" />
</property>
<property name="createdDate">
<column name="createdDate" not-null="false" sql-type="date" />
</property>
<property name="lastModifiedBy">
<column name="lastModifiedBy" not-null="false" sql-type="varchar(36)" />
</property>
<property name="lastModifiedDate">
<column name="lastModifiedDate" not-null="false" sql-type="date" />
</property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
I use Spring to deal with it
<bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
Full stack trace of any exception that occurs:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: org.springframework.jdbc.UncategorizedSQLException: (HibernateAccessor): encountered SQLException [No more data to read from socket]; nested exception is java.sql.SQLException: No more data to read from socket
javax.faces.webapp.FacesServlet.service(FacesServlet.java:209)
org.navigoproject.ui.web.filter.SentryFilter.doFilter(SentryFilter.java:171)
org.sakaiproject.framework.config.ThreadLocalMapProviderFilter.doFilter(ThreadLocalMapProviderFilter.java:63)
org.navigoproject.ui.web.filter.Log4jMdcFilter.doFilter(Log4jMdcFilter.java:105)
org.navigoproject.ui.web.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:196)
com.corejsf.UploadFilter.doFilter(UploadFilter.java:90)
root cause
javax.faces.FacesException: org.springframework.jdbc.UncategorizedSQLException: (HibernateAccessor): encountered SQLException [No more data to read from socket]; nested exception is java.sql.SQLException: No more data to read from socket
com.corejsf.UploadRenderer.decode(UploadRenderer.java:134)
javax.faces.component.UIComponentBase.decode(UIComponentBase.java:665)
javax.faces.component.UIInput.decode(UIInput.java:464)
javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:885)
javax.faces.component.UIInput.processDecodes(UIInput.java:380)
javax.faces.component.UIForm.processDecodes(UIForm.java:144)
javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:880)
javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:306)
com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:79)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
org.navigoproject.ui.web.filter.SentryFilter.doFilter(SentryFilter.java:171)
org.sakaiproject.framework.config.ThreadLocalMapProviderFilter.doFilter(ThreadLocalMapProviderFilter.java:63)
org.navigoproject.ui.web.filter.Log4jMdcFilter.doFilter(Log4jMdcFilter.java:105)
org.navigoproject.ui.web.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:196)
com.corejsf.UploadFilter.doFilter(UploadFilter.java:90)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
Name and version of the database you are using:
oracle 9i
The generated SQL (show_sql=true):
** rendered, check file size =7707
Hibernate: select mediadata_mediaId.nextval from dual
Hibernate: insert into mediaData (itemGradingId, media, fileSize, mimeType, description, location, filename, isLink, isHtmlInline, status, createdBy, createdDate, lastModifiedBy, lastModifiedDate, mediaId) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Debug level Hibernate log excerpt:
not sure what this is?