81,091
社区成员
发帖
与我相关
我的任务
分享
<Resource
auth="Container"
type="javax.sql.DataSource"
name="jdbc/mysql"
username="root"
password="lnie"
maxActive="4"
maxIdle="2"
maxWait="5000"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/test?autoReconnect=true"
/>
<Resource name="UserTransaction" auth="Container"
type="javax.transaction.UserTransaction"
factory = "org.objectweb.jotm.UserTransactionFactory"
jotm.timeout = "60"/>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/mysql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>UserTransaction description</description>
<res-ref-name>UserTransaction</res-ref-name>
<res-type>javax.transaction.UserTransaction</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="connection.datasource">java:comp/env/jdbc/mysql</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<!--后面测试发现下面这行配置不起作用,不知道为什么,很困惑-->
<property name="current_session_context_class">jta</property>
<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="jta.UserTransaction">java:comp/env/UserTransaction</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.JOTMTransactionManagerLookup</property>
UserTransaction tx = getUserTransaction();
System.out.println(tx);
Session session = sessionfactory.getCurrentSession();//这行报异常