EJB事务问题
public class TestEJB
implements SessionBean
{
Connection conn = null;
public void test1() throws Exception
{
...
Statement stmt = getStmt();
stmt.query();
...
}
public void test2() throws Exception
{
...
Statement stmt = getStmt();
stmt.query();
...
}
private Statement getStmt()
{
if ( conn == null )
{
conn = createConnect();
}
return conn.createStatement();
}
}
public class test()
{
...
Object obj = initial.lookup("TestEJB");
TestHome home = (TestHome)PortableRemoteObject.narrow(objref,TestHome.class);
Test test = home.create();
test.test1();
test.test2();
...
}
在执行test2时会报错,java.sql.SQLException: The transaction is no longer active - status: 'Committed'. No further JDBC access is allowed within this transaction.
如果采用JTA就不会出现这个问题。
由于系统原因不能使用JTA,请问如何解决这个问题,
谢谢各位大侠