ConnectionHandle implements Connection,Serializable { protected SQLException markPossiblyBroken(SQLException e) { String state = e.getSQLState(); boolean alreadyDestroyed = false; ConnectionState connectionState = this.getConnectionHook() != null ? this.getConnectionHook().onMarkPossiblyBroken(this, state, e) : ConnectionState.NOP; if (state == null){ state = "08999"; } if (((sqlStateDBFailureCodes.contains(state) || connectionState.equals(ConnectionState.TERMINATE_ALL_CONNECTIONS)) && this.pool != null) && this.pool.getDbIsDown().compareAndSet(false, true) ){ logger.error("Database access problem. Killing off this connection and all remaining connections in the connection pool. SQL State = " + state); this.pool.connectionStrategy.terminateAllConnections(); this.pool.destroyConnection(this); this.logicallyClosed.set(true); alreadyDestroyed = true; for (int i=0; i < this.pool.partitionCount; i++) { this.pool.partitions[i].getPoolWatchThreadSignalQueue().offer(new Object()); } } if (state.equals("08003") || sqlStateDBFailureCodes.contains(state) || e.getCause() instanceof SocketException) { if (!alreadyDestroyed) { this.pool.destroyConnection(this); this.logicallyClosed.set(true); getOriginatingPartition().getPoolWatchThreadSignalQueue().offer(new Object()); } } char firstChar = state.charAt(0); if (connectionState.equals(ConnectionState.CONNECTION_POSSIBLY_BROKEN) || state.equals("40001") || state.equals("HY000") || state.startsWith("08") || (firstChar >= '5' && firstChar <='9') ){ this.possiblyBroken = true; } if (this.possiblyBroken && (this.getConnectionHook() != null)){ this.possiblyBroken = this.getConnectionHook().onConnectionException(this, state, e); } return e; } protected  ConnectionHandle(Connection connection, ConnectionPartition partition, BoneCP pool, boolean recreating); private  ConnectionHandle(); ConnectionHandle recreateConnectionHandle(); void sendInitSQL(); void clearWarnings(); void close(); void commit(); Properties getClientInfo(); String getClientInfo(String name); boolean isValid(int timeout); boolean isWrapperFor(Class<?> iface); T unwrap(Class<T> iface); void setClientInfo(Properties properties); void setClientInfo(String name, String value); Struct createStruct(String typeName, Object[] attributes); Array createArrayOf(String typeName, Object[] elements); Blob createBlob(); Clob createClob(); NClob createNClob(); SQLXML createSQLXML(); void setSchema(String schema); String getSchema(); void abort(Executor executor); void setNetworkTimeout(Executor executor, int milliseconds); int getNetworkTimeout(); Statement createStatement(); Statement createStatement(int resultSetType, int resultSetConcurrency); Statement createStatement(int resultSetType,
			int resultSetConcurrency, int resultSetHoldability); boolean getAutoCommit(); String getCatalog(); int getHoldability(); DatabaseMetaData getMetaData(); int getTransactionIsolation(); Map<String, Class<?>> getTypeMap(); SQLWarning getWarnings(); boolean isClosed(); boolean isReadOnly(); String nativeSQL(String sql); CallableStatement prepareCall(String sql); CallableStatement prepareCall(String sql, int resultSetType,	int resultSetConcurrency); CallableStatement prepareCall(String sql, int resultSetType,
			int resultSetConcurrency, int resultSetHoldability); PreparedStatement prepareStatement(String sql); PreparedStatement prepareStatement(String sql, int autoGeneratedKeys); PreparedStatement prepareStatement(String sql, int[] columnIndexes); PreparedStatement prepareStatement(String sql, String[] columnNames); PreparedStatement prepareStatement(String sql, int resultSetType,  int resultSetConcurrency); PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability); void releaseSavepoint(Savepoint savepoint); void rollback(); void rollback(Savepoint savepoint); void setAutoCommit(boolean autoCommit); void setCatalog(String catalog); void setHoldability(int holdability); void setReadOnly(boolean readOnly); Savepoint setSavepoint(); Savepoint setSavepoint(String name); void setTransactionIsolation(int level); void setTypeMap(Map<String, Class<?>> map); long getConnectionLastUsedInMs(); @Deprecated long getConnectionLastUsed(); long getConnectionLastResetInMs(); @Deprecated long getConnectionLastReset(); boolean isPossiblyBroken(); ConnectionPartition getOriginatingPartition(); Object getDebugHandle(); void setDebugHandle(Object debugHandle); @Deprecated Connection getRawConnection(); Connection getInternalConnection(); ConnectionHook getConnectionHook(); boolean isLogStatementsEnabled(); void setLogStatementsEnabled(boolean logStatementsEnabled); boolean isConnectionAlive(); void setInternalConnection(Connection rawConnection); BoneCP getPool(); List<ReplayLog> getReplayLog(); Object getProxyTarget(); Thread getThreadUsingConnection(); @Deprecated long getConnectionCreationTime(); long getConnectionCreationTimeInMs(); boolean isExpired(); Thread getThreadWatch(); void refreshConnection(); String getUrl(); String toString();  }
@Test public void testMarkPossiblyBroken() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException{ Field field = this.testClass.getClass().getDeclaredField("possiblyBroken"); field.setAccessible(true); field.set(this.testClass, false); this.testClass.markPossiblyBroken(new SQLException()); Assert.assertTrue(field.getBoolean(this.testClass)); expect(this.mockPool.getDbIsDown()).andReturn(new AtomicBoolean()).anyTimes(); this.mockPool.connectionStrategy.terminateAllConnections(); this.mockLogger.error((String)anyObject(), anyObject()); replay(this.mockPool); this.testClass.markPossiblyBroken(new SQLException("test", "08001")); verify(this.mockPool); }