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

📄 connectioncoat.java

📁 用java编写的一个连接池的程序
💻 JAVA
字号:
package Pool;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Savepoint;
import java.sql.Statement;
import java.util.Map;

public class ConnectionCoat implements Connection {

	protected Connection conn;

	public ConnectionCoat(Connection conn)

	{

		this.conn = conn; // 实际从数据库获得的Connection引用

	}

	/**
	 * 此方法将被子类覆盖,以实现数据库连接池的连接返回操作
	 * 
	 */

	public void close() throws SQLException

	{

		this.conn.close();

	}

	public void commit() throws SQLException

	{

		this.conn.commit();// 调用实际连接的commit方法

	}

	public void clearWarnings() throws SQLException {
		this.conn.clearWarnings();

	}

	public Statement createStatement() throws SQLException {

		return this.conn.createStatement();
	}

	public Statement createStatement(int resultSetType, int resultSetConcurrency)
			throws SQLException {

		return this.conn.createStatement(resultSetType, resultSetConcurrency);
	}

	public Statement createStatement(int resultSetType,
			int resultSetConcurrency, int resultSetHoldability)
			throws SQLException {

		return this.conn.createStatement(resultSetType, resultSetConcurrency,
				resultSetHoldability);
	}

	public boolean getAutoCommit() throws SQLException {

		return this.conn.getAutoCommit();
	}

	public String getCatalog() throws SQLException {

		return this.conn.getCatalog();
	}

	public int getHoldability() throws SQLException {

		return this.conn.getHoldability();
	}

	public DatabaseMetaData getMetaData() throws SQLException {

		return this.conn.getMetaData();
	}

	public int getTransactionIsolation() throws SQLException {

		return this.conn.getTransactionIsolation();
	}

	public Map getTypeMap() throws SQLException {

		return this.conn.getTypeMap();
	}

	public SQLWarning getWarnings() throws SQLException {

		return this.conn.getWarnings();
	}

	public boolean isClosed() throws SQLException {

		return this.conn.isClosed();
	}

	public boolean isReadOnly() throws SQLException {

		return this.conn.isReadOnly();
	}

	public String nativeSQL(String sql) throws SQLException {

		return this.conn.nativeSQL(sql);
	}

	public CallableStatement prepareCall(String sql) throws SQLException {

		return this.conn.prepareCall(sql);
	}

	public CallableStatement prepareCall(String sql, int resultSetType,
			int resultSetConcurrency) throws SQLException {

		return this.conn.prepareCall(sql, resultSetType, resultSetConcurrency);
	}

	public CallableStatement prepareCall(String sql, int resultSetType,
			int resultSetConcurrency, int resultSetHoldability)
			throws SQLException {

		return this.conn.prepareCall(sql, resultSetType, resultSetConcurrency,
				resultSetHoldability);
	}

	public PreparedStatement prepareStatement(String sql) throws SQLException {

		return this.conn.prepareStatement(sql);
	}

	public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
			throws SQLException {

		return this.conn.prepareStatement(sql, autoGeneratedKeys);
	}

	public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
			throws SQLException {

		return this.conn.prepareStatement(sql, columnIndexes);
	}

	public PreparedStatement prepareStatement(String sql, String[] columnNames)
			throws SQLException {

		return this.conn.prepareStatement(sql, columnNames);
	}

	public PreparedStatement prepareStatement(String sql, int resultSetType,
			int resultSetConcurrency) throws SQLException {

		return this.conn.prepareStatement(sql, resultSetType,
				resultSetConcurrency);
	}

	public PreparedStatement prepareStatement(String sql, int resultSetType,
			int resultSetConcurrency, int resultSetHoldability)
			throws SQLException {

		return this.conn.prepareStatement(sql, resultSetType,
				resultSetConcurrency, resultSetHoldability);
	}

	public void releaseSavepoint(Savepoint savepoint) throws SQLException {
		this.conn.releaseSavepoint(savepoint);

	}

	public void rollback() throws SQLException {
		this.conn.rollback();

	}

	public void rollback(Savepoint savepoint) throws SQLException {
		this.conn.rollback(savepoint);

	}

	public void setAutoCommit(boolean autoCommit) throws SQLException {
		this.conn.setAutoCommit(autoCommit);

	}

	public void setCatalog(String catalog) throws SQLException {
		this.conn.setCatalog(catalog);

	}

	public void setHoldability(int holdability) throws SQLException {
		this.conn.setHoldability(holdability);

	}

	public void setReadOnly(boolean readOnly) throws SQLException {
		this.conn.setReadOnly(readOnly);

	}

	public Savepoint setSavepoint() throws SQLException {

		return this.conn.setSavepoint();
	}

	public Savepoint setSavepoint(String name) throws SQLException {

		return this.conn.setSavepoint(name);
	}

	public void setTransactionIsolation(int level) throws SQLException {
		this.conn.setTransactionIsolation(level);

	}

	public void setTypeMap(Map map) throws SQLException {
		this.conn.setTypeMap(map);

	}

}

⌨️ 快捷键说明

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