44 lines
1.3 KiB
Java
44 lines
1.3 KiB
Java
package com.methods;
|
|
|
|
import com.main.Scheduler;
|
|
import java.sql.Connection;
|
|
import java.sql.DriverManager;
|
|
import org.apache.log4j.Logger;
|
|
|
|
public class Util {
|
|
static Logger log = Logger.getLogger(Scheduler.class.getName());
|
|
|
|
public static Connection getDBConnection() {
|
|
Connection dbConnection = null;
|
|
|
|
try {
|
|
Class.forName(Scheduler.prop.getProperty("DB_DRIVER"));
|
|
dbConnection =
|
|
DriverManager.getConnection(
|
|
Scheduler.prop.getProperty("DB_URL"),
|
|
Scheduler.prop.getProperty("DB_USER"),
|
|
Scheduler.prop.getProperty("DB_PWD"));
|
|
} catch (Exception e) {
|
|
log.error(String.valueOf(e.getMessage()) + " in Util class db connection error");
|
|
}
|
|
return dbConnection;
|
|
}
|
|
|
|
public static Connection getDBConnectionforAPI() {
|
|
Connection dbConnection = null;
|
|
|
|
try {
|
|
Class.forName(Scheduler.prop.getProperty("DB_DRIVER"));
|
|
dbConnection =
|
|
DriverManager.getConnection(
|
|
Scheduler.prop.getProperty("DB_URL_API"),
|
|
Scheduler.prop.getProperty("DB_USER_API"),
|
|
Scheduler.prop.getProperty("DB_PWD_API"));
|
|
} catch (Exception e) {
|
|
log.error(
|
|
String.valueOf(e.getMessage()) + " in Util class db connection error for API database");
|
|
}
|
|
return dbConnection;
|
|
}
|
|
}
|