Java hosting - JavaSercer Pages public void clearWarnings( ) throws SQLException
JavaSercer Pages public void clearWarnings( ) throws SQLException { if (isClosed) { throw new SQLException(”Pooled connection is closed”); } realConn.clearWarnings( ); } … } An instance of this class is associated with a real Connection object, retrieved from a connection pool, through the constructor. The constructor also provides a reference to the DataSourceWrapper instance that creates it, described next. The ConnectionWrapper class implements the Connection interface. The implementations of all the methods except two simply relay the call to the real Connection object so it can perform the requested database operation. The implementation of the close( ) method, however, doesn’t call the real Connect object’s method. Instead, it calls the DataSourceWrapper object’s return-Connection( ) method, to return the Connection to the pool. The isClosed( ) method, finally, returns the state of the ConnectionWrapper object as opposed to the real Connection object. Example 17.2 shows how the com.ora.jsp.sql.DataSourceWrapper gets a connection from a pool, and returns it when the pool client is done with it. Example 17.2. The DataSourceWrapper Class package com.ora.jsp.sql; import java.io.*; import java.sql.*; import javax.sql.*; public class DataSourceWrapper implements DataSource { private ConnectionPool pool; public DataSourceWrapper(String driverClass, String url, String user, String pw) throws ClassNotFoundException, InstantiationException, SQLException, IllegalAccessException { pool = new ConnectionPool(url, user, pw, driverClass, 1, 1); } /** * Gets a connection from the pool and returns it wrapped in * a ConnectionWrapper. */ public Connection getConnection( ) throws SQLException { return new ConnectionWrapper(pool.getConnection( ), this); } /** * Returns a Connection to the pool. This method is called by * the ConnectionWrapper’s close( ) method. */ public void returnConnection(Connection conn) { pool.returnConnection(conn); } /** * Always throws a SQLException. Username and password are set * in the constructor and can not be changed. */ public Connection getConnection(String username, String password) throws SQLException { throw new SQLException(”Not supported”); } public int getLoginTimeout( ) throws SQLException { throw new SQLException(”Not supported”); } public PrintWriter getLogWriter( ) throws SQLException { throw new SQLException(”Not supported”); } public void setLoginTimeout(int seconds) throws SQLException { throw new SQLException(”Not supported”); } public synchronized void setLogWriter(PrintWriter out) throws SQLException { throw new SQLException(”Not supported”); } } page 239
Note: If you are looking for good and quality webspace to host and run your java application check professional java hosting services