我正在尝试为一个方法编写一个测试,该方法返回连接到PostgreSQL的java.sql.Connection。
我的测试非常简单:
@Test
public void connectionFactoryShouldReturnOpenConnection() throws Exception {
Connection conn = ConnectionFactory.getConnection();
assertTrue(conn.isValid(2));
}
不过,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)
到底怎么回事?当然,有一个Java驱动程序可以实现Java1.6的方法,比如isValid()
下面是我使用的驱动程序的详细信息:
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.0-801.jdbc4</version>
发布于 2011-03-12 02:56:15
执行一个简单的查询,如果它工作,它是有效的。如果不是,它就不是。
对于简单的查询,我的意思是这样的:
SELECT 1;
非常简单。
发布于 2011-03-12 02:46:01
从postresql驱动程序source code中,AbstractJdbc4Connection.isValid()
在被调用时抛出此异常:
public boolean isValid(int timeout) throws SQLException
{
checkClosed();
throw org.postgresql.Driver.notImplemented(this.getClass(), "isValid(int)");
}
https://stackoverflow.com/questions/5276816
复制相似问题