1
내 PC에서 실행되는 ProgreSQL DB를 JDBC에 연결하려고합니다.JDBC가 ProgreSQL과 연결
package postgres;
import java.sql.*;
import java.util.Properties;
public class SQLConnector {
String url = "jdbc:postgresql://localhost:5432/postgres";
Properties props = new Properties();
Connection con;
public SQLConnector() throws SQLException {
props.setProperty("user", "postgres");
props.setProperty("password", "admin");
this.con = DriverManager.getConnection(url, props);
}
public boolean isOpen() throws SQLException {
return con.isValid(5);
}
public static void main(String[] args)throws SQLException {
SQLConnector sqldb = new SQLConnector();
if (sqldb.isOpen()) {
System.out.println("Connection successfully established.");
}
}
}
나는 항상 다음과 같은 예외를 얻을 :
Exception in thread "main" java.lang.AbstractMethodError: org.postgresql.jdbc3g.Jdbc3gConnection.isValid(I)Z
at postgres.SQLConnector.isOpen(SQLConnector.java:21)
at postgres.SQLConnector.main(SQLConnector.java:27)
드라이버는 프로젝트의 참조 된 라이브러리입니다.
도와 드리겠습니다.
티몬
'isValid (int)'메소드가 드라이버에 의해 구현되지 않은 것 같습니다. 마치 오래된 버전의 드라이버를 사용하고있는 것처럼 들립니다. –
고마워요! 그것이 문제였습니다. – unknown