Skip to content

Commit

Permalink
update to KeyValueDAO detection of missing table
Browse files Browse the repository at this point in the history
exception thrown when ModelVersion table does not exist is
different in tomcat (reason unknown)
  • Loading branch information
pdowler committed Sep 12, 2024
1 parent 10e14ee commit 70ecca9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cadc-util/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sourceCompatibility = 1.8

group = 'org.opencadc'

version = '1.11.3'
version = '1.11.4'

description = 'OpenCADC core utility library'
def git_url = 'https://github.com/opencadc/core'
Expand Down
23 changes: 22 additions & 1 deletion cadc-util/src/main/java/ca/nrc/cadc/db/version/KeyValueDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public KeyValue get(String name) {
sel.setValues(name);
try {
o = jdbc.query(sel, extractor);
} catch (BadSqlGrammarException ex) {
} catch (Exception ex) {
try {
// try simples query possible to see if table exists
String sql = "SELECT count(*) from " + tableName;
Expand All @@ -153,6 +153,27 @@ public Integer mapRow(ResultSet rs, int i) throws SQLException {
} catch (BadSqlGrammarException ex2) {
log.debug("previous install not found: " + ex2.getMessage());
o = null;
} catch (Exception ex2) {
Throwable cause = ex2;
boolean notExists = false;
while (cause != null) {
if (cause instanceof SQLException) {
String msg = cause.getMessage();
if (msg != null) {
msg = msg.trim().toLowerCase();
if (msg.contains("does not exist")) {
log.debug("previous install not found: " + ex2.getMessage());
o = null;
notExists = true;
}
}
}
cause = cause.getCause();
}
if (!notExists) {
// some other kind of error
throw ex;
}
}
}

Expand Down

0 comments on commit 70ecca9

Please sign in to comment.