Skip to content

Commit

Permalink
revert the changes; the connection don't need to be shared; #2
Browse files Browse the repository at this point in the history
  • Loading branch information
QianSwirlds committed Jul 31, 2019
1 parent 3945d99 commit 3846c00
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static boolean processFile(File balanceFile) {

try {
// process the file
connect = DatabaseUtilities.getConnection();
connect = DatabaseUtilities.openDatabase(connect);

if (connect != null) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static void main(String[] args) {
File balanceFile = getLatestBalancefile(balanceFilesPath);
if (balanceFile != null) {
// process the file
connect = DatabaseUtilities.getConnection();
connect = DatabaseUtilities.openDatabase(connect);

if (connect != null) {
PreparedStatement insertBalance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
public class DatabaseUtilities {
private static final Logger log = LogManager.getLogger("recordStream-log");
static final Marker LOGM_EXCEPTION = MarkerManager.getMarker("EXCEPTION");
private static Connection connect = null;

public static Connection getConnection() {
public static Connection openDatabase(Connection connect) {
if (connect == null) {
try {
ConfigLoader configLoader = new ConfigLoader("./config/config.json");
Expand All @@ -35,8 +34,8 @@ public static Connection getConnection() {
return connect;
}

public static void closeDatabase() throws SQLException {
public static Connection closeDatabase(Connection connect) throws SQLException {
connect.close();
connect = null;
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ enum F_ENTITIES {
}

public static boolean start() {
connect = DatabaseUtilities.getConnection();
connect = DatabaseUtilities.openDatabase(connect);
if (connect == null) {
return false;
}
return true;
}
public static boolean finish() {
try {
DatabaseUtilities.closeDatabase();
connect = DatabaseUtilities.closeDatabase(connect);
return false;
} catch (SQLException e) {
log.error(LOGM_EXCEPTION, "Exception {}", e);
Expand Down

0 comments on commit 3846c00

Please sign in to comment.