TWiki . Catch0405 . StoreModule
|
*
* Created on Dec 13, 2004
*
* TODO To change the template for this generated file go to
* Window - Preferences - 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(User1.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
User1 newUser1 = new User1();
//newUser1.setID("dr");
newUser1.setName(s[0]);
newUser1.setSex(s[1]);
newUser1.setBirth(s[2]);
newUser1.setDeath(s[3]);
session.save(newUser1);
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 - 14 Dec 2004
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.