Results 1 to 7 of 7
Thread: data not inserted in tables
- 09-30-2011, 11:44 AM #1
Member
- Join Date
- Jul 2011
- Posts
- 26
- Rep Power
- 0
data not inserted in tables
hi,
I m new to using hibernate...
this is the code i have written in servlet
SessionFactory factory=new Configuration().configure().buildSessionFactory();
Session ss=factory.openSession();
Transaction tx=ss.beginTransaction();
Userlogin userlogin=new Userlogin(username,password,"","","","","","",0);
Userinfo userinfo=new Userinfo(email,userlogin,firstname,lastname,gender ,dob,occupation,registrationDate,registrationTime, registrationIp,0,0.0,0,0);
ss.save(userlogin);
ss.save(userinfo);
tx.commit();
if(tx.wasCommitted())
{
session.setAttribute("username",username);
response.sendRedirect("home.jsp");
}
else
{
tx.rollback();
response.sendRedirect("register.jsp");
}
ss.close();
using this code, the data is not inserted in the two tables.
plz help...
thank u
- 09-30-2011, 12:07 PM #2
Member
- Join Date
- May 2011
- Posts
- 27
- Rep Power
- 0
Re: data not inserted in tables
Above code is correctly but, were you configured your hibernate.cfg.xml file. it should be in the default folder
- 09-30-2011, 01:43 PM #3
Member
- Join Date
- Jul 2011
- Posts
- 26
- Rep Power
- 0
Re: data not inserted in tables
i have used netbeans, it must be correct..........
- 09-30-2011, 02:23 PM #4
Member
- Join Date
- Jul 2011
- Posts
- 26
- Rep Power
- 0
Re: data not inserted in tables
it is giving the following exception
org.hibernate.exception.DataException: Could not execute JDBC batch update
plz help
thank u
- 09-30-2011, 02:30 PM #5
Member
- Join Date
- May 2011
- Posts
- 27
- Rep Power
- 0
Re: data not inserted in tables
do you add the jdbc jar file and can you print the hibernate.cfg.xml file
- 09-30-2011, 02:36 PM #6
Member
- Join Date
- Jul 2011
- Posts
- 26
- Rep Power
- 0
Re: data not inserted in tables
yes the jar file is added in the library.
If I remove the line ss.save(userinfo), it is able to insert data in userlogin table.....
but i want data to be inserted in both the tables...
what to do...???
:(
- 09-30-2011, 03:02 PM #7
Member
- Join Date
- May 2011
- Posts
- 27
- Rep Power
- 0
Re: data not inserted in tables
In hibernate,
Userlogin userlogin=new Userlogin(username,password,"","","","","","",0);
Userinfo userinfo=new Userinfo(email,userlogin,firstname,lastname,gender ,dob,occupation,registrationDate,registrationTime, registrationIp,0,0.0,0,0);
//ss.save(userlogin);
ss.save(userinfo);
it will automatically take data abd store in db. that is one of the adv in hibernate.
In userinfo obj you storing the userlogin obj details.
if any prb plz print the hibernate.cfg.xml file their you should specify the relation ship
Similar Threads
-
Data not inserted into an object
By LoViNgHeArTy in forum New To JavaReplies: 11Last Post: 06-28-2011, 05:51 AM -
how to format data tables
By tlyn in forum New To JavaReplies: 2Last Post: 04-19-2011, 07:11 PM -
how to get data from more than two tables based on other
By kishan.java in forum New To JavaReplies: 1Last Post: 03-24-2011, 12:20 PM -
Implementation of Big Dictionary without using data storage in tables
By sanver99 in forum New To JavaReplies: 1Last Post: 01-31-2011, 02:38 AM -
How to use one form to submit data to 2 tables on mysql
By kwesiaryee in forum New To JavaReplies: 2Last Post: 10-10-2008, 01:41 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks