mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 08:56:15 +00:00
Use try-with-resources for resource management.
This commit is contained in:
parent
294aa6c773
commit
98941ab783
@ -774,10 +774,8 @@ public class RdbmsCentralRepoFactory {
|
|||||||
* @return True if success, false otherwise.
|
* @return True if success, false otherwise.
|
||||||
*/
|
*/
|
||||||
private boolean insertDefaultAccountsTablesContent(Connection conn) {
|
private boolean insertDefaultAccountsTablesContent(Connection conn) {
|
||||||
Statement stmt = null;
|
|
||||||
try {
|
try (Statement stmt = conn.createStatement()) {
|
||||||
stmt = conn.createStatement();
|
|
||||||
|
|
||||||
// Populate the account_types table
|
// Populate the account_types table
|
||||||
for (Account.Type type : Account.Type.PREDEFINED_ACCOUNT_TYPES) {
|
for (Account.Type type : Account.Type.PREDEFINED_ACCOUNT_TYPES) {
|
||||||
int correlationTypeId = getCorrelationTypeIdForAccountType(conn, type);
|
int correlationTypeId = getCorrelationTypeIdForAccountType(conn, type);
|
||||||
@ -790,16 +788,8 @@ public class RdbmsCentralRepoFactory {
|
|||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
LOGGER.log(Level.SEVERE, String.format("Failed to populate default data in Accounts tables."), ex);
|
LOGGER.log(Level.SEVERE, String.format("Failed to populate default data in Accounts tables."), ex);
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
}
|
||||||
if (stmt != null) {
|
|
||||||
try {
|
|
||||||
stmt.close();
|
|
||||||
} catch (SQLException ex2) {
|
|
||||||
LOGGER.log(Level.SEVERE, "Error closing statement.", ex2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -812,10 +802,7 @@ public class RdbmsCentralRepoFactory {
|
|||||||
*/
|
*/
|
||||||
private boolean insertDefaultPersonaTablesContent(Connection conn) {
|
private boolean insertDefaultPersonaTablesContent(Connection conn) {
|
||||||
|
|
||||||
Statement stmt = null;
|
try (Statement stmt = conn.createStatement()) {
|
||||||
try {
|
|
||||||
stmt = conn.createStatement();
|
|
||||||
|
|
||||||
// populate the confidence table
|
// populate the confidence table
|
||||||
for (Confidence confidence : Persona.Confidence.values()) {
|
for (Confidence confidence : Persona.Confidence.values()) {
|
||||||
String sqlString = "INSERT INTO confidence (confidence_id, description) VALUES ( " + confidence.getLevel() + ", '" + confidence.toString() + "')" //NON-NLS
|
String sqlString = "INSERT INTO confidence (confidence_id, description) VALUES ( " + confidence.getLevel() + ", '" + confidence.toString() + "')" //NON-NLS
|
||||||
@ -833,16 +820,8 @@ public class RdbmsCentralRepoFactory {
|
|||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
LOGGER.log(Level.SEVERE, String.format("Failed to populate default data in Persona tables."), ex);
|
LOGGER.log(Level.SEVERE, String.format("Failed to populate default data in Persona tables."), ex);
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
}
|
||||||
if (stmt != null) {
|
|
||||||
try {
|
|
||||||
stmt.close();
|
|
||||||
} catch (SQLException ex2) {
|
|
||||||
LOGGER.log(Level.SEVERE, "Error closing statement.", ex2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user