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