-
15. Re: JBoss Transactions API 4.2.3 question
breako Nov 15, 2007 4:58 AM (in response to breako)Fair enough. I checked all local bookshops (Hoggis Figgis, Waterstones)none of them had your book. Also Amazon.co.uk (http://www.amazon.co.uk/Java-Transaction-Processing-Design-Implementation/dp/013035290X/ref=sr_1_1?ie=UTF8&s=books&qid=1195120586&sr=8-1) are out stock.
Is this book still in print?
Thanks -
16. Re: JBoss Transactions API 4.2.3 question
jhalliday Nov 15, 2007 5:00 AM (in response to breako)yup, fresh copy arrived on my desk from Amazon just a few weeks ago. It did take them a while though.
-
17. Re: JBoss Transactions API 4.2.3 question
adinn Nov 15, 2007 6:13 AM (in response to breako)
Is this book still in print?
I just clicked on the link you posted and it shows 17 vendors of new and used copies of which almost all are new. PEBKAC, perhaps? -
18. Re: JBoss Transactions API 4.2.3 question
breako Nov 15, 2007 7:48 AM (in response to breako)Yes, I have ordered a copy.
I am just looking for a simple example which uses JTA locally without no App Server and no JNDI.
Something like this:XADataSource ds = getOracleDataSource(); // call method to get DS XAConnection xaConnection = ds.getXAConnection("usr", "pswd"); Connection con = xaConnection.getConnection(); Statement stmt = con.createStatement(); javax.transaction.UserTransaction ut = UserTransaction.userTransaction(); ut.begin(); stmt.executeUpdate("insert into TAddress (C, I, CITY) " + "VALUES (20 + ", " + 15 + ", 'LONDON')"); ut.commit();
There is no API to map the transaction to the connection. My understanding is that this is no down under the hood by thread mapping.However when executeUpdate() is executed, the data is put in the database, not ut.commit().
It appears there is no connection between the userTransaction and the data operations.
Please, I know I am missing something obvious here and people are probably laughing here but I would appreciate any help at all. That book won't be here until the end of next week. I can't find any simple examples with no JNDI, and no App Server.
Cheers -
19. Re: JBoss Transactions API 4.2.3 question
breako Nov 15, 2007 10:18 AM (in response to breako)An update on this:
My understanding is now:
1. The connections have to registered with arjuna TransactionalDriver in order to make them participate with any UserTransactions
2. There appears two ways of doing this
- firstly register the datasoure with JNDI
- secondly use a dynamic class (which is no longer recommended)
So my current understanding is, it is impossible to use *local* transactions without JNDI because I see no way of registering a DataSources with the TransactionalDriver without using JNDI.
I may take this in a separate thread - if that's ok? -
20. Re: JBoss Transactions API 4.2.3 question
breako Nov 15, 2007 1:00 PM (in response to breako)Finally got this working this is what I did.
1. Configuring my application to use JNDI using the RmiRegistry. this is done by putting a jndi.properties file on my classpath and including the entries:java.naming.factory.initial com.sun.jndi.rmi.registry.RegistryContextFactory java.naming.provider.url rmi://localhost:1099
2. Update the
jbossjta-properties.xml, so that it will use the same JNDI context. I added the following:<property name="Context.java.naming.factory.initial" value="com.sun.jndi.rmi.registry.RegistryContextFactory"/> <property name="Context.java.naming.provider.url" value="rmi://localhost:1099"/>
3. In my code, create an in memory XADatasourceOracleXADataSource xaDS = new OracleXADataSource(); xaDS.setDataSourceName("Oracle"); xaDS.setURL("jdbc:oracle:thin:@XXXX:yyy:ora10g");
4.
Put this datasource in JNDIctx = new InitialContext(); ctx.bind("jdbc/foo", xaDS);
6.
Get a transaction, using the TransactionalDriver:TransactionalDriver arjunaDriver = new TransactionalDriver(); conn = arjunaDriver.connect("jdbc:arjuna:jdbc/foo", props);
7.
Begin a transaction:UserTransaction.userTransaction().begin();
8.
Do some data operations on the connectionStatement stmt = conn.createStatement(); stmt.executeUpdate("insert into TAddress (C, I, CITY) " + "VALUES (" + Address.CLASSID + ", " + 90000 + ", 'LONDON')");
This statement will not put anything in the database
9.
Commit the transactionUserTransaction.userTransaction().commit();
Now it will be in the database.
Ok, this is the simpliest example I can think of using JBoss JTA outside a AppServer.
The tricky parts are
1. You have to configure JNDI and make sure the arjuna core and your application use the same Context.
2. You have to get your connection via the TransactionalDriver
Hope this example makes sense. -
21. Re: JBoss Transactions API 4.2.3 question
marklittle Nov 16, 2007 4:43 PM (in response to breako)You don't have to use JNDI at all with the TransactionalDriver. You'd have to look through the JTA and JDBC sections of the documentatin though to see what I mean.
-
22. Re: JBoss Transactions API 4.2.3 question
breako Nov 20, 2007 8:48 AM (in response to breako)the only other mechanism is dynamic class loading which according to the programmers guide pg 31 is not recommended.
Also, in this posts you do not recommend using it:
1.
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=96210
2.
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=88103
Note - in this thread it says that support for Oracle 8 has been removed. So I can't see any other way for doing it for Oracle other than JNDI.
Regards -
23. Re: JBoss Transactions API 4.2.3 question
marklittle Nov 20, 2007 9:58 AM (in response to breako)Well the code is available, so you can always go in and update it yourself :-)