2  * Copyright © 2017-2018 AT&T Intellectual Property.
\r 
   4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
\r 
   5  * in compliance with the License. You may obtain a copy of the License at
\r 
   7  * http://www.apache.org/licenses/LICENSE-2.0
\r 
   9  * Unless required by applicable law or agreed to in writing, software distributed under the License
\r 
  10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
\r 
  11  * or implied. See the License for the specific language governing permissions and limitations under
\r 
  15 package org.onap.ccsdk.config.data.adaptor.db;
\r 
  17 import java.io.PrintWriter;
\r 
  18 import java.sql.Connection;
\r 
  19 import java.sql.SQLException;
\r 
  20 import java.sql.SQLFeatureNotSupportedException;
\r 
  21 import javax.sql.DataSource;
\r 
  22 import com.att.eelf.configuration.EELFLogger;
\r 
  23 import com.att.eelf.configuration.EELFManager;
\r 
  25 public class DataSourceWrap implements DataSource {
\r 
  27     private static EELFLogger logger = EELFManager.getInstance().getLogger(DataSourceWrap.class);
\r 
  29     private DataSource dataSource;
\r 
  31     public DataSourceWrap(DataSource dataSource) {
\r 
  32         logger.info("Setting Data Source {} ", dataSource);
\r 
  33         this.dataSource = dataSource;
\r 
  37     public PrintWriter getLogWriter() throws SQLException {
\r 
  38         return dataSource.getLogWriter();
\r 
  42     public void setLogWriter(PrintWriter out) throws SQLException {
\r 
  43         dataSource.setLogWriter(out);
\r 
  47     public void setLoginTimeout(int seconds) throws SQLException {
\r 
  48         dataSource.setLoginTimeout(seconds);
\r 
  52     public int getLoginTimeout() throws SQLException {
\r 
  53         return dataSource.getLoginTimeout();
\r 
  57     public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException {
\r 
  58         return dataSource.getParentLogger();
\r 
  62     public <T> T unwrap(Class<T> iface) throws SQLException {
\r 
  63         return dataSource.unwrap(iface);
\r 
  67     public boolean isWrapperFor(Class<?> iface) throws SQLException {
\r 
  68         return dataSource.isWrapperFor(iface);
\r 
  71     @SuppressWarnings("squid:S2095")
\r 
  73     public Connection getConnection() throws SQLException {
\r 
  74         Connection c = dataSource.getConnection();
\r 
  75         logger.trace("getConnection: ({})", c.getClass().getName());
\r 
  76         c.setAutoCommit(true);
\r 
  80     @SuppressWarnings("squid:S2095")
\r 
  82     public Connection getConnection(String username, String pass) throws SQLException {
\r 
  83         Connection c = dataSource.getConnection(username, pass);
\r 
  84         c.setAutoCommit(true);
\r