本文整理汇总了Java中javax.resource.ResourceException.getCause方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceException.getCause方法的具体用法?Java ResourceException.getCause怎么用?Java ResourceException.getCause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.resource.ResourceException
的用法示例。
在下文中一共展示了ResourceException.getCause方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: commit
import javax.resource.ResourceException; //导入方法依赖的package包/类
public void commit() throws SQLException {
MC mc = getManagedConnection();
if (mc.isInXaTransaction()) {
throw new SQLException("Can not commit within an XA transaction");
}
Connection c = mc.getPhysicalConnection();
if (c.getAutoCommit()) {
return;
}
try {
LocalTransaction tx = mc.getClientLocalTransaction();
tx.commit();
tx.begin();
} catch (ResourceException e) {
if (e.getCause() instanceof SQLException) {
throw (SQLException) e.getCause();
} else {
throw new SQLException(e);
}
}
}
示例2: rollback
import javax.resource.ResourceException; //导入方法依赖的package包/类
public void rollback() throws SQLException {
MC mc = getManagedConnection();
if (mc.isInXaTransaction()) {
throw new SQLException("Can not rollback within an XA transaction");
}
Connection c = mc.getPhysicalConnection();
if (c.getAutoCommit()) {
return;
}
try {
LocalTransaction tx = mc.getClientLocalTransaction();
tx.rollback();
tx.begin();
} catch (ResourceException e) {
if (e.getCause() instanceof SQLException) {
throw (SQLException) e.getCause();
} else {
throw new SQLException(e);
}
}
}
示例3: setAutoCommit
import javax.resource.ResourceException; //导入方法依赖的package包/类
public void setAutoCommit(boolean autoCommit) throws SQLException {
MC mc = getManagedConnection();
if (mc.isInXaTransaction()) {
throw new SQLException("Can not set autoCommit within an XA transaction");
}
Connection c = mc.getPhysicalConnection();
if (autoCommit == c.getAutoCommit()) {
// nothing to do
return;
}
try {
LocalTransaction tx = mc.getClientLocalTransaction();
if (autoCommit) {
// reenabling autoCommit - JDBC spec says current transaction is committed
tx.commit();
} else {
// disabling autoCommit
tx.begin();
}
} catch (ResourceException e) {
if (e.getCause() instanceof SQLException) {
throw (SQLException) e.getCause();
} else {
throw new SQLException(e);
}
}
}
示例4: getConnection
import javax.resource.ResourceException; //导入方法依赖的package包/类
private Connection getConnection(UserPasswordConnectionRequestInfo cri) throws SQLException {
try {
return (Connection) cm.allocateConnection(mcf, cri);
} catch (ResourceException e) {
LOGGER.log(Level.INFO, e.getMessage(), e);
//Failed to allocate!
if (e.getCause() instanceof SQLException) {
throw (SQLException) e.getCause();
} else {
throw new SQLException(e);
}
}
}