Skip to content

Commit fad8fd2

Browse files
authored
Add files via upload
1 parent 453d27f commit fad8fd2

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

DBSyncAgent.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,15 +400,17 @@ public void stopSync(){
400400

401401
/**
402402
* Disconnects the existing client and server connections safely.
403-
* Call this after calling {@link #stopSync()} if a {@link #liveSync()} is
404-
* in progress.
403+
* Call this method after calling {@link #stopSync()}.
405404
*/
406405
public void disconnect(){
407406

408407
try{
409408

410409
clientStatement.close();
411410
serverStatement.close();
411+
412+
clientConnection.close();
413+
serverConnection.close();
412414
}
413415

414416
catch(Exception e){

DBSynchronizer.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ private String getLastSyncTimestamp(String destinationTable,
121121

122122
lastSyncTimestamp = "0000-00-00 00:00:00";
123123
}
124+
125+
rs.close();
124126
}
125127

126128
catch (Exception e) {
@@ -146,7 +148,6 @@ private String generateSelectQuery(String table, ArrayList<AttributeMap> attribu
146148
selectQuery.append(" from ").append(table).append(" where ")
147149
.append(timestampAttribute).append(" > ")
148150
.append(" '").append(lastSyncTimestamp).append("'");
149-
System.out.println(selectQuery.toString());
150151
return selectQuery.toString();
151152
}
152153

@@ -177,7 +178,6 @@ private String generateUpdateQuery(ResultSet rs, String table, ArrayList<Attribu
177178
}
178179
}
179180
updateQuery.append(")");
180-
System.out.println(updateQuery.toString());
181181
return updateQuery.toString();
182182
}
183183

@@ -204,6 +204,8 @@ private void sync(){
204204
String updateQuery = generateUpdateQuery(serverResultSet, destinationTable, attributeMap);
205205
clientStatement.executeUpdate(updateQuery);
206206
}
207+
208+
serverResultSet.close();
207209
}
208210

209211
catch(Exception e){

0 commit comments

Comments
 (0)