本文整理汇总了Java中com.mchange.v2.c3p0.C3P0ProxyConnection类的典型用法代码示例。如果您正苦于以下问题:Java C3P0ProxyConnection类的具体用法?Java C3P0ProxyConnection怎么用?Java C3P0ProxyConnection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
C3P0ProxyConnection类属于com.mchange.v2.c3p0包,在下文中一共展示了C3P0ProxyConnection类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activeCheckConnection
import com.mchange.v2.c3p0.C3P0ProxyConnection; //导入依赖的package包/类
public int activeCheckConnection(Connection con) {
try {
if (this.pingMethod != null) {
if (con instanceof com.mysql.jdbc.Connection) {
// We've been passed an instance of a MySQL connection -- no need for reflection
((com.mysql.jdbc.Connection) con).ping();
} else {
// Assume the connection is a C3P0 proxy
C3P0ProxyConnection castCon = (C3P0ProxyConnection) con;
castCon.rawConnectionOperation(this.pingMethod, C3P0ProxyConnection.RAW_CONNECTION, NO_ARGS_ARRAY);
}
} else {
Statement pingStatement = null;
try {
pingStatement = con.createStatement();
pingStatement.executeQuery("SELECT 1").close();
} finally {
if (pingStatement != null) {
pingStatement.close();
}
}
}
return CONNECTION_IS_OKAY;
} catch (Exception ex) {
return CONNECTION_IS_INVALID;
}
}
示例2: getNativeConnection
import com.mchange.v2.c3p0.C3P0ProxyConnection; //导入依赖的package包/类
public Connection getNativeConnection(Connection con) throws Exception {
if (con instanceof C3P0ProxyConnection) {
C3P0ProxyConnection cpCon = (C3P0ProxyConnection) con;
return (Connection) cpCon.rawConnectionOperation(
this.getRawConnectionMethod, null,
new Object[] { C3P0ProxyConnection.RAW_CONNECTION });
}
return con;
}
示例3: activeCheckConnection
import com.mchange.v2.c3p0.C3P0ProxyConnection; //导入依赖的package包/类
public int activeCheckConnection(Connection con) {
try {
if (pingMethod != null) {
if (con instanceof com.mysql.jdbc.Connection) {
// We've been passed an instance of a MySQL connection --
// no need for reflection
((com.mysql.jdbc.Connection) con).ping();
} else {
// Assume the connection is a C3P0 proxy
C3P0ProxyConnection castCon = (C3P0ProxyConnection) con;
castCon.rawConnectionOperation(pingMethod,
C3P0ProxyConnection.RAW_CONNECTION, NO_ARGS_ARRAY);
}
} else {
Statement pingStatement = null;
try {
pingStatement = con.createStatement();
pingStatement.executeQuery("SELECT 1").close();
} finally {
if (pingStatement != null) {
pingStatement.close();
}
}
}
return CONNECTION_IS_OKAY;
} catch (Exception ex) {
return CONNECTION_IS_INVALID;
}
}