高手请给看看weblogic为什么不rollback呀?

flowerCow 2004-06-30 11:14:02
是代码的问题,还是weblogic配置问题?

<%
final String jNDIString="jdbc/mysql_test";
javax.naming.Context ic = new javax.naming.InitialContext();
javax.sql.DataSource ds=(javax.sql.DataSource)ic.lookup(jNDIString);
java.sql.Connection conn = ds.getConnection();
java.sql.Statement stmt=conn.createStatement();
int i;
javax.transaction.UserTransaction userTran;

userTran = (javax.transaction.UserTransaction)ic.lookup("javax.transaction.UserTransaction");

userTran.begin();
try
{
stmt.execute("insert into test (a) values ('abc')");
i=1/0;
userTran.commit();
}
catch(Exception ex)
{
userTran.rollback();
out.print(ex.toString());
}
stmt.close();
conn.close();

ic = null;
ds = null;
conn = null;
stmt =null;
%>


下面是连接池和数据源配置

<JDBCTxDataSource EnableTwoPhaseCommit="true"
JNDIName="jdbc/mysql_test" Name="jdbc/mysql_test"
PoolName="jdbc/mysql_test" Targets="myserver"/>
<JDBCConnectionPool DriverName="org.gjt.mm.mysql.Driver"
Name="jdbc/mysql_test" Password="{3DES}wMiXJu2VjPmitcGWfZkIXA=="
Properties="user=dataCenter_user" Targets="myserver"
TestConnectionsOnCreate="true" TestConnectionsOnRelease="true"
TestConnectionsOnReserve="true" TestFrequencySeconds="60"
TestTableName="SQL SELECT 1" URL="jdbc:mysql://localhost:3306/datacenter"/>


可同样的代码在
Sun Java System Application Server Platform Edition 8.0
下面就能正常的rollback
...全文
45 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
flowerCow 2004-06-30
  • 打赏
  • 举报
回复
InnoDB,BDB类型的表可以支持事务
hq1305018 2004-06-30
  • 打赏
  • 举报
回复
mysql不支持事务。请换用其它数据库。

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧