Experience the true Struts development (Phase 2) 5

zhaozj2021-02-17  54

Try {

// ptemp = new schemaexport (cfg);

//pTemp.create (true, true);

sf = cfg.buildsessionFactory ();

S = sf.opensession ();

} catch (hibernateException e) {

E.PrintStackTrace ();

Log.Error ("Hibernate error" e);

Return;

}

Try {

LOG.INFO ("Open session OK");

Long Start = system.currenttimemillis ();

For (int i = 0; i <10; i ) {

UserInfo Message = New UserInfo ();

Message.setid (String.Valueof (i));

Message.setUsername (String.Valueof (i));

Message.SetPassword (String.Valueof (i));

Try {

S.SAVE (Message);

S.flush ();

//s.evict(MESSAGE);

} catch (hibernateException E4) {

E4.PrintStackTrace ();

Log.Error ("Hibernate Insert Error E4);

Return;

}

}

Long end = system.currenttimemillis ();

LOG.INFO (New long (end - start));

}

Catch (Exception E) {

E.PrintStackTrace ();

Log. Error ("Hibernate Insert error" E);

Return;

}

Finally {

Try {

s.close ();

} catch (hibernateException E4) {

E4.PrintStackTrace ();

Log.error ("Hibernate Close Error E4);

}

}

}

}

转载请注明原文地址:https://www.9cbs.com/read-30023.html

New Post(0)