Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Object Relational Mapping
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Object Relational Mapping
Hibernate insert problem
muntago Richard
Ranch Hand
Posts: 82
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
can someone tell me what is wrong with this code.
it prints "Data Inserted Successfully" but does not insert the values to database
<%! int empno;double salary;String name; Session session1 = null; %> <body> <% String num1=request.getParameter("t1"); if(num1 != null) { empno=Integer.parseInt(num1); name=request.getParameter("t2"); String sal=request.getParameter("t3"); salary=Integer.parseInt(sal); try { Configuration cf=new Configuration(); cf.configure(); SessionFactory sessionFactory = cf.buildSessionFactory(); session1 =sessionFactory.openSession(); Transaction tr = session1.beginTransaction(); Emp e=new Emp(empno,name,salary); tr.commit(); session1.save(e); session1.close(); out.println("<h1>Data Inserted Successfully</h1>"); } catch(Exception e) { System.out.println("e="+e.getMessage()); } } %> <form> <table width="352" border="1"> <tr> <th>Emp Number</th> <td><input name="t1" type="text"></td> </tr> <tr> <th> Name </th> <td><input name="t2" type="text"></td> </tr> <tr> <th>Salary </th> <td><input name="t3" type="text"></td> </tr> <tr> <th colspan="2"><input type="submit"value="Submit" > </th> </tr> </table> </form> </body> </html>
T Mishra
Ranch Hand
Posts: 108
I like...
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
save the object before committing.
session1.save(e); tr.commit();
Thanks,
Tushar (SCJP 1.5)
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Error coming 500 please an code is
jsp insert program not working
Retrive a single data from database and display that in jsp text box.
when i retrive data from access it showing empty page in tomcat
Writing data to database
More...