mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-17 23:04:07 +01:00
Cleanup: Ease debugging connection problems: add cause to thrown exceptions
This commit is contained in:
@@ -117,7 +117,7 @@ public final class ConnectionFactory {
|
|||||||
}
|
}
|
||||||
} catch (DriverLoadException ex) {
|
} catch (DriverLoadException ex) {
|
||||||
LOGGER.debug("Unable to load database driver", ex);
|
LOGGER.debug("Unable to load database driver", ex);
|
||||||
throw new DatabaseException("Unable to load database driver");
|
throw new DatabaseException("Unable to load database driver", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
userName = Settings.getString(Settings.KEYS.DB_USER, "dcuser");
|
userName = Settings.getString(Settings.KEYS.DB_USER, "dcuser");
|
||||||
@@ -130,7 +130,7 @@ public final class ConnectionFactory {
|
|||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
LOGGER.debug(
|
LOGGER.debug(
|
||||||
"Unable to retrieve the database connection string", ex);
|
"Unable to retrieve the database connection string", ex);
|
||||||
throw new DatabaseException("Unable to retrieve the database connection string");
|
throw new DatabaseException("Unable to retrieve the database connection string", ex);
|
||||||
}
|
}
|
||||||
boolean shouldCreateSchema = false;
|
boolean shouldCreateSchema = false;
|
||||||
try {
|
try {
|
||||||
@@ -140,7 +140,7 @@ public final class ConnectionFactory {
|
|||||||
}
|
}
|
||||||
} catch (IOException ioex) {
|
} catch (IOException ioex) {
|
||||||
LOGGER.debug("Unable to verify database exists", ioex);
|
LOGGER.debug("Unable to verify database exists", ioex);
|
||||||
throw new DatabaseException("Unable to verify database exists");
|
throw new DatabaseException("Unable to verify database exists", ioex);
|
||||||
}
|
}
|
||||||
LOGGER.debug("Loading database connection");
|
LOGGER.debug("Loading database connection");
|
||||||
LOGGER.debug("Connection String: {}", connectionString);
|
LOGGER.debug("Connection String: {}", connectionString);
|
||||||
@@ -157,11 +157,11 @@ public final class ConnectionFactory {
|
|||||||
LOGGER.debug("Unable to start the database in server mode; reverting to single user mode");
|
LOGGER.debug("Unable to start the database in server mode; reverting to single user mode");
|
||||||
} catch (SQLException sqlex) {
|
} catch (SQLException sqlex) {
|
||||||
LOGGER.debug("Unable to connect to the database", ex);
|
LOGGER.debug("Unable to connect to the database", ex);
|
||||||
throw new DatabaseException("Unable to connect to the database");
|
throw new DatabaseException("Unable to connect to the database", ex);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOGGER.debug("Unable to connect to the database", ex);
|
LOGGER.debug("Unable to connect to the database", ex);
|
||||||
throw new DatabaseException("Unable to connect to the database");
|
throw new DatabaseException("Unable to connect to the database", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ public final class ConnectionFactory {
|
|||||||
createTables(conn);
|
createTables(conn);
|
||||||
} catch (DatabaseException dex) {
|
} catch (DatabaseException dex) {
|
||||||
LOGGER.debug("", dex);
|
LOGGER.debug("", dex);
|
||||||
throw new DatabaseException("Unable to create the database structure");
|
throw new DatabaseException("Unable to create the database structure", dex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -228,7 +228,7 @@ public final class ConnectionFactory {
|
|||||||
conn = DriverManager.getConnection(connectionString, userName, password);
|
conn = DriverManager.getConnection(connectionString, userName, password);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
LOGGER.debug("", ex);
|
LOGGER.debug("", ex);
|
||||||
throw new DatabaseException("Unable to connect to the database");
|
throw new DatabaseException("Unable to connect to the database", ex);
|
||||||
}
|
}
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
@@ -317,7 +317,7 @@ public final class ConnectionFactory {
|
|||||||
try {
|
try {
|
||||||
databaseProductName = conn.getMetaData().getDatabaseProductName();
|
databaseProductName = conn.getMetaData().getDatabaseProductName();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
throw new DatabaseException("Unable to get the database product name");
|
throw new DatabaseException("Unable to get the database product name", ex);
|
||||||
}
|
}
|
||||||
if ("h2".equalsIgnoreCase(databaseProductName)) {
|
if ("h2".equalsIgnoreCase(databaseProductName)) {
|
||||||
LOGGER.debug("Updating database structure");
|
LOGGER.debug("Updating database structure");
|
||||||
@@ -412,7 +412,7 @@ public final class ConnectionFactory {
|
|||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
LOGGER.debug("", ex);
|
LOGGER.debug("", ex);
|
||||||
throw new DatabaseException("Unable to check the database schema version");
|
throw new DatabaseException("Unable to check the database schema version", ex);
|
||||||
} finally {
|
} finally {
|
||||||
DBUtils.closeResultSet(rs);
|
DBUtils.closeResultSet(rs);
|
||||||
DBUtils.closeStatement(ps);
|
DBUtils.closeStatement(ps);
|
||||||
|
|||||||
Reference in New Issue
Block a user