⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 replicationconnection.java

📁 mysql5.0 JDBC 驱动 放在glassfish或者tomcat的lib文件夹下就可以了
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	/*	 * (non-Javadoc)	 * 	 * @see java.sql.Connection#setSavepoint(java.lang.String)	 */	public synchronized Savepoint setSavepoint(String name) throws SQLException {		return this.currentConnection.setSavepoint(name);	}	/*	 * (non-Javadoc)	 * 	 * @see java.sql.Connection#setTransactionIsolation(int)	 */	public synchronized void setTransactionIsolation(int level)			throws SQLException {		this.currentConnection.setTransactionIsolation(level);	}	// For testing	/*	 * (non-Javadoc)	 * 	 * @see java.sql.Connection#setTypeMap(java.util.Map)	 */	public synchronized void setTypeMap(Map arg0) throws SQLException {		this.currentConnection.setTypeMap(arg0);	}	private synchronized void switchToMasterConnection() throws SQLException {		swapConnections(this.masterConnection, this.slavesConnection);	}	private synchronized void switchToSlavesConnection() throws SQLException {		swapConnections(this.slavesConnection, this.masterConnection);	}		/**	 * Swaps current context (catalog, autocommit and txn_isolation) from	 * sourceConnection to targetConnection, and makes targetConnection	 * the "current" connection that will be used for queries.	 * 	 * @param switchToConnection the connection to swap from	 * @param switchFromConnection the connection to swap to	 * 	 * @throws SQLException if an error occurs	 */	private synchronized void swapConnections(Connection switchToConnection, 			Connection switchFromConnection) throws SQLException {		String switchFromCatalog = switchFromConnection.getCatalog();		String switchToCatalog = switchToConnection.getCatalog();		if (switchToCatalog != null && !switchToCatalog.equals(switchFromCatalog)) {			switchToConnection.setCatalog(switchFromCatalog);		} else if (switchFromCatalog != null) {			switchToConnection.setCatalog(switchFromCatalog);		}		boolean switchToAutoCommit = switchToConnection.getAutoCommit();		boolean switchFromConnectionAutoCommit = switchFromConnection.getAutoCommit();				if (switchFromConnectionAutoCommit != switchToAutoCommit) {			switchToConnection.setAutoCommit(switchFromConnectionAutoCommit);		}		int switchToIsolation = switchToConnection				.getTransactionIsolation();		int switchFromIsolation = switchFromConnection.getTransactionIsolation();				if (switchFromIsolation != switchToIsolation) {			switchToConnection					.setTransactionIsolation(switchFromIsolation);		}				this.currentConnection = switchToConnection;	}	public synchronized void doPing() throws SQLException {		if (this.masterConnection != null) {			this.masterConnection.ping();		}				if (this.slavesConnection != null) {			this.slavesConnection.ping();		}	}	public synchronized void changeUser(String userName, String newPassword)			throws SQLException {		// TODO Auto-generated method stub			}	public synchronized void clearHasTriedMaster() {		this.masterConnection.clearHasTriedMaster();		this.slavesConnection.clearHasTriedMaster();			}	public synchronized PreparedStatement clientPrepareStatement(String sql)			throws SQLException {		PreparedStatement pstmt = this.currentConnection.clientPrepareStatement(sql);		((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);				return pstmt;	}	public synchronized PreparedStatement clientPrepareStatement(String sql,			int autoGenKeyIndex) throws SQLException {		PreparedStatement pstmt = this.currentConnection.clientPrepareStatement(sql, autoGenKeyIndex);		((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);				return pstmt;	}	public synchronized PreparedStatement clientPrepareStatement(String sql,			int resultSetType, int resultSetConcurrency) throws SQLException {		PreparedStatement pstmt = this.currentConnection.clientPrepareStatement(sql, resultSetType, resultSetConcurrency);		((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);				return pstmt;	}	public synchronized PreparedStatement clientPrepareStatement(String sql,			int[] autoGenKeyIndexes) throws SQLException {		PreparedStatement pstmt = this.currentConnection.clientPrepareStatement(sql, autoGenKeyIndexes);		((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);				return pstmt;	}	public synchronized PreparedStatement clientPrepareStatement(String sql,			int resultSetType, int resultSetConcurrency,			int resultSetHoldability) throws SQLException {		PreparedStatement pstmt = this.currentConnection.clientPrepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);		((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);				return pstmt;	}	public synchronized PreparedStatement clientPrepareStatement(String sql,			String[] autoGenKeyColNames) throws SQLException {		PreparedStatement pstmt = this.currentConnection.clientPrepareStatement(sql, autoGenKeyColNames);		((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);				return pstmt;	}	public synchronized int getActiveStatementCount() {		return this.currentConnection.getActiveStatementCount();	}	public synchronized long getIdleFor() {		return this.currentConnection.getIdleFor();	}	public synchronized Log getLog() throws SQLException {		return this.currentConnection.getLog();	}	public synchronized String getServerCharacterEncoding() {		return this.currentConnection.getServerCharacterEncoding();	}	public synchronized TimeZone getServerTimezoneTZ() {		return this.currentConnection.getServerTimezoneTZ();	}	public synchronized String getStatementComment() {		return this.currentConnection.getStatementComment();	}	public synchronized boolean hasTriedMaster() {		return this.currentConnection.hasTriedMaster();	}	public synchronized void initializeExtension(Extension ex) throws SQLException {		this.currentConnection.initializeExtension(ex);	}	public synchronized boolean isAbonormallyLongQuery(long millisOrNanos) {		return this.currentConnection.isAbonormallyLongQuery(millisOrNanos);	}	public synchronized boolean isInGlobalTx() {		return this.currentConnection.isInGlobalTx();	}	public synchronized boolean isMasterConnection() {		return this.currentConnection.isMasterConnection();	}	public synchronized boolean isNoBackslashEscapesSet() {		return this.currentConnection.isNoBackslashEscapesSet();	}	public synchronized boolean lowerCaseTableNames() {		return this.currentConnection.lowerCaseTableNames();	}	public synchronized boolean parserKnowsUnicode() {		return this.currentConnection.parserKnowsUnicode();	}	public synchronized void ping() throws SQLException {		this.masterConnection.ping();		this.slavesConnection.ping();	}	public synchronized void reportQueryTime(long millisOrNanos) {		this.currentConnection.reportQueryTime(millisOrNanos);	}	public synchronized void resetServerState() throws SQLException {		this.currentConnection.resetServerState();	}	public synchronized PreparedStatement serverPrepareStatement(String sql)			throws SQLException {		PreparedStatement pstmt = this.currentConnection.serverPrepareStatement(sql);		((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);				return pstmt;	}	public synchronized PreparedStatement serverPrepareStatement(String sql,			int autoGenKeyIndex) throws SQLException {		PreparedStatement pstmt = this.currentConnection.serverPrepareStatement(sql, autoGenKeyIndex);		((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);				return pstmt;	}	public synchronized PreparedStatement serverPrepareStatement(String sql,			int resultSetType, int resultSetConcurrency) throws SQLException {		PreparedStatement pstmt = this.currentConnection.serverPrepareStatement(sql, resultSetType, resultSetConcurrency);		((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);				return pstmt;	}	public synchronized PreparedStatement serverPrepareStatement(String sql,			int resultSetType, int resultSetConcurrency,			int resultSetHoldability) throws SQLException {		PreparedStatement pstmt = this.currentConnection.serverPrepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);		((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);				return pstmt;	}	public synchronized PreparedStatement serverPrepareStatement(String sql,			int[] autoGenKeyIndexes) throws SQLException {		PreparedStatement pstmt = this.currentConnection.serverPrepareStatement(sql, autoGenKeyIndexes);		((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);				return pstmt;	}	public synchronized PreparedStatement serverPrepareStatement(String sql,			String[] autoGenKeyColNames) throws SQLException {		PreparedStatement pstmt = this.currentConnection.serverPrepareStatement(sql, autoGenKeyColNames);		((com.mysql.jdbc.Statement) pstmt).setPingTarget(this);				return pstmt;	}	public synchronized void setFailedOver(boolean flag) {		this.currentConnection.setFailedOver(flag);	}	public synchronized void setPreferSlaveDuringFailover(boolean flag) {		this.currentConnection.setPreferSlaveDuringFailover(flag);	}	public synchronized void setStatementComment(String comment) {		this.masterConnection.setStatementComment(comment);		this.slavesConnection.setStatementComment(comment);	}	public synchronized void shutdownServer() throws SQLException {		this.currentConnection.shutdownServer();	}	public synchronized boolean supportsIsolationLevel() {		return this.currentConnection.supportsIsolationLevel();	}	public synchronized boolean supportsQuotedIdentifiers() {		return this.currentConnection.supportsQuotedIdentifiers();	}	public synchronized boolean supportsTransactions() {		return this.currentConnection.supportsTransactions();	}	public synchronized boolean versionMeetsMinimum(int major, int minor, int subminor)			throws SQLException {		return this.currentConnection.versionMeetsMinimum(major, minor, subminor);	}	public synchronized String exposeAsXml() throws SQLException {		return this.currentConnection.exposeAsXml();	}	public synchronized boolean getAllowLoadLocalInfile() {		return this.currentConnection.getAllowLoadLocalInfile();	}	public synchronized boolean getAllowMultiQueries() {		return this.currentConnection.getAllowMultiQueries();	}	public synchronized boolean getAllowNanAndInf() {		return this.currentConnection.getAllowNanAndInf();	}	public synchronized boolean getAllowUrlInLocalInfile() {		return this.currentConnection.getAllowUrlInLocalInfile();	}	public synchronized boolean getAlwaysSendSetIsolation() {		return this.currentConnection.getAlwaysSendSetIsolation();	}	public synchronized boolean getAutoClosePStmtStreams() {		return this.currentConnection.getAutoClosePStmtStreams();	}	public synchronized boolean getAutoDeserialize() {		return this.currentConnection.getAutoDeserialize();	}	public synchronized boolean getAutoGenerateTestcaseScript() {		return this.currentConnection.getAutoGenerateTestcaseScript();	}	public synchronized boolean getAutoReconnectForPools() {		return this.currentConnection.getAutoReconnectForPools();	}	public synchronized boolean getAutoSlowLog() {		return this.currentConnection.getAutoSlowLog();	}	public synchronized int getBlobSendChunkSize() {		return this.currentConnection.getBlobSendChunkSize();	}	public synchronized boolean getBlobsAreStrings() {		return this.currentConnection.getBlobsAreStrings();	}	public synchronized boolean getCacheCallableStatements() {		return this.currentConnection.getCacheCallableStatements();	}	public synchronized boolean getCacheCallableStmts() {		return this.currentConnection.getCacheCallableStmts();	}	public synchronized boolean getCachePrepStmts() {		return this.currentConnection.getCachePrepStmts();	}	public synchronized boolean getCachePreparedStatements() {		return this.currentConnection.getCachePreparedStatements();	}	public synchronized boolean getCacheResultSetMetadata() {		return this.currentConnection.getCacheResultSetMetadata();	}	public synchronized boolean getCacheServerConfiguration() {		return this.currentConnection.getCacheServerConfiguration();	}	public synchronized int getCallableStatementCacheSize() {		return this.currentConnection.getCallableStatementCacheSize();	}	public synchronized int getCallableStmtCacheSize() {		return this.currentConnection.getCallableStmtCacheSize();	}	public synchronized boolean getCapitalizeTypeNames() {		return this.currentConnection.getCapitalizeTypeNames();	}	public synchronized String getCharacterSetResults() {		return this.currentConnection.getCharacterSetResults();	}	public synchronized String getClientCertificateKeyStorePassword() {		return this.currentConnection.getClientCertificateKeyStorePassword();	}	public synchronized String getClientCertificateKeyStoreType() {		return this.currentConnection.getClientCertificateKeyStoreType();	}	public synchronized String getClientCertificateKeyStoreUrl() {		return this.currentConnection.getClientCertificateKeyStoreUrl();	}	public synchronized String getClientInfoProvider() {		return this.currentConnection.getClientInfoProvider();	}	public synchronized String getClobCharacterEncoding() {		return this.currentConnection.getClobCharacterEncoding();	}	public synchronized boolean getClobberStreamingResults() {		return this.currentConnection.getClobberStreamingResults();	}	public synchronized int getConnectTimeout() {		return this.currentConnection.getConnectTimeout();	}	public synchronized String getConnectionCollation() {		return this.currentConnection.getConnectionCollation();	}	public synchronized String getConnectionLifecycleInterceptors() {		return this.currentConnection.getConnectionLifecycleInterceptors();	}	public synchronized boolean getContinueBatchOnError() {		return this.currentConnection.getContinueBatchOnError();	}	public synchronized boolean getCreateDatabaseIfNotExist() {		return this.currentConnection.getCreateDatabaseIfNotExist();	}	public synchronized int getDefaultFetchSize() {		return this.currentConnection.getDefaultFetchSize();	}	public synchronized boolean getDontTrackOpenResources() {		return this.currentConnection.getDontTrackOpenResources();	}	public synchronized boolean getDumpMetadataOnColumnNotFound() {		return this.currentConnection.getDumpMetadataOnColumnNotFound();	}	public synchronized boolean getDumpQueriesOnException() {		return this.currentConnection.getDumpQueriesOnException();	}	public synchronized boolean getDynamicCalendars() {		return this.currentConnection.getDynamicCalendars();	}	public synchronized boolean getElideSetAutoCommits() {		return this.currentConnection.getElideSetAutoCommits();	}	public synchronized boolean getEmptyStringsConvertToZero() {		return this.currentConnection.getEmptyStringsConvertToZero();	}	public synchronized boolean getEmulateLocators() {		return this.currentConnection.getEmulateLocators();	}	public synchronized boolean getEmulateUnsupportedPstmts() {		return this.currentConnection.getEmulateUnsupportedPstmts();	}	public synchronized boolean getEnablePacketDebug() {		return this.currentConnection.getEnablePacketDebug();	}	public synchronized boolean getEnableQueryTimeouts() {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -