Filling combobox from database by using hibernate in Java

Posted by denny on Stack Overflow See other posts from Stack Overflow or by denny
Published on 2010-03-27T22:36:28Z Indexed on 2010/03/27 22:43 UTC
Read the original article Hit count: 358

Filed under:
|
|
|

Heyy;

I am developing a small swing based application with hibernate in java. And I want fill combobox from database coloumn.How i can do that ? And I don't know in where(under initComponents, buttonActionPerformd) i need to do.

For saving i'am using jbutton and it's code is here :

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

 int idd=Integer.parseInt(jTextField1.getText());

 String name=jTextField2.getText();

 String description=jTextField3.getText();

 Session session = null;

 SessionFactory sessionFactory = new Configuration().configure()
    .buildSessionFactory();

 session = sessionFactory.openSession();

 Transaction transaction = session.getTransaction();

   try {


       ContactGroup con = new ContactGroup();

       con.setId(idd);

       con.setGroupName(name);
       con.setGroupDescription(description);



       transaction.begin(); 
       session.save(con); 
       transaction.commit(); 


      } catch (Exception e) {
       e.printStackTrace();
      }

      finally{
       session.close(); 
      }    

}

© Stack Overflow or respective owner

Related posts about java

Related posts about hibernate