diff --git a/bindings/java/src/org/sleuthkit/datamodel/Bundle.properties b/bindings/java/src/org/sleuthkit/datamodel/Bundle.properties index 1a57d0602a6374c349b6a445876481f8a60f99a0..12ed6f13ad18a9453d5628689f2b6c2e84bd5a21 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/Bundle.properties +++ b/bindings/java/src/org/sleuthkit/datamodel/Bundle.properties @@ -163,7 +163,6 @@ SleuthkitCase.addLocalFile.exception.msg1.text=Error adding local file\: {0}, pa SleuthkitCase.addLocalFile.exception.msg2.text=Error creating a local file, cannot get new id of the object, file name\: {0} SleuthkitCase.addLocalFile.exception.msg3.text=Error creating a derived file, file name\: {0} SleuthkitCase.getLastObjectId.exception.msg.text=Error closing result set after getting last object id. -SleuthkitCase.CouldNotCompleteDatabaseOperation=Could not complete the database operation TskData.tskFsNameFlagEnum.allocated=Allocated TskData.tskFsNameFlagEnum.unallocated=Unallocated TskData.tskFsMetaFlagEnum.allocated=Allocated diff --git a/bindings/java/src/org/sleuthkit/datamodel/CaseDbConnectionInfo.java b/bindings/java/src/org/sleuthkit/datamodel/CaseDbConnectionInfo.java index 47f8909126b3cf5dbf9bb62068bd6f193d3a3f6f..1a1c7ee387dcdfed67dba65f6b07650e8cd48054 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/CaseDbConnectionInfo.java +++ b/bindings/java/src/org/sleuthkit/datamodel/CaseDbConnectionInfo.java @@ -47,9 +47,6 @@ public CaseDbConnectionInfo(String hostNameOrIP, String portNumber, String userN this.userName = userName; this.password = password; this.dbType = dbType; - if (this.dbType == DbType.SQLITE) { - logger.log(Level.WARNING, "Bad remote database case type!"); - } } public DbType getDbType() { diff --git a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java index e2e866c48c33fbfae0cc94324bccddf359c3f3e1..971c082f6d57e383821e87af4033ffbe00f85721 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java +++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java @@ -78,7 +78,6 @@ public class SleuthkitCase { private final Map<Long, Long> carvedFileContainersCache = new HashMap<Long, Long>(); // Caches the IDs of the root $CarvedFiles for each volume. private final Map<Long, FileSystem> fileSystemIdMap = new HashMap<Long, FileSystem>(); // Cache for file system results. private static final ArrayList<ErrorObserver> sleuthkitCaseErrorObservers = new ArrayList<ErrorObserver>(); - private static final int SLEEP_LENGTH_IN_MILLISECONDS = 50; private final String dbPath; private final DbType dbType; private final String caseDirPath; @@ -4616,7 +4615,7 @@ public static void removeErrorObserver(ErrorObserver observer) { * types of errors. * @param errorMessage A description of the error that occurred. */ - static void notifyError(Exception ex) { + private static void notifyError(Exception ex) { for (ErrorObserver observer : sleuthkitCaseErrorObservers) { if (observer != null) { try { @@ -5303,8 +5302,8 @@ protected interface DbCommand { void execute() throws SQLException; } - protected static final int MAX_RETRIES = 5; - + static final int SLEEP_LENGTH_IN_MILLISECONDS = 50; + final static class CreateStatement implements DbCommand { private final Connection connection; @@ -5607,8 +5606,12 @@ PreparedStatement getPreparedStatement(PREPARED_STATEMENT statementKey, int gene return statement; } - abstract PreparedStatement prepareStatement(String sqlStatement, int generateKeys) throws SQLException; - + PreparedStatement prepareStatement(String sqlStatement, int generateKeys) throws SQLException { + PrepareStatement prepareStatement = new PrepareStatement(this.getConnection(), sqlStatement); + executeCommand(prepareStatement); + return prepareStatement.getPreparedStatement(); + } + Statement createStatement() throws SQLException { CreateStatement createStatement = new CreateStatement(this.connection); executeCommand(createStatement); @@ -5684,8 +5687,11 @@ void executeUpdate(Statement statement, String update) throws SQLException { executeUpdate(statement, update, Statement.NO_GENERATED_KEYS); } - abstract void executeUpdate(Statement statement, String update, int generateKeys) throws SQLException; - + void executeUpdate(Statement statement, String update, int generateKeys) throws SQLException { + ExecuteStatementUpdate executeStatementUpdate = new ExecuteStatementUpdate(statement, update); + executeCommand(executeStatementUpdate); + } + void executeUpdate(PreparedStatement statement) throws SQLException { ExecutePreparedStatementUpdate executePreparedStatementUpdate = new ExecutePreparedStatementUpdate(statement); executeCommand(executePreparedStatementUpdate); @@ -5719,19 +5725,6 @@ private static final class SQLiteConnection extends CaseDbConnection { super(createConnection(dbPath)); } - @Override - void executeUpdate(Statement statement, String update, int generateKeys) throws SQLException { - ExecuteStatementUpdate executeStatementUpdate = new ExecuteStatementUpdate(statement, update); - executeCommand(executeStatementUpdate); - } - - @Override - PreparedStatement prepareStatement(String sqlStatement, int generateKeys) throws SQLException { - PrepareStatement prepareStatement = new PrepareStatement(this.getConnection(), sqlStatement); - executeCommand(prepareStatement); - return prepareStatement.getPreparedStatement(); - } - static Connection createConnection(String dbPath) { Connection connection = null; try { @@ -5785,7 +5778,7 @@ void executeCommand(DbCommand command) throws SQLException { // locked issue and we will retry. Thread.sleep(SLEEP_LENGTH_IN_MILLISECONDS); } catch (InterruptedException exp) { - Logger.getLogger(SleuthkitCase.class.getName()).log(Level.WARNING, "Enexpectedly unable to wait for database.", exp); + Logger.getLogger(SleuthkitCase.class.getName()).log(Level.WARNING, "Unexpectedly unable to wait for database.", exp); } } else { notifyError(ex); @@ -5804,7 +5797,8 @@ private static final class PostgreSQLConnection extends CaseDbConnection { private static final String COMMUNICATION_ERROR = PSQLState.COMMUNICATION_ERROR.getState(); private static final String SYSTEM_ERROR = PSQLState.SYSTEM_ERROR.getState(); private static final String UNKNOWN_STATE = PSQLState.UNKNOWN_STATE.getState(); - + private static final int MAX_RETRIES = 5; + PostgreSQLConnection(String host, int port, String dbName, String userName, String password) { super(createConnection(host, port, dbName, userName, password)); } @@ -5818,7 +5812,6 @@ void executeUpdate(Statement statement, String update, int generateKeys) throws @Override PreparedStatement prepareStatement(String sqlStatement, int generateKeys) throws SQLException { PrepareStatementGenerateKeys prepareStatementGenerateKeys = new PrepareStatementGenerateKeys(this.getConnection(), sqlStatement, generateKeys); - executeCommand(prepareStatementGenerateKeys); return prepareStatementGenerateKeys.getPreparedStatement(); } @@ -5842,10 +5835,9 @@ void executeCommand(DbCommand command) throws SQLException { String sqlState = ((PSQLException) ex).getSQLState(); if (sqlState.equals(COMMUNICATION_ERROR) || sqlState.equals(SYSTEM_ERROR) || sqlState.equals(UNKNOWN_STATE)) { try { - notifyError(ex); Thread.sleep(SLEEP_LENGTH_IN_MILLISECONDS); - } catch (InterruptedException ignored) { - // Swallow, should never happen nor log + } catch (InterruptedException exp) { + Logger.getLogger(SleuthkitCase.class.getName()).log(Level.WARNING, "Unexpectedly unable to wait for database.", exp); } } else { notifyError(ex);