\r
private static String DB_URL;\r
private static String DB_LOGIN;\r
private static String DB_PASSWORD;\r
private static Properties props;\r
\r
private static String DB_URL;\r
private static String DB_LOGIN;\r
private static String DB_PASSWORD;\r
private static Properties props;\r
private static final Queue<Connection> queue = new LinkedList<>();\r
\r
public static String HTTPS_PORT;\r
public static String HTTP_PORT;\r
\r
/**\r
private static final Queue<Connection> queue = new LinkedList<>();\r
\r
public static String HTTPS_PORT;\r
public static String HTTP_PORT;\r
\r
/**\r
- * Construct a DB object. If this is the very first creation of this object, it will load a copy\r
- * of the properties for the server, and attempt to load the JDBC driver for the database. If a fatal\r
- * error occurs (e.g. either the properties file or the DB driver is missing), the JVM will exit.\r
+ * Construct a DB object. If this is the very first creation of this object, it will load a copy of the properties\r
+ * for the server, and attempt to load the JDBC driver for the database. If a fatal error occurs (e.g. either the\r
+ * properties file or the DB driver is missing), the JVM will exit.\r
- try (InputStream inStream = getClass().getClassLoader().getResourceAsStream(CONFIG_FILE)) {\r
- props.load(inStream);\r
+ try {\r
+ props.load(new FileInputStream(System.getProperty(\r
+ "org.onap.dmaap.datarouter.provserver.properties",\r
+ "/opt/app/datartr/etc/provserver.properties")));\r
String DB_DRIVER = (String) props.get("org.onap.dmaap.datarouter.db.driver");\r
DB_URL = (String) props.get("org.onap.dmaap.datarouter.db.url");\r
DB_LOGIN = (String) props.get("org.onap.dmaap.datarouter.db.login");\r
String DB_DRIVER = (String) props.get("org.onap.dmaap.datarouter.db.driver");\r
DB_URL = (String) props.get("org.onap.dmaap.datarouter.db.url");\r
DB_LOGIN = (String) props.get("org.onap.dmaap.datarouter.db.login");\r
* Get a JDBC connection to the DB from the pool. Creates a new one if none are available.\r
*\r
* @return the Connection\r
* Get a JDBC connection to the DB from the pool. Creates a new one if none are available.\r
*\r
* @return the Connection\r
try {\r
connection = DriverManager.getConnection(DB_URL, DB_LOGIN, DB_PASSWORD);\r
} catch (SQLException sqlEx) {\r
try {\r
connection = DriverManager.getConnection(DB_URL, DB_LOGIN, DB_PASSWORD);\r
} catch (SQLException sqlEx) {\r
- * Run all necessary retrofits required to bring the database up to the level required for this version\r
- * of the provisioning server. This should be run before the server itself is started.\r
+ * Run all necessary retrofits required to bring the database up to the level required for this version of the\r
+ * provisioning server. This should be run before the server itself is started.\r
*\r
* @return true if the retrofit worked, false otherwise\r
*/\r
private boolean retroFit1() {\r
final String[] expectedTables = {\r
*\r
* @return true if the retrofit worked, false otherwise\r
*/\r
private boolean retroFit1() {\r
final String[] expectedTables = {\r
- "FEEDS", "FEED_ENDPOINT_ADDRS", "FEED_ENDPOINT_IDS", "PARAMETERS",\r
- "SUBSCRIPTIONS", "LOG_RECORDS", "INGRESS_ROUTES", "EGRESS_ROUTES",\r
- "NETWORK_ROUTES", "NODESETS", "NODES", "GROUPS"\r
+ "FEEDS", "FEED_ENDPOINT_ADDRS", "FEED_ENDPOINT_IDS", "PARAMETERS",\r
+ "SUBSCRIPTIONS", "LOG_RECORDS", "INGRESS_ROUTES", "EGRESS_ROUTES",\r
+ "NETWORK_ROUTES", "NODESETS", "NODES", "GROUPS"\r
Set<String> actualTables = getTableSet(connection);\r
boolean initialize = false;\r
for (String table : expectedTables) {\r
Set<String> actualTables = getTableSet(connection);\r
boolean initialize = false;\r
for (String table : expectedTables) {\r
- ResultSet rs = md.getTables("datarouter", "", "", null);\r
+ ResultSet rs = md.getTables(null, null, "%", null);\r
- * Initialize the tables by running the initialization scripts located in the directory specified\r
- * by the property <i>org.onap.dmaap.datarouter.provserver.dbscripts</i>. Scripts have names of\r
- * the form sql_init_NN.sql\r
+ * Initialize the tables by running the initialization scripts located in the directory specified by the property\r
+ * <i>org.onap.dmaap.datarouter.provserver.dbscripts</i>. Scripts have names of the form sql_init_NN.sql\r
*/\r
private void runInitScript(Connection connection, int scriptId) {\r
String scriptDir = (String) props.get("org.onap.dmaap.datarouter.provserver.dbscripts");\r
*/\r
private void runInitScript(Connection connection, int scriptId) {\r
String scriptDir = (String) props.get("org.onap.dmaap.datarouter.provserver.dbscripts");\r
- if (!(new File(scriptFile)).exists())\r
- return;\r
-\r
- LineNumberReader in = new LineNumberReader(new FileReader(scriptFile));\r
+ if (!(new File(scriptFile)).exists()) {\r
+ intlogger.fatal("PROV9005 Failed to load sql script from : " + scriptFile);\r
+ System.exit(1);\r
+ }\r
+ LineNumberReader lineReader = new LineNumberReader(new FileReader(scriptFile));\r
- String sql = sb.toString();\r
- sb.setLength(0);\r
- Statement s = connection.createStatement();\r
- s.execute(sql);\r
- s.close();\r
+ String sql = strBuilder.toString();\r
+ strBuilder.setLength(0);\r
+ Statement statement = connection.createStatement();\r
+ statement.execute(sql);\r
+ statement.close();\r
} catch (Exception e) {\r
intlogger.fatal("PROV9002 Error when initializing table: " + e.getMessage());\r
System.exit(1);\r
} catch (Exception e) {\r
intlogger.fatal("PROV9002 Error when initializing table: " + e.getMessage());\r
System.exit(1);\r