• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Load Data into database using Hibernate

 
Aiswarya Geidth
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic