Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2005

Tip: Looking for answers? Try searching our database.

HIBERNATE, ORACLE, BLOB > 4k

Thread view: 
chomiq - 20 Oct 2005 12:08 GMT
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:oracle: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();
Adam Maass - 21 Oct 2005 03:56 GMT
> How to put blob ( > 4k )  into Oracle9 using Hiberanete?

Please google before posting questions that have obvious answers at obvious
places.

To save you the effort:

http://www.hibernate.org/56.html

Now, a slightly longer answer:

Oracle LOBs do not behave in the way that the authors of the SQL spec or the
JDBC spec expect. Oracle, to their credit, does a decent job of documenting
what you must do to make LOBs work in Oracle. Note that you will be spinning
a lot of custom code just for Oracle to use Oracle LOB types.

-- Adam Maass


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.