2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * =============================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
20 * ============LICENSE_END=========================================================
23 package org.onap.appc.encryptiontool.wrapper;
27 import java.sql.SQLException;
28 import java.util.ArrayList;
29 import java.util.Properties;
31 import javax.sql.rowset.CachedRowSet;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
36 import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
38 public class DbServiceUtil
40 private static final Logger log = LoggerFactory
41 .getLogger(DbServiceUtil.class);
43 private static Properties props;
44 private static DBResourceManager jdbcDataSource = null;
46 public static boolean updateDB(String tableName, ArrayList inputArgs,
47 String scema, String whereClause, String setCluase) throws SQLException
49 String updatePasswordString = "update " + tableName + " set " + setCluase + " where " + whereClause ;
50 boolean result = jdbcDataSource.writeData(updatePasswordString, inputArgs,Constants.SCHEMA_SDNCTL);
54 public static CachedRowSet getData(String tableName, ArrayList argList, String schema,
55 String getselectData, String getDataClasue ) throws SQLException
57 String selectQuery = "select " + getselectData + "from " + tableName + " where " + getDataClasue ;
58 CachedRowSet data = jdbcDataSource.getData(selectQuery, argList, schema);
63 public static DBResourceManager initDbLibService() throws Exception
65 props = new Properties();
66 File file = new File("/opt/app/bvc/properties/dblib.properties");
67 URL propURL = file.toURI().toURL();
68 props.load(propURL.openStream());
69 jdbcDataSource = new DBResourceManager(props);
70 return jdbcDataSource;