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


Java Connection.isValid方法代码示例

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


在下文中一共展示了Connection.isValid方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleDLLException

import java.sql.Connection; //导入方法依赖的package包/类
/**
 * If DDL exception was caused by a closed connection, log info and display
 * a simple error dialog. Otherwise let users report the exception.
 */
private void handleDLLException(DatabaseConnection dbConn,
        DDLException e) throws SQLException, MissingResourceException {
    Connection conn = dbConn == null ? null : dbConn.getJDBCConnection();
    if (conn != null && !conn.isValid(1000)) {
        LOGGER.log(Level.INFO, e.getMessage(), e);
        NotifyDescriptor nd = new NotifyDescriptor.Message(
                NbBundle.getMessage(
                MakeDefaultCatalogAction.class,
                "ERR_ConnectionToServerClosed"), //NOI18N
                NotifyDescriptor.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notifyLater(nd);
    } else {
        Exceptions.printStackTrace(e);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:MakeDefaultCatalogAction.java

示例2: getConnection

import java.sql.Connection; //导入方法依赖的package包/类
public synchronized Connection getConnection() {
	Connection result = cachedConnection; 
	if (result != null) {
		try {
			if (!result.isValid(2)) {
				logger.log(Level.WARNING, "closing invalid connection"); 
				result = null;
			}
		}
		catch (Exception e) {
			logger.log(Level.WARNING, "connection became invalid: "+e.toString(), e); 
			result = null;
		}
	}
	if (result == null) {
		result = getNewConnection();
		cachedConnection = result;
	}
	return result;
}
 
开发者ID:ferenc-hechler,项目名称:RollenspielAlexaSkill,代码行数:21,代码来源:SimpleDBConnection.java

示例3: testBug56122

import java.sql.Connection; //导入方法依赖的package包/类
/**
 * Tests fix for Bug#56122 - JDBC4 functionality failure when using replication connections.
 */
public void testBug56122() throws Exception {
    for (final Connection testConn : new Connection[] { this.conn, getFailoverConnection(), getLoadBalancedConnection(),
            getMasterSlaveReplicationConnection() }) {
        testConn.createClob();
        testConn.createBlob();
        testConn.createNClob();
        testConn.createSQLXML();
        testConn.isValid(12345);
        testConn.setClientInfo(new Properties());
        testConn.setClientInfo("NAME", "VALUE");
        testConn.getClientInfo();
        testConn.getClientInfo("CLIENT");
        assertThrows(SQLFeatureNotSupportedException.class, new Callable<Void>() {
            public Void call() throws Exception {
                testConn.createArrayOf("A_TYPE", null);
                return null;
            }
        });
        assertThrows(SQLFeatureNotSupportedException.class, new Callable<Void>() {
            public Void call() throws Exception {
                testConn.createStruct("A_TYPE", null);
                return null;
            }
        });
    }
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:30,代码来源:ConnectionRegressionTest.java

示例4: isClose

import java.sql.Connection; //导入方法依赖的package包/类
public static boolean isClose(Connection connection){
    try {
        connection.isValid(1000);
        return connection == null||connection.isClosed();
    } catch (SQLException e) {
        return false;
    }
}
 
开发者ID:rpgmakervx,项目名称:slardar,代码行数:9,代码来源:ConnectionUtils.java

示例5: isValid

import java.sql.Connection; //导入方法依赖的package包/类
public static boolean isValid(Connection connection){
    try {
        return connection == null||connection.isValid(3);
    } catch (SQLException e) {
        return false;
    }
}
 
开发者ID:rpgmakervx,项目名称:slardar,代码行数:8,代码来源:ConnectionUtils.java

示例6: validateConnection

import java.sql.Connection; //导入方法依赖的package包/类
private boolean validateConnection(Connection conn) {
	try {
		return conn.isValid(2000);
	} catch (Exception e) {
		log.error(String.format("��֤���ݿ�����״̬ʱ��������%s", e.getMessage()));
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:MsBuggy,项目名称:AnyMall,代码行数:10,代码来源:DBConnectionPool.java

示例7: validateConnection

import java.sql.Connection; //导入方法依赖的package包/类
/**
 * Verify the provided connection is valid.
 */
protected boolean validateConnection(Connection connection)
    throws SQLException {
  return connection != null && !connection.isClosed()
    && connection.isValid(DEFAULT_RETRY_WAIT_INTERVAL);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:9,代码来源:BasicRetrySQLFailureHandler.java


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