2 * Copyright © 2017-2018 AT&T Intellectual Property.
\r
3 * Modifications Copyright © 2018 IBM.
\r
5 * Licensed under the Apache License, Version 2.0 (the "License");
\r
6 * you may not use this file except in compliance with the License.
\r
7 * You may obtain a copy of the License at
\r
9 * http://www.apache.org/licenses/LICENSE-2.0
\r
11 * Unless required by applicable law or agreed to in writing, software
\r
12 * distributed under the License is distributed on an "AS IS" BASIS,
\r
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
14 * See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
18 package org.onap.ccsdk.features.data.adaptor.db;
\r
20 import java.io.PrintWriter;
\r
21 import java.sql.Connection;
\r
22 import java.sql.SQLException;
\r
23 import java.sql.SQLFeatureNotSupportedException;
\r
24 import javax.sql.DataSource;
\r
25 import com.att.eelf.configuration.EELFLogger;
\r
26 import com.att.eelf.configuration.EELFManager;
\r
28 public class DataSourceWrap implements DataSource {
\r
30 private static EELFLogger logger = EELFManager.getInstance().getLogger(DataSourceWrap.class);
\r
32 private DataSource dataSource;
\r
34 public DataSourceWrap(DataSource dataSource) {
\r
35 logger.info("Setting Data Source {} ", dataSource);
\r
36 this.dataSource = dataSource;
\r
40 public PrintWriter getLogWriter() throws SQLException {
\r
41 return dataSource.getLogWriter();
\r
45 public void setLogWriter(PrintWriter out) throws SQLException {
\r
46 dataSource.setLogWriter(out);
\r
50 public void setLoginTimeout(int seconds) throws SQLException {
\r
51 dataSource.setLoginTimeout(seconds);
\r
55 public int getLoginTimeout() throws SQLException {
\r
56 return dataSource.getLoginTimeout();
\r
60 public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException {
\r
61 return dataSource.getParentLogger();
\r
65 public <T> T unwrap(Class<T> iface) throws SQLException {
\r
66 return dataSource.unwrap(iface);
\r
70 public boolean isWrapperFor(Class<?> iface) throws SQLException {
\r
71 return dataSource.isWrapperFor(iface);
\r
74 @SuppressWarnings("squid:S2095")
\r
76 public Connection getConnection() throws SQLException {
\r
77 Connection c = dataSource.getConnection();
\r
78 logger.trace("getConnection: ({})", c.getClass().getName());
\r
79 c.setAutoCommit(true);
\r
83 @SuppressWarnings("squid:S2095")
\r
85 public Connection getConnection(String username, String pass) throws SQLException {
\r
86 Connection c = dataSource.getConnection(username, pass);
\r
87 c.setAutoCommit(true);
\r