every connection to a DB *may* be enlisted in a transaction. for this the
db/db driver MUST provide a JTA implementation
connections should be enroled to a transaction by means of their DataSource,
which is implemented by the ejb server.
No need to pool connections there, specially since JDBC 2.0 drivers *must*
pool connections.
So, per the spec(I can't make guarantees for every server vendor),
connection pooling is not needed to provide
full BMP transactional support
HTH
JP
-----Original Message-----
From: BELOUALI Amine [mailto:[EMAIL PROTECTED]]
Sent: Jueves, 11 de Enero de 2001 14:16
To: [EMAIL PROTECTED]
Subject: Re: Transactions, Connection Pooling and legacy databases
> JDBC supports transactions in the same way, more or less, as the
> applications server:
> Connection conn = getConnection(); // begin an new transaction..
> conn.setAutoCommit(false); // no automatic commit
> <snip>
> conn.commit(); // transaction is commited, and a new
> transaction is begun
> <snip>
> smt2.execute(q1);
> int i = smt.executeUpdate(query);
> if (i < 5) conn.rollback(); // transaction is being rolled back.
>
> if autocommit is true, all sql statements are executed as single
> transaction. (This is the default). Otherwise transactions are
> demarcated by commit() and rollback().
>
sorry Sven if my first post was ambiguous.
What you say is correct in the case we execute 2 or more statements under
the SAME CONNECTION. I mean something like this :
myEjb.businessMethod {
...
Connection conn = getConnection(); // begin an new transaction..
conn.setAutoCommit(false); // no automatic commit
conn.execute(q1);
conn.execute(q2);
conn.execute(q3);
conn.close();
...
}
if there are system exception in one of the execute calls, than the App
Server roll back the whole transaction.
In this case whe need only a JDBC with commit and rollback features.
Now suppose myEjb.businessMethod call 2 ore 3 BMPs as follows :
myEjb.businessMethod {
...
B1.query();
B2.query();
B3.query();
...
}
and in each BMP i have something like this :
B1.query() {
...
Connection conn = getConnection(); // begin an new transaction..
conn.setAutoCommit(false); // no automatic commit
conn.execute(q);
conn.close(); // HERE IS THE PROBLEM I SUPPOSE,
// even we set Autocommit to false,
// WHEN WE CLOSE THE CONNECTION EVERYTHING RELATED TO THIS CONNECTION IS
COMMITED
...
}
you can see that if the second BMP fails to execute its query for example,
the first one (wich have previously excuted conn.close) can't rollback their
own..
Now, what happens with Connection Pooling? Simply, when you do
conn.close().. the App Server give back the connection to the pool and don't
close it realy. I suppose that it maintains some local transaction log or
some CONNEXIONID to communicate with database.
Realy, i have no idea why App Servers don't support Connection Polling to
all databases? (at less its the case of Websphere wich supports CP to
Sybase, DB2 and Oracle)
I have also no idea how can i manage transactions in the case i have other
databases ?
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".