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;
022
023import java.io.PrintWriter;
024import java.sql.Connection;
025import java.sql.SQLException;
026import java.sql.SQLFeatureNotSupportedException;
027import java.util.logging.Logger;
028
029import javax.naming.NamingException;
030import javax.naming.Reference;
031
032/**
033 * @author Paul Ferraro
034 */
035public class DataSource extends CommonDataSourceProxy<javax.sql.DataSource> implements javax.sql.DataSource
036{
037        /**
038         * Constructs a new DataSource
039         */
040        public DataSource()
041        {
042                super(new DataSourceFactory());
043        }
044
045        /**
046         * @see javax.sql.DataSource#getConnection()
047         */
048        @Override
049        public Connection getConnection() throws SQLException
050        {
051                return this.getProxy().getConnection();
052        }
053
054        /**
055         * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String)
056         */
057        @Override
058        public Connection getConnection(String user, String password) throws SQLException
059        {
060                return this.getProxy().getConnection(user, password);
061        }
062
063        /**
064         * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
065         */
066        @Override
067        public boolean isWrapperFor(Class<?> targetClass) throws SQLException
068        {
069                return this.getProxy().isWrapperFor(targetClass);
070        }
071
072        /**
073         * @see java.sql.Wrapper#unwrap(java.lang.Class)
074         */
075        @Override
076        public <T> T unwrap(Class<T> targetClass) throws SQLException
077        {
078                return this.getProxy().unwrap(targetClass);
079        }
080
081        /**
082         * @see javax.sql.CommonDataSource#getLoginTimeout()
083         */
084        @Override
085        public int getLoginTimeout() throws SQLException
086        {
087                return this.getProxy().getLoginTimeout();
088        }
089
090        /**
091         * @see javax.sql.CommonDataSource#getLogWriter()
092         */
093        @Override
094        public PrintWriter getLogWriter() throws SQLException
095        {
096                return this.getProxy().getLogWriter();
097        }
098
099        /**
100         * @see javax.sql.CommonDataSource#setLoginTimeout(int)
101         */
102        @Override
103        public void setLoginTimeout(int timeout) throws SQLException
104        {
105                this.getProxy().setLoginTimeout(timeout);
106        }
107
108        /**
109         * @see javax.sql.CommonDataSource#setLogWriter(java.io.PrintWriter)
110         */
111        @Override
112        public void setLogWriter(PrintWriter writer) throws SQLException
113        {
114                this.getProxy().setLogWriter(writer);
115        }
116
117        /**
118         * @see javax.naming.Referenceable#getReference()
119         */
120        @Override
121        public Reference getReference() throws NamingException
122        {
123                return new DataSourceReference(this.getCluster(), this.getConfig());
124        }
125
126        public Logger getParentLogger() throws SQLFeatureNotSupportedException {
127            throw new SQLFeatureNotSupportedException();
128        }
129
130}