-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: insert a binary stream to a blob in oracle 9i
PostPosted: Fri Jan 14, 2005 1:48 pm 
Newbie

Joined: Fri Jan 14, 2005 1:07 pm
Posts: 2
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?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 14, 2005 3:04 pm 
Newbie

Joined: Fri Jan 14, 2005 1:07 pm
Posts: 2
problem is resolved. I used a bad oracle driver, I thought it was 10g but it is not.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 6:06 pm 
Newbie

Joined: Thu Mar 03, 2005 6:03 pm
Posts: 1
I am trying to do the same thing with the binary type. It saves to the db correctly (I can dump to file and see it), but when I load the blob back into the byte array it is all garbbled up. I am using the oracle 10g driver and hibernate 2.0. I tried setting the hibernate.jdbc.use_streams_for_binary to true but this didn't seem to work.

daisyflemming, could you post an example of what you did?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.