public String businessMethod(String message) throws Exception{
                       
                        ut=(UserTransaction) messageDC.getUserTransaction();
                                                ut.begin();                     
                                              Properties prop = new 
Properties();  
              prop.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.RemoteInitialContextFactory");    
              prop.setProperty(Context.PROVIDER_URL, "ejbd://127.0.0.1:4201");  
                
              InitialContext ctx = new InitialContext(prop);                    
                                                                        
                                        //DataSource h2 =(DataSource) 
ctx.lookup("H2");  ??????
                                                        //XAConnection 
xah=h2.getXAConnection(); ??????
                                        //java.sql.Connection 
connh2=xah.getConnection();???????                                
                                        StringBuffer sql1 = new 
StringBuffer(256);
                                                        sql1.append(" update 
testh set name  ='111'  where id =1 ");                    
                                                        PreparedStatement 
PreStmt1 =
connh2.prepareStatement(sql1.toString());
                                                        
System.out.println(sql1);
                                                        
PreStmt1.executeUpdate();
                                                  PreStmt1.close();
                                                  connh2.close();
                                        
                                        //DataSource db2 =(DataSource) 
ctx.lookup("DB2");??????
                                        //XAConnection 
xad=db2.getXAConnection();????????????
                                        //java.sql.Connection 
conndb2=db2.getConnection();????????                                      
                                        StringBuffer sql = new 
StringBuffer(256);
                                                        sql.append(" update 
TEST27 set name  ='131'  where id =1 ");                            
                                                        PreparedStatement 
PreStmt = conndb2.prepareStatement(sql.toString());
                                                        System.out.println(sql);
                                                        PreStmt.executeUpdate();
                                                  PreStmt.close();
                                                  conndb2.close();              
                          
                                          ut.commit();
                                          System.out.println("businessMethod 
finish!");
                                return "OK_Earth";
    }



--
View this message in context: 
http://openejb.979440.n4.nabble.com/about-openejb-standalone-transaction-control-tp4660358p4660413.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Reply via email to