mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
support pinGlobalTxToPhysicalConnection setting.
This commit is contained in:
@@ -20,11 +20,23 @@ import java.sql.SQLException;
|
||||
|
||||
import javax.sql.XAConnection;
|
||||
|
||||
import com.mysql.jdbc.Util;
|
||||
import com.mysql.jdbc.jdbc2.optional.MysqlXAConnection;
|
||||
import com.mysql.jdbc.jdbc2.optional.SuspendableXAConnection;
|
||||
|
||||
public class MySqlUtils {
|
||||
|
||||
public static XAConnection createXAConnection(Connection physicalConn) throws SQLException {
|
||||
return new MysqlXAConnection((com.mysql.jdbc.ConnectionImpl) physicalConn, false);
|
||||
com.mysql.jdbc.ConnectionImpl mysqlConn = (com.mysql.jdbc.ConnectionImpl)physicalConn;
|
||||
if(mysqlConn.getPinGlobalTxToPhysicalConnection()) {
|
||||
|
||||
if (!Util.isJdbc4()) {
|
||||
return new SuspendableXAConnection(mysqlConn);
|
||||
}
|
||||
|
||||
return new com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection(mysqlConn);
|
||||
|
||||
}
|
||||
return new MysqlXAConnection(mysqlConn, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user