• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Load Data into database using Hibernate

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I want to upload data from a text file into mysql database. I have tried this in mysql as a script it works fine. But it doesn't work with Hibernate.
Please help me in this regard.





It doesn't shows any errors or exceptions. My text file contains the following data


Swathi,89.9,2012-03-16
 
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's unlikely that Hibernate will recognize and execute that database command for you.
Why do you want to use hibernate for this when you can already load the data using the more efficient database command?
One reason why you don't see any errors could be because you have empty catch blocks in your code that you have not posted as part of the code you posted here.
 
Aiswarya Geidth
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to load a data file into data base using Hibernate. Is that Load query work in hibernate or any other query for this .


Thanks in advance
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again, why do you want to use Hibernate to do this when you can let the DB do it?
Hibernate is a tool for mapping java objects to database tables.
 
Aiswarya Geidth
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I want this in my application. Is this can be done by hibernate or not.

Could you please help me.






Thanks
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would have to do bulk inserts as a batch http://docs.jboss.org/hibernate/core/3.3/reference/en/html/batch.html
Also have a look at this blog post as well:http://sensiblerationalization.blogspot.com/2011/03/quick-tip-on-hibernate-batch-operation.html
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Aiswarya Geidth wrote:...It doesn't shows any errors or exceptions...


Try catching the exceptions and printing them.

And as already suggested It's really not a good usage as you have a simple way to load data to the DB by the vendor provided mechanism.
 
reply
    Bookmark Topic Watch Topic
  • New Topic