Win a copy of Java Challengers this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

UserTransaction object in remote client

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can anyone help me out here?

I am using JBoss 4.0.1 and I've deployed a Datasource "Test" to connect to Postgres database.

This is what my java client which is running in JVM outside JBoss.

1. Lookup "UserTransaction" object in JBoss namespace.
2. Lookup "Test" datasource in JBoss namespace. (With JBoss 3.2.x it is not possible, it's possible only in JBoss 4.0.x by setting "<use-java-context>false</use-java-context>" in -ds.xml to deploy dataosure.)
3. Begin UserTransaction, Get connection object and do some database updates & either commit or rollback usertransaction.
4. But UserTransaction is not working. My database updates are always committed.
I tested the same thing in EJB deployed on the JBoss and it works fine. The only problem is when I control the user transaction from outside JBoss JVM. I get no errors/exceptions but it doesnt work.

Here is the snippet of code.

***********************************************
InitialContext ctx = new InitialContext();
Object o1 = ctx.lookup("AgileITPTest");
DataSource datasource = (DataSource) PortableRemoteObject.narrow(o1, DataSource.class);
Object o = (UserTransaction) ctx.lookup("UserTransaction");
UserTransaction userTransaction = (UserTransaction)PortableRemoteObject.narrow(o, UserTransaction.class);

userTransaction.begin();
Connection conn = datasource.getConnection();
stat = conn.createStatement();
String sql_Outer = "insert into transac_order values(6421)";
stat.executeUpdate(sql_Outer);
userTransaction.rollback();
conn.close();
} catch(Exception sle) {
sle.printStackTrace();
}
**********************************************************


Thanks in advance,
Suparna
 
Squanch that. And squanch this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic