diff --git a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java
index 1b1d7487127d0c61b3be837e0b0a0ad16026bb6c..9d7942342dd5dcc3c0df52a16738d2a174172ca0 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java
@@ -9500,6 +9500,7 @@ public CaseDbConnection getPooledConnection() throws SQLException {
 	abstract class CaseDbConnection {
 
 		static final int SLEEP_LENGTH_IN_MILLISECONDS = 5000;
+		static final int MAX_RETRIES = 20; //MAX_RETRIES * SLEEP_LENGTH_IN_MILLESECONDS = max time to hang attempting connection
 
 		private class CreateStatement implements DbCommand {
 
@@ -9835,16 +9836,19 @@ private final class SQLiteConnection extends CaseDbConnection {
 
 		@Override
 		void executeCommand(DbCommand command) throws SQLException {
+			int retryCounter = 0;
 			while (true) {
 				try {
 					command.execute(); // Perform the operation
 					break;
 				} catch (SQLException ex) {
-					if (ex.getErrorCode() == SQLITE_BUSY_ERROR || ex.getErrorCode() == DATABASE_LOCKED_ERROR) {
+					if ((ex.getErrorCode() == SQLITE_BUSY_ERROR || ex.getErrorCode() == DATABASE_LOCKED_ERROR) && retryCounter < MAX_RETRIES) {
 						try {
+							
 							// We do not notify of error here, as this is not an
 							// error condition. It is likely a temporary busy or
 							// locked issue and we will retry.
+							retryCounter++;
 							Thread.sleep(SLEEP_LENGTH_IN_MILLISECONDS);
 						} catch (InterruptedException exp) {
 							Logger.getLogger(SleuthkitCase.class.getName()).log(Level.WARNING, "Unexpectedly unable to wait for database.", exp);