当前位置: 首页>>代码示例>>Java>>正文


Java C3P0ProxyConnection.rawConnectionOperation方法代码示例

本文整理汇总了Java中com.mchange.v2.c3p0.C3P0ProxyConnection.rawConnectionOperation方法的典型用法代码示例。如果您正苦于以下问题:Java C3P0ProxyConnection.rawConnectionOperation方法的具体用法?Java C3P0ProxyConnection.rawConnectionOperation怎么用?Java C3P0ProxyConnection.rawConnectionOperation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mchange.v2.c3p0.C3P0ProxyConnection的用法示例。


在下文中一共展示了C3P0ProxyConnection.rawConnectionOperation方法的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;
    }
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:30,代码来源:MysqlConnectionTester.java

示例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;
}
 
开发者ID:linyuhe,项目名称:london,代码行数:11,代码来源:C3P0NativeJdbcExtractor.java

示例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;
	}
}
 
开发者ID:hinsenchan,项目名称:fil_project_mgmt_app_v2,代码行数:32,代码来源:MysqlConnectionTester.java


注:本文中的com.mchange.v2.c3p0.C3P0ProxyConnection.rawConnectionOperation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。