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).
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.
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 ?
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