improved update failure reporting

This commit is contained in:
Jeremy Long
2015-10-26 06:36:10 -04:00
parent 54d921f275
commit 92e7d9cf80

View File

@@ -315,7 +315,7 @@ public final class ConnectionFactory {
}
reader = new InputStreamReader(is, "UTF-8");
in = new BufferedReader(reader);
final StringBuilder sb = new StringBuilder(2110);
final StringBuilder sb = new StringBuilder(is.available());
String tmp;
while ((tmp = in.readLine()) != null) {
sb.append(tmp);
@@ -323,7 +323,10 @@ public final class ConnectionFactory {
Statement statement = null;
try {
statement = conn.createStatement();
statement.execute(sb.toString());
boolean success = statement.execute(sb.toString());
if (!success && statement.getUpdateCount() <= 0) {
throw new DatabaseException(String.format("Unable to upgrade the database schema to %s", schema));
}
} catch (SQLException ex) {
LOGGER.debug("", ex);
throw new DatabaseException("Unable to update database schema", ex);