From 433cc1e32c450a551fdef086d15f0e6362532117 Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Sun, 26 Jan 2014 09:02:08 -0500 Subject: [PATCH] updated error messages Former-commit-id: 2b1c5e7560f30d1aaf2215bdc8997961a637d083 --- .../data/nvdcve/ConnectionFactory.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/ConnectionFactory.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/ConnectionFactory.java index 1d9df1116..f4525c787 100644 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/ConnectionFactory.java +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/ConnectionFactory.java @@ -96,9 +96,19 @@ public final class ConnectionFactory { //Class.forName("org.h2.Driver"); conn = DriverManager.getConnection(connStr, user, pass); if (createTables) { - createTables(conn); + try { + createTables(conn); + } catch (DatabaseException ex) { + Logger.getLogger(ConnectionFactory.class.getName()).log(Level.FINE, null, ex); + throw new DatabaseException("Unable to create the database structure"); + } } else { - ensureSchemaVersion(conn); + try { + ensureSchemaVersion(conn); + } catch (DatabaseException ex) { + Logger.getLogger(ConnectionFactory.class.getName()).log(Level.FINE, null, ex); + throw new DatabaseException("Database schema does not match this version of dependency-check"); + } } } catch (IOException ex) { Logger.getLogger(ConnectionFactory.class.getName()).log(Level.FINE, null, ex); @@ -109,9 +119,6 @@ public final class ConnectionFactory { } catch (SQLException ex) { Logger.getLogger(ConnectionFactory.class.getName()).log(Level.FINE, null, ex); throw new DatabaseException("Unable to connect to the database"); - } catch (DatabaseException ex) { - Logger.getLogger(ConnectionFactory.class.getName()).log(Level.FINE, null, ex); - throw new DatabaseException("Unable to create the database structure"); } return conn; }