You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Patrick PC Yu <pc...@popular.com.hk> on 2001/10/10 02:24:14 UTC

Qs 'bout javax.transaction.* implementation in Tomcat

Hi,

I'm new to tomcat.  Has Tomcat implemented the javax.transaction package?

Currenly I'm working on this case:

Suppose an object "Company"  has-a "Office" object.  And they both have a
method ".insert()".  The pattern is like this:

public void insert() throws SQLException {

   getConnection....
   executeQuery...
   connection.close()

}

So, when i insert a new company with an office in JSP....

company.insert();
office.insert();


In the jsp, i need to check:  if failed to insert "office", i have to
rollback also "company".  So, I suppose I need sth like this:

transaction.begin();
company.insert();

try {
        office.insert();
        transaction.commit();
} catch (Exception e) {
        transaction.rollback();
}

My Questions:
1)  Is my logic right?
2)  If yes, do I need that transaction stuff (IF I DON'T want to keep the
connection in the jsp's)?
3)  How to use the javax.transaction.*[.*.* ...] in tomcat?  (e.g. how to
get an implemented transaction?)

Thx very much for ur kind advice!


Regards,
Patrick
Thx a lot!

Regards,
Patrick PC Yu