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
This week's giveaway is in the
Spring
forum.
We're giving away four copies of
Microservices Testing (Live Project)
and have Chris Love & Andres Sacco on-line!
See
this thread
for details.
Win a copy of
Microservices Testing (Live Project)
this week in the
Spring
forum!
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
Tim Cooke
Ron McLeod
Jeanne Boyarsky
Paul Clapham
Sheriffs:
Liutauras Vilda
Henry Wong
Devaka Cooray
Saloon Keepers:
Tim Moores
Stephan van Hulst
Tim Holloway
Al Hobbs
Carey Brown
Bartenders:
Piet Souris
Mikalai Zaikin
Himai Minh
Forum:
Object Relational Mapping
Hibernate insert problem
muntago Richard
Ranch Hand
Posts: 82
posted 9 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 9 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...