"[EMAIL PROTECTED]" wrote : Look up the datasource and ask for a connection.
  | The jca wrapper will enroll the connection in the
  | current transaction.
  | 
  | Make sure you close the connection and any statements
  | in a finally block to return them to the pool.
  | 
  | Regards,
  | Adrian

Hi:
I am trying this in Jboss 4.0.4 and it does not work:

example:




  | protected EJBContext myContext = null;
  | public void setSessionContext (SessionContext ctx){
  |       myContext = ctx;
  | }
  | public void  setUserData(String userId, String name,  String roleId) 
  | throws RemoteException{
  |                 try { 
  |                         UserLocal userLocal = UserFactoryLocal.getUser
  | (userId); //Userlocal is an entity bean 
  |                         userLocal.setRoleId(roleId);
  |                         Object object = myContext.lookup("java:/" + 
myDataSourceName); // Same datasoiurce name as the bean uses, it is a local 
datasource name
  |                         Connection connection = 
  | ((DataSource)object).getConnection();
  |                         connection.execute("update usuario set 
  | rol = '" + roleId + "' where usuario = '" + userId + "'";
  | 
  |                         connection.close();
  | 
  |                         userLocal.setUserName(name);    //if this set fails 
there is no rollback performed to the previous execute
  |                 }
  |                 catch (Exception e) {
  |                         e.printStackTrace();
  |                         throw new EJBException(e);
  |                 }
  |         }

The example as you can see is functionalitywise, bogus, but I can see that if 
the code fails in setUserName then the new role appears set in the database 
eventhoug There is a EJB exception thrown....






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

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4111190
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to