001/* 002 * HA-JDBC: High-Availability JDBC 003 * Copyright (c) 2004-2008 Paul Ferraro 004 * 005 * This library is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU Lesser General Public License as published by the 007 * Free Software Foundation; either version 2.1 of the License, or (at your 008 * option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, but WITHOUT 011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 013 * for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public License 016 * along with this library; if not, write to the Free Software Foundation, 017 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 018 * 019 * Contact: ferraro@users.sourceforge.net 020 */ 021package net.sf.hajdbc.sql.pool; 022 023import java.io.PrintWriter; 024import java.sql.SQLException; 025import java.sql.SQLFeatureNotSupportedException; 026import java.util.logging.Logger; 027 028import javax.naming.NamingException; 029import javax.naming.Reference; 030import javax.sql.PooledConnection; 031 032import net.sf.hajdbc.sql.CommonDataSourceProxy; 033 034/** 035 * @author Paul Ferraro 036 * 037 */ 038public class ConnectionPoolDataSource extends CommonDataSourceProxy<javax.sql.ConnectionPoolDataSource> implements javax.sql.ConnectionPoolDataSource 039{ 040 /** 041 * Constructs a new ConnectionPoolDataSource 042 */ 043 public ConnectionPoolDataSource() 044 { 045 super(new ConnectionPoolDataSourceFactory()); 046 } 047 048 /** 049 * @see javax.sql.ConnectionPoolDataSource#getPooledConnection() 050 */ 051 @Override 052 public PooledConnection getPooledConnection() throws SQLException 053 { 054 return this.getProxy().getPooledConnection(); 055 } 056 057 /** 058 * @see javax.sql.ConnectionPoolDataSource#getPooledConnection(java.lang.String, java.lang.String) 059 */ 060 @Override 061 public PooledConnection getPooledConnection(String user, String password) throws SQLException 062 { 063 return this.getProxy().getPooledConnection(user, password); 064 } 065 066 /** 067 * @see javax.sql.CommonDataSource#getLoginTimeout() 068 */ 069 @Override 070 public int getLoginTimeout() throws SQLException 071 { 072 return this.getProxy().getLoginTimeout(); 073 } 074 075 /** 076 * @see javax.sql.CommonDataSource#getLogWriter() 077 */ 078 @Override 079 public PrintWriter getLogWriter() throws SQLException 080 { 081 return this.getProxy().getLogWriter(); 082 } 083 084 /** 085 * @see javax.sql.CommonDataSource#setLoginTimeout(int) 086 */ 087 @Override 088 public void setLoginTimeout(int timeout) throws SQLException 089 { 090 this.getProxy().setLoginTimeout(timeout); 091 } 092 093 /** 094 * @see javax.sql.CommonDataSource#setLogWriter(java.io.PrintWriter) 095 */ 096 @Override 097 public void setLogWriter(PrintWriter writer) throws SQLException 098 { 099 this.getProxy().setLogWriter(writer); 100 } 101 102 /** 103 * @see javax.naming.Referenceable#getReference() 104 */ 105 @Override 106 public Reference getReference() throws NamingException 107 { 108 return new ConnectionPoolDataSourceReference(this.getCluster(), this.getConfig()); 109 } 110 111 public Logger getParentLogger() throws SQLFeatureNotSupportedException { 112 throw new SQLFeatureNotSupportedException(); 113 } 114 115}