Werner,
See inline comments below.
In addition to the oracle-xa-ds.xml XA datasource posted earlier, i'll
also post my non-XA datasource xml. Again it is derived from stock JBoss
configurations from doc/examples/jca.
<datasources>
<local-tx-datasource>
<jndi-name>AT4ServerDS</jndi-name>
<connection-url>jdbc:oracle:thin:@beer:1521:orcl</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>attempt4</user-name>
<password>attempt4</password>
<!-- Uses the pingDatabase method to check a connection is still
valid before handing it out from the pool -->
<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker
<!-- Checks the Oracle error codes and messages for fatal errors -->
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
-->
<!-- sql to call on an existing pooled connection when it is
obtained from pool - the OracleValidConnectionChecker is prefered
<check-valid-connection-sql>some arbitrary
sql</check-valid-connection-sql>
-->
</local-tx-datasource>
</datasources>
On Fri, 2004-06-18 at 02:18, Werner Guttmann wrote:
> On Thu, 17 Jun 2004 21:44:48 -0600, Bruce Snyder wrote:
>
> >
> >Donnie Armstrong wrote:
> >
> >> Werner thanks for your help.
> >>
> >> My environment JBoss 3.2.3 + Oracle 10g + Oracle XA + Castor 0.9.5.3
> >>
> >> I would like the database.xml file to use the JNDI datasource instead of
> >> stand-alone JDBC connection. When I invoke
> >> qry.execute(Database.ReadOnly), I receive an exception. I am at a loss
> >> as how to tell Castor to ignore setAutoCommit() on the connection.
> >>
> >> The below code works fine if i change database.xml to use stand-alone
> >> jdbc.
> >>
> >> database.xml =>
> >> <database name="at4" engine="oracle">
> >> <jndi name="java:/AT4ServerDS" />
> >> <mapping href="conf/castor_mapping.xml" />
> >> </database>
> >>
> >> Code snippet =>
> >>
> >> try {
> >> // construct JDO adapter
> >> JDO jdo = new JDO("at4");
> >>
> >> // load database file
> >>
> >> jdo.setConfiguration(getClass().getClassLoader().getResource(dbFileName).toString());
> >>
> >> // aquire database handle
> >> Database db = jdo.getDatabase();
> >>
> >> // initialize castor transaction
> >> db.begin();
> >>
> >> // initialize query
> >> OQLQuery qry = db.getOQLQuery("SELECT p FROM
> >> com.attempt4.framework.oracle.DatasetLayoutBean p where p.dataSetName =
> >> $1");
> >>
> >> // bind parameters
> >> qry.bind(datasetName);
> >>
> >> // execute query (read-only)
> >> QueryResults results = qry.execute(Database.ReadOnly);
> >>
> >>
> >> Stack Trace =>
> >> ERROR 11:32:39,877 [STDERR] java.sql.SQLException: You cannot set
> >> autocommit during a managed transaction!
> >> ERROR 11:32:39,878 [STDERR] at
> >> org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.setJdbcAutoCommit(BaseWrapperManagedConnection.java:440)
> >> ERROR 11:32:39,878 [STDERR] at
> >> org.jboss.resource.adapter.jdbc.WrappedConnection.setAutoCommit(WrappedConnection.java:446)
> >> ERROR 11:32:39,879 [STDERR] at
> >> org.exolab.castor.jdo.engine.TransactionContextImpl.getConnection(TransactionContextImpl.java:211)
> >
> >Donnie,
> >
> >The exception above makes me think that you've got the DataSource
> >configured improperly in JBoss. Please post your *-ds.xml file so that
> >we can see how the DataSource is configured.
>
> I was just about to say the same. Above you state that you are using Oracle XA.
> Given that there is not product labeled Oracle XA, I take it that you
> want to use Castor as part of a solution where global transaction demarcation is
> used (as opposed to Castor controlling transaction demarcation).
We are using oracle 10g backend with oracle 10g jdbc drivers. Global
transaction demarcation would be preferred, but to get things moving we
can use a non-XA datasource as well. As of right now, we are using a
stand-alone database.xml until setAutoCommit() is resolved.
> As Bruce has said, it is essential to get the configuration of the JDBC DataSource
> right in this context. First of all, you'll need an instance of
> XADataSource for this to work. Second, you'll need a thorough understanding of all
> the semantic issues involved.
I used the stock *-ds.xml from Jboss to setup both an XA and non-XA
datasource. It is preferred we use the XA driver as our application may
span transaction across multiple DB. Regardless of which datasource I
use, Castor still fails with:
class org.exolab.castor.jdo.PersistenceException; REASON=Nested error:
java.sql.SQLException: You cannot set autocommit during a managed
transaction!
> Can you tell us as to why you'd want to use XA transactions (aka global
> transactions). Do you have more than one (physical) database ? Iow, what
> resources do you have to manage in such a way that you need 2PC ?
Our application will have many different simultaneous database
connections to Informix, DB2, Oracle. In general, we will gather data
from a source, combine the data from the source with data from the
master into a consolidated object. We'll need to insert the
consolidated object back to the source and into the master. We'll try
to use 2PC for inserts into two different databases under one
transaction. The work is performed using Stateless CMP Session beans.
We'll use Castor to manage the persistence of the data conversion
data/rule objects. Typically the data conversion rules are read-only
retrievals from Oracle.
>
> Regards
> Werner
>
> >
> >Bruce
> >--
> >perl -e 'print
> >unpack("u30","<0G)[EMAIL PROTECTED]&5R\\"F9E<G)E=\\$\\!F<FEI+F-O;0\\`\\`");'
> >
> >The Castor Project
> >http://www.castor.org/
> >
> >Apache Geronimo
> >http://incubator.apache.org/projects/geronimo.html
> >
> >
> >
> >-----------------------------------------------------------
> >If you wish to unsubscribe from this mailing, send mail to
> >[EMAIL PROTECTED] with a subject of:
> > unsubscribe castor-user
> >
>
>
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-user
>
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user