當前位置: 首頁>>代碼示例>>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: 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

示例5: 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

示例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;未經允許,請勿轉載。