Fix SQLNestedException deprecated import warning
Change-Id: I3cf0b581458939ee434ddc20c4cd25956e9c280a Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -32,7 +32,6 @@ import com.google.inject.Module;
|
|||||||
import com.google.inject.name.Names;
|
import com.google.inject.name.Names;
|
||||||
import com.google.inject.spi.Message;
|
import com.google.inject.spi.Message;
|
||||||
|
|
||||||
import org.apache.commons.dbcp.SQLNestedException;
|
|
||||||
import org.kohsuke.args4j.Option;
|
import org.kohsuke.args4j.Option;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -176,10 +175,7 @@ public abstract class SiteProgram extends AbstractProgram {
|
|||||||
if (why instanceof OrmException && why.getCause() != null
|
if (why instanceof OrmException && why.getCause() != null
|
||||||
&& "Unable to determine driver URL".equals(why.getMessage())) {
|
&& "Unable to determine driver URL".equals(why.getMessage())) {
|
||||||
why = why.getCause();
|
why = why.getCause();
|
||||||
if (why instanceof SQLNestedException
|
if (isCannotCreatePoolException(why)) {
|
||||||
&& why.getCause() != null
|
|
||||||
&& why.getMessage().startsWith(
|
|
||||||
"Cannot create PoolableConnectionFactory")) {
|
|
||||||
throw die("Cannot connect to SQL database", why.getCause());
|
throw die("Cannot connect to SQL database", why.getCause());
|
||||||
}
|
}
|
||||||
throw die("Cannot connect to SQL database", why);
|
throw die("Cannot connect to SQL database", why);
|
||||||
@@ -200,4 +196,12 @@ public abstract class SiteProgram extends AbstractProgram {
|
|||||||
throw die(buf.toString(), new RuntimeException("DbInjector failed", ce));
|
throw die(buf.toString(), new RuntimeException("DbInjector failed", ce));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
private static boolean isCannotCreatePoolException(Throwable why) {
|
||||||
|
return why instanceof org.apache.commons.dbcp.SQLNestedException
|
||||||
|
&& why.getCause() != null
|
||||||
|
&& why.getMessage().startsWith(
|
||||||
|
"Cannot create PoolableConnectionFactory");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user