TWiki . Catch0405 . StoreData

/*
 * Created on Dec 28, 2004
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

/**
 * @author t100671
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.Transaction;
import net.sf.hibernate.cfg.Configuration;

/*
 * Created on Dec 13, 2004
 *
 * TODO To change the template for this generated file go to
 * Window - Prefere nces - Java - Code Style - Code Templates
 */

/**
 * @author denis
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class StoreData {
   String store(String [] s) {

      try {

         //Create the SessionFactory
         Configuration cfg = new Configuration().addClass(StoreTupel.class);
         SessionFactory factory = cfg.buildSessionFactory();
         //Create the Session
         Session session = factory.openSession();
         //Create the Transaction               
         Transaction tx = session.beginTransaction();

         //Create new User and store them the database
         StoreTupel storeTupel = new StoreTupel();        
         //storeTupel.setPrimaryKey(s[])
         storeTupel.setHaustyp(s[0]);
         storeTupel.setAnzahl(s[1]);
         storeTupel.setName(s[2]);
         storeTupel.setNname(s[3]);
         storeTupel.setBreite(s[4]);
         storeTupel.setTiefe(s[5]);
         storeTupel.setFläche(s[6]);
         storeTupel.setr(s[7]);
         storeTupel.setg(s[8]);
         storeTupel.setb(s[9]);
         storeTupel.setstrasse(s[10]);
         storeTupel.setwasser(s[11]);
         storeTupel.setgruen(s[12]);
         storeTupel.setnix(s[13]);
          
         session.save(storeTupel);
         tx.commit();

         // close our session and release resources
         session.flush();
         session.close();
                  
      } catch (HibernateException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
      String returnString = "store successfully completed";
      return (returnString);
   }
}


-- OtherDenisRaschpichler - 30 Dec 2004

----- Revision r1.1 - 30 Dec 2004 - 11:16 - OtherDenisRaschpichler
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.

This website has been archived and is no longer maintained.