Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close connection in some AccountingDataStore methods #343

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class AccountingDataStore {
protected static final String USAGE_COL = "usage";
protected static final String DEFAULT_DATASTORE_NAME = "datastore_accounting.slite";
protected static final String ERROR_WHILE_INITIALIZING_THE_DATA_STORE =
"Error while initializing the Accouting DataStore.";
"Error while initializing the Accounting DataStore.";

private String dataStoreURL;

Expand All @@ -54,7 +54,6 @@ public AccountingDataStore(Properties properties, String defaultDatastoreNamePre
+ "usage DOUBLE,"
+ "PRIMARY KEY (user, requesting_member, providing_member)"
+ ")");
statement.close();
} catch (Exception e) {
LOGGER.error(ERROR_WHILE_INITIALIZING_THE_DATA_STORE, e);
throw new Error(ERROR_WHILE_INITIALIZING_THE_DATA_STORE, e);
Expand Down Expand Up @@ -201,11 +200,13 @@ private List<AccountingEntryKey> getEntryKeys() {
} catch (SQLException e) {
LOGGER.error("Couldn't get keys from DB.", e);
return null;
} finally {
close(statement, conn);
}
}

public List<AccountingInfo> getAccountingInfo() {
LOGGER.debug("Getting AccounintgInfo...");
LOGGER.debug("Getting AccountingInfo...");
Statement statement = null;
Connection conn = null;
try {
Expand All @@ -217,7 +218,9 @@ public List<AccountingInfo> getAccountingInfo() {
} catch (SQLException e) {
LOGGER.error("Couldn't get keys from DB.", e);
return null;
}
} finally {
close(statement, conn);
}
}

private static final String SELECT_SPECIFIC_USAGE_SQL = "SELECT * FROM " + USAGE_TABLE_NAME
Expand Down Expand Up @@ -384,7 +387,7 @@ public int hashCode() {

@Override
public String toString() {
return "user=" + user + "; requestigMember=" + requestingMember + "; providingMember="
return "user=" + user + "; requestingMember=" + requestingMember + "; providingMember="
+ providingMember;
}
}