ejb 多数据库操作

ejb 多数据库操作

2012-05-07 18:06:18| 分类: j2ee |字号 订阅







mysqlds01
true
com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
127.0.0.1
test01
root
xinhua

mySQL





mysqlds02
true
com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
127.0.0.1
test02
root
xinhua

mySQL





@Stateless(name="sm")
@Remote
public class StudentManagerBean implements StudentManager {

@PersistenceContext(unitName="test01")
private EntityManager em;

@PersistenceContext(unitName="test02")
private EntityManager em1;

public void addStudent(String name) {

User u = new User();
u.setName(name);
em.persist(u);

Person p = new Person();
p.setName(name + "01");
em1.persist(p);
//throw new RuntimeException("oh no!");
}

}



xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">

java:/mysqlds01
com.huazhen.jpa.User
true







java:/mysqlds02
com.huazhen.jpa.Person
true





你可能感兴趣的:(EJB3)