提交 6687137f authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Throw exception from JdbcUtils.getConnection() when driver is not compatible

上级 d3bb6c84
...@@ -300,10 +300,7 @@ public class JdbcUtils { ...@@ -300,10 +300,7 @@ public class JdbcUtils {
if (connection != null) { if (connection != null) {
return connection; return connection;
} }
/* throw new SQLException("Driver " + driver + " is not suitable for " + url, "08001");
* URL is not valid for the specified driver, fallback to
* default.
*/
} else if (javax.naming.Context.class.isAssignableFrom(d)) { } else if (javax.naming.Context.class.isAssignableFrom(d)) {
// JNDI context // JNDI context
Context context = (Context) d.getDeclaredConstructor().newInstance(); Context context = (Context) d.getDeclaredConstructor().newInstance();
......
...@@ -515,9 +515,9 @@ public class TestTools extends TestDb { ...@@ -515,9 +515,9 @@ public class TestTools extends TestDb {
assertEquals(null, JdbcUtils.getDriver("jdbc:unknown:test")); assertEquals(null, JdbcUtils.getDriver("jdbc:unknown:test"));
try { try {
JdbcUtils.getConnection("org.h2.Driver", "jdbc:h2x:test", "sa", ""); JdbcUtils.getConnection("org.h2.Driver", "jdbc:h2x:test", "sa", "");
fail("Expected SQLException: No suitable driver found"); fail("Expected SQLException: 08001");
} catch (SQLException e) { } catch (SQLException e) {
// OK assertEquals("08001", e.getSQLState());
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论