packagecn.itheima.jdbc.DataSource;importjava.sql.Array;importjava.sql.Blob;importjava.sql.CallableStatement;importjava.sql.Clob;importjava.sql.Connection;importjava.sql.DatabaseMetaData;importjava.sql.NClob;importjava.sql.PreparedStatement;importjava.sql.SQLClientInfoException;importjava.sql.SQLException;importjava.sql.SQLWarning;importjava.sql.SQLXML;importjava.sql.Savepoint;importjava.sql.Statement;importjava.sql.Struct;importjava.util.LinkedList;importjava.util.Map;importjava.util.Properties;importjava.util.concurrent.Executor;//1.实现同一个接口Connection
public class MyConnection implementsConnection {//3.定义一个变量
privateConnection conn;private LinkedListpool;//2.编写一个构造方法(参数使用了面相对象的多态特性)
public MyConnection(Connection conn,LinkedListpool) {this.conn=conn;this.pool=pool;
}//4.书写需要增强的方法
@Overridepublic void close() throwsSQLException {
pool.add(conn);
}/*** 此方法必须覆盖!否则会出现空指针异常!!!*/@Overridepublic PreparedStatement prepareStatement(String sql) throwsSQLException {returnconn.prepareStatement(sql);
}
@Overridepublic T unwrap(Class iface) throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic boolean isWrapperFor(Class> iface) throwsSQLException {//TODO Auto-generated method stub
return false;
}
@Overridepublic Statement createStatement() throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic CallableStatement prepareCall(String sql) throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic String nativeSQL(String sql) throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic void setAutoCommit(boolean autoCommit) throwsSQLException {//TODO Auto-generated method stub
}
@Overridepublic boolean getAutoCommit() throwsSQLException {//TODO Auto-generated method stub
return false;
}
@Overridepublic void commit() throwsSQLException {//TODO Auto-generated method stub
}
@Overridepublic void rollback() throwsSQLException {//TODO Auto-generated method stub
}
@Overridepublic boolean isClosed() throwsSQLException {//TODO Auto-generated method stub
return false;
}
@Overridepublic DatabaseMetaData getMetaData() throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic void setReadOnly(boolean readOnly) throwsSQLException {//TODO Auto-generated method stub
}
@Overridepublic boolean isReadOnly() throwsSQLException {//TODO Auto-generated method stub
return false;
}
@Overridepublic void setCatalog(String catalog) throwsSQLException {//TODO Auto-generated method stub
}
@Overridepublic String getCatalog() throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic void setTransactionIsolation(int level) throwsSQLException {//TODO Auto-generated method stub
}
@Overridepublic int getTransactionIsolation() throwsSQLException {//TODO Auto-generated method stub
return 0;
}
@Overridepublic SQLWarning getWarnings() throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic void clearWarnings() throwsSQLException {//TODO Auto-generated method stub
}
@Overridepublic Statement createStatement(int resultSetType, int resultSetConcurrency) throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic PreparedStatement prepareStatement(String sql, int resultSetType, intresultSetConcurrency)throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic Map> getTypeMap() throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic void setTypeMap(Map> map) throwsSQLException {//TODO Auto-generated method stub
}
@Overridepublic void setHoldability(int holdability) throwsSQLException {//TODO Auto-generated method stub
}
@Overridepublic int getHoldability() throwsSQLException {//TODO Auto-generated method stub
return 0;
}
@Overridepublic Savepoint setSavepoint() throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic Savepoint setSavepoint(String name) throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic void rollback(Savepoint savepoint) throwsSQLException {//TODO Auto-generated method stub
}
@Overridepublic void releaseSavepoint(Savepoint savepoint) throwsSQLException {//TODO Auto-generated method stub
}
@Overridepublic Statement createStatement(int resultSetType, int resultSetConcurrency, intresultSetHoldability)throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic PreparedStatement prepareStatement(String sql, int resultSetType, intresultSetConcurrency,int resultSetHoldability) throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic CallableStatement prepareCall(String sql, int resultSetType, intresultSetConcurrency,int resultSetHoldability) throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic PreparedStatement prepareStatement(String sql, int[] columnIndexes) throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic PreparedStatement prepareStatement(String sql, String[] columnNames) throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic Clob createClob() throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic Blob createBlob() throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic NClob createNClob() throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic SQLXML createSQLXML() throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic boolean isValid(int timeout) throwsSQLException {//TODO Auto-generated method stub
return false;
}
@Overridepublic void setClientInfo(String name, String value) throwsSQLClientInfoException {//TODO Auto-generated method stub
}
@Overridepublic void setClientInfo(Properties properties) throwsSQLClientInfoException {//TODO Auto-generated method stub
}
@Overridepublic String getClientInfo(String name) throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic Properties getClientInfo() throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic Array createArrayOf(String typeName, Object[] elements) throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic Struct createStruct(String typeName, Object[] attributes) throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic void setSchema(String schema) throwsSQLException {//TODO Auto-generated method stub
}
@Overridepublic String getSchema() throwsSQLException {//TODO Auto-generated method stub
return null;
}
@Overridepublic void abort(Executor executor) throwsSQLException {//TODO Auto-generated method stub
}
@Overridepublic void setNetworkTimeout(Executor executor, int milliseconds) throwsSQLException {//TODO Auto-generated method stub
}
@Overridepublic int getNetworkTimeout() throwsSQLException {//TODO Auto-generated method stub
return 0;
}
}