C
chomiq
How to put blob ( > 4k ) into Oracle9 using Hiberanete?
I got problem with inserting BLOB > 4k into Oracle database.
Example from http://www.hibernate.org/56.html do not works.
I use Tomcata5.5, Hibernate2.1.7, Oracle9, Java 1.5.
This line in my code:
( (oracle.sql.BLOB)atta.getData() ).putBytes(0,temp);
throws ClassCastException , why??
Is any other way to insert Blob into Oracle?
Do I have to use some other driver then oracle.thin ?
My context.xml looks like:
<Resource
name="jdbc/test"
auth="Container"
type="javax.sql.DataSource"
username="migration"
password="***"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc
racle:thin
123.123.123.123:2222:TEST"
maxActive="100"
maxIdle="10"
maxWait="3000"
/>
Code is:
session = HibetnateUtil.currentSession();
tx = sessison.beginTransaction();
....
atta.setData( Hibernate.createBlob("temporary".getBytes()) );
session.save(atta);
session.flush();
byte[] temp = atta.getBytes();
session.refresh( atta, LockMode.UPGRADE );
( (oracle.sql.BLOB)atta.getData() ).putBytes(0,temp);
tx.commit();
session.flush();
I got problem with inserting BLOB > 4k into Oracle database.
Example from http://www.hibernate.org/56.html do not works.
I use Tomcata5.5, Hibernate2.1.7, Oracle9, Java 1.5.
This line in my code:
( (oracle.sql.BLOB)atta.getData() ).putBytes(0,temp);
throws ClassCastException , why??
Is any other way to insert Blob into Oracle?
Do I have to use some other driver then oracle.thin ?
My context.xml looks like:
<Resource
name="jdbc/test"
auth="Container"
type="javax.sql.DataSource"
username="migration"
password="***"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc
maxActive="100"
maxIdle="10"
maxWait="3000"
/>
Code is:
session = HibetnateUtil.currentSession();
tx = sessison.beginTransaction();
....
atta.setData( Hibernate.createBlob("temporary".getBytes()) );
session.save(atta);
session.flush();
byte[] temp = atta.getBytes();
session.refresh( atta, LockMode.UPGRADE );
( (oracle.sql.BLOB)atta.getData() ).putBytes(0,temp);
tx.commit();
session.flush();