我将尝试编写一个测试方法,该方法返回一个java.sql.Connection以连接到PostgreSQL。
我的测试非常简单:
@Test
public void connectionFactoryShouldReturnOpenConnection() throws Exception {
Connection conn = ConnectionFactory.getConnection();
assertTrue(conn.isValid(2));
}
< p > isValid
调用失败了:
org.postgresql.util.PSQLException: Method org.postgresql.jdbc4.Jdbc4Connection.isValid(int) is not yet implemented.
at org.postgresql.Driver.notImplemented(Driver.java:753)
at org.postgresql.jdbc4.AbstractJdbc4Connection.isValid(AbstractJdbc4Connection.java:109)
at org.postgresql.jdbc4.Jdbc4Connection.isValid(Jdbc4Connection.java:21)
发生了什么?肯定有一款PostgreSQL JDBC驱动程序实现了Java 1.6的方法,例如isValid()
吧?
这是我正在使用的驱动程序的详细信息:
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.0-801.jdbc4</version>