tanner

Greenhorn
+ Follow
since Oct 30, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by tanner

I need to create a CF(class factory). The CF should store references (probably in a Map). When the method is called the CF should check is a reference is available, if yes, it should return the reference to the client else create a new instance, store in the Map (for subsequent requests) and return a reference to the client. Is this a feasible? My concern is what happens when 2 clients get reference to the object at the same time. When both the clients call methods on the object will it cause a problem since both the clients are using the same object reference,
Thanks,
Tanner
I have a questions on EJB's
How can I define parameters in deployment descriptor so that these parameters are available to all the EJB's in the deployment. I am looking to define things like dataSource name in the deployment descriptor so all the ejb's in the deployment can use the same datasource. Can anyone pls. provide me with a copy of deployment descriptor for this. How to retrieve these values in ejb's? Can anyone provide sample code for this also?
Many Thanks,
Tanner
I created a datasource in weblogic server and used this datasource in code. I am able to rollback transactions by calling ctx.setRollbackOnly() in the catch block in the code.
The catch block code is as follows:
catch (Exception e)
{
ctx.setRollbackOnly();
throw new EJBException(e.getMessage());
}
Is this standard behaviour to call ctx.setRollbackOnly() in the catch block? Will creating the EJBException not rollback the transaction?
Thanks Kyle, really appreciate your reply. I was working on weblogic server. Will try the datasource method and get back if I run into anu problem.
Thanks
Simple Question I have a standalone client calling a stateless session bean with container managed transaction. In the bean I have 2 database inserts in a method to SQL 2000 database. The second insert is for a table that does not exists so as per my understanding the transaction should be rolled back and neither of the updates should take place. What I am finding is the first insert takes place even though the second insert is throwing an error!! PLS HELP!!! Below is my EJB code. public class TranTestEJB implements SessionBean { SessionContext ctx; public void ejbActivate() {} public void ejbPassivate() {} public void ejbCreate() {} public void ejbRemove() {} public void setSessionContext(SessionContext ctx) { this.ctx = ctx; } public void runTest() { String url = "jdbc dbc:Queue"; String user = "sa"; String password = ""; String sql; String sql2; Connection connection; Statement statement; try{ //ctx.getUserTransaction().begin(); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); connection = DriverManager.getConnection(url,user,password); statement = connection.createStatement(); sql = "Insert into Description values ('HA')"; statement.executeUpdate(sql); sql2 = "Insert into AAAXXX values ('HB')"; statement.executeUpdate(sql2); ().commit(); } catch (Exception e) { throw new EJBException(e.getMessage); } finally { sql = null; sql2 = null; statement = null; connection = null; } } } My deployment descriptor has the following code <ejb-jar> <enterprise-beans> <session> <ejb-name>TranTest</ejb-name> <home>test.TranTestHome</home> <remote>test.TranTest</remote> <ejb-class>test.TranTestEJB</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> </session> </enterprise-beans> <assembly-descriptor> <container-transaction> <method> <ejb-name>TranTest</ejb-name> <method-name>*</method-name> </method> <trans-attribute>RequiresNew</trans-attribute> </container-transaction> </assembly-descriptor> </ejb-jar> PLS Help.