[jboss-user] [JCA/JBoss] - Re: XA Connection error

smithbstl do-not-reply at jboss.com
Wed Sep 6 17:06:13 EDT 2006


I was under the impression that connections and tranasctions were not the same animal.  What I am doing is gaining a connection from the datasource looked up from JNDI, issueing an update through that connection, committing the update and closing the connection

    public void update(AccountBean acctBean){
  |         Connection conn = null;
  |         PreparedStatement ps = null;
  |         int result = 0;
  |         String sql = "Update Budget.Account Set Acct_Num = ?, Acct_Name =?" +
  |                 " Where Acct_ID = ?";
  |         try {
  |             conn = JDBCUtil.getConnection();
  |             ps = conn.prepareStatement(sql);
  |             ps.setString(1,acctBean.getAcctNum());
  |             ps.setString(2,acctBean.getAcctName());
  |             ps.setInt(3,acctBean.getAcctId());
  |             result = ps.executeUpdate();
  |             conn.commit();
  |         } catch (SQLException e) {
  |             System.err.println(e.toString());
  |         } finally {
  |             JDBCUtil.close(ps);
  |             JDBCUtil.close(conn);
  |         }        
  |     } 

JDBCUtil
  public static Connection getConnection()
  |     throws SQLException
  |   {
  |     DataSource ds = null;
  |     Connection connection = null;
  |     boolean exceptionRaised = false;
  |     ds = ServiceLocator.getDataSource("java:comp/env/jdbc/XAOracleDS");
  |     connection = ds.getConnection();
  |     return connection;
  |   }	

How would this look if I was letting JBoss manage the transaction?

I thought the only difference between TX and XA was the two phase commit?

Thanks for your patience and help.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969882#3969882

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969882



More information about the jboss-user mailing list