How to insert data from textfields into database using hibernate?

How to insert data from textfields into database using hibernate?

try{ Session session = HibernateUtil.getSessionFactory().openSession(); org.hibernate.Transaction tx = session.beginTransaction(); Produs produs = new Produs(); produs.setIdprodus("IdProdusTextField"); produs.setFurnizor("IdFurnTextField"); produs.setCategorie(IdCatTextField); produs.setRaft(IdRaftTextField); produs.setDenumire(DenumireTextField); produs.setCantitate(IdCantitateTextField); produs.setUnitMas(UnitMasTextField);

    session.save(produs);
    System.out.println("Successfully data insert in database");
    tx.commit();

}

This method doesn't work. I tried with quotes for textfields, without them. The setters require other parameters, not textfields. I tried to cast them, but it doesn't work either.

Maybe you can help me. Thanks!

View Answers









Related Tutorials/Questions & Answers:
How to insert data from textfields into database using hibernate?
how to insert data from database using oops concepts - Development process
Advertisements
how to insert data into database using jsp & retrive
how to insert data in database using html+jsp
how to read data from excel file through browse and insert into oracle database using jsp or oracle???
How to insert image in sql database from user using servlet
How to insert data from a combobox and textbox values into DB using JSP?
insert data in the database using checkbox
Insert image from user using and save in database
How to Retrieve Data from the database and write into excel file using Java
How to insert multiple drop down list data in single column in sql database using servlet
How to get the data from the database using Servlet or JSP program
How to get data from Oracle database using JSP
Insert data in Excel File from Database using JSP
using ajax i want to insert data into oracle database
how to insert data from netbeans into databse
i need program to insert data in database using javascript
how to retrieve data from database ?????/
how to retrieve data from database ?????/
how to retrieve data from database ?????/
how to retrieve data from database ?????/
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database
how to fetch data from mysql database table and draw a bar chart on that data using in jsp
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp
Insert excel file data into database Using Java Programming
place data in text fields from database using jdbc
How to insert rows from Excel spreadsheet into database by browsing the excel file?
insert and delete data in database
how to insert, retrieve data from,to db(code)....
how to insert data into databasse by using jdbc
how to insert data into databasse by using jdbc
how to insert data into databasse by using jdbc
how to insert data into databasse by using jdbc
How to export data from database to excel sheet by using java in standalone project
how to insert, retrieve data from,to db(code)....
retrieve data from database using jsf
Insert data in mysql database through jsp using prepared statement
how to make a radiobutton selected when retrieving data from database using struts framework and spring jdbc
insert data into database
Populate a combo box using data from a database
how to insert and retrieve an image from mysql using java - Java Beginners
Problem insert data into database using servlet n javabean - Java Beginners
how to display data from database in jsp
How to insert dynamic textbox values into database using Java?
database is connected but not insert the data
retrive data from database using jsp in struts?
Insert file data into database

Ads