I'm now getting a data-source handle by looking up "jdbc/DefaultEJBDS" instead of "jdbc/DefaultPooledDS" and the rollbacks are working as intended. Thankyou. I'm presuming the connection pooling will still work in the same manner?
Rob. > -----Original Message----- > From: Fredrik Lindgren [mailto:[EMAIL PROTECTED]] > Sent: 05 January 2002 00:09 > To: [EMAIL PROTECTED] > Subject: Re: Basic transaction misunderstanding > > > You seem to be using Orion. If I remember this correctly, you > should be using the ejb-location to take advantage of the > Container Managed Transactions in Orion. > > I haven't used it myself, but I seem to recall that the xa > datasource is used for Bean Managed Transactions. > > /Fredrik Lindgren > > > Robert Hargreaves wrote: > > > I get the DataSource handle using > > > > ds = (DataSource) initialContext.lookup("jdbc/DefaultPooledDS"); > > > > which is defined in data-sources.xml as: > > > > <data-source > > name="SQL Server" > > class="com.evermind.sql.ConnectionDataSource" > > location="jdbc/DefaultDS" > > pooled-location="jdbc/DefaultPooledDS" > > ejb-location="jdbc/DefaultEJBDS" > > xa-location="jdbc/xa/DefaultXADS" > > url="jdbc:inetdae7:RH:1433?database=damanEnt" > > connection-driver="com.inet.tds.TdsDriver" > > username="sa" > > max-connections="20" > > schema = "\database-schemas\sqlserver.xml" > > password="password" > > /> > > > > Should a be using "jdbc/xa/DefaultXADS" ? > > > > > >>-----Original Message----- > >>From: Chandra kumar [mailto:[EMAIL PROTECTED]] > >>Sent: 04 January 2002 14:02 > >>To: [EMAIL PROTECTED] > >>Subject: Re: Basic transaction misunderstanding > >> > >> > >> > >>>con = ds.getConnection(); > >>> > >>As you haven't mentioned about the data source, I'd check > to make sure > >>the data source obtained is defined in admin server as > transactional. > >>That means the server should provide ds object from the connection > >>pool that uses xa driver. > >> > >> > >>Robert Hargreaves wrote: > >> > >>I have a remote method X defined in a stateless session > bean as being > >>TX_REQUIRES_NEW. In the implementation class for method X I > call three > >>non-remote private methods A, B & C. Methods A and C create > CMP Entity > >>beans using their respective create() methods, but method B creates > >>database records using hard-coded SQL like this: > >> > >>public void B(int compNum, long oid) throws RemoteException { > >> Connection con = null; > >> try { > >> con = ds.getConnection(); > >> > >> Statement stmt = con.createStatement(); > >> stmt.executeUpdate(("INSERT INTO companyMap > (compNum, oid) > >>" > >>+ > >> "VALUES (" + compNum + "," + oid + ")")); > >> stmt.close(); > >> } catch (Exception e) { > >> throw new RemoteException(e.toString()); > >> } finally { > >> if (con != null) { > >> try { > >> con.close(); > >> } catch (Exception e) { > >> } > >> } > >> } > >> } > >> > >> > >>Trouble is, if there is a problem in with any of the three > methods, I > >>catch the appropriate exception in method X and throw an > EJBException > >>which causes a rollback - but it only rolls back data created in > >>methods A & C (CMP entity bean > >>records) and not data written to the database in method B. > I want the > >>INSERT statement above to be included in the transaction > started when > >>method X is called. > >> > >>Any suggestions? > >> > >>Rob. ==========================================================================To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
