@@ -0,0 +1,2178 @@
+/*%0A * Copyright 2006 Chris Wareham%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage net.rkbloom.logdriver;%0A%0Aimport org.apache.log4j.Logger;%0A%0Aimport java.io.PrintWriter;%0Aimport java.sql.Connection;%0Aimport java.sql.SQLException;%0Aimport javax.sql.DataSource;%0A%0A/**%0A * LogDataSource%0A * @version $Rev$%0A */%0Apublic class LogDataSource implements DataSource %7B%0A%09/** The logger. */%0A%09private static Logger logger = Logger.getLogger(LogDataSource.class);%0A%0A%09/** The data source to delegate to. */%0A%09private DataSource dataSource;%0A%0A%09/**%0A%09 * Creates a new instance of the LogDataSource class.%0A%09 *%0A%09 * @param ds the data source to delegate to.%0A%09 */%0A%09public LogDataSource(DataSource ds) %7B%0A%09%09dataSource = ds;%0A%09%7D%0A%0A%09/**%0A%09 * %7B@inheritDoc%7D%0A%09 */%0A%09public Connection getConnection() throws SQLException %7B%0A%09%09return new LogConnection(dataSource.getConnection());%0A%09%7D%0A%0A%09/**%0A%09 * %7B@inheritDoc%7D%0A%09 */%0A%09public Connection getConnection(String username, String password) throws SQLException %7B%0A%09%09return new LogConnection(dataSource.getConnection(username, password));%0A%09%7D%0A%0A%09/**%0A%09 * %7B@inheritDoc%7D%0A%09 */%0A%09public int getLoginTimeout() throws SQLException %7B%0A%09%09return dataSource.getLoginTimeout();%0A%09%7D%0A%0A%09/**%0A%09 * %7B@inheritDoc%7D%0A%09 */%0A%09public void setLoginTimeout(int seconds) throws SQLException %7B%0A%09%09logger.debug(%22Setting login timeout to %22 + seconds + %22 seconds%22);%0A%09%09dataSource.setLoginTimeout(seconds);%0A%09%7D%0A%0A%09/**%0A%09 * %7B@inheritDoc%7D%0A%09 */%0A%09public PrintWriter getLogWriter() throws SQLException %7B%0A%09%09return dataSource.getLogWriter();%0A%09%7D%0A%0A%09/**%0A%09 * %7B@inheritDoc%7D%0A%09 */%0A%09public void setLogWriter(PrintWriter out) throws SQLException %7B%0A%09%09logger.debug(%22Setting log writer to %22 + out);%0A%09%09dataSource.setLogWriter(out);%0A%09%7D%0A%7D%0A%0A

Add a LogDataSource class. This allows the jdbcLogDriver to be used with the DataSource implementation instead of the DriverManager.