java中的类conextion:
try {
Class.forName("org.postgresql.Driver");
Properties props = new Properties();
props.setProperty("user","postgres");
props.setProperty("password","postgres");
Connection conn = DriverManager.getConnection(url, props);
String stsql = "SELECT * From mercarderia";
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(stsql);
while (rs.next()) {
String c = rs.getString("nombre");
System.out.println(c);
}
conn.close();
} catch (SQLException se) {
System.out.println("oops! No se puede conectar. Error: " + se.toString()+se.getErrorCode());
msj.setText("oops! No se puede conectar. Error: " + se.toString() + "||" +se.getErrorCode());
} catch (ClassNotFoundException e) {
System.out.println("oops! No se encuentra la clase. Error: " + e.getMessage() +" "+ e.getException());
msj.setText("oops! No se encuentra la clase. Error: " + e.getMessage());
}
}
我明白了:
Error: java.lang.NoClassDefFoundError: org.postgresql.Driver
请帮忙......
postgresql版本9.3
* JDK 1.8
Eclipse和SDK oficial *
现在我收到以下错误消息:java.lang.VerifyError: org.postgresql.Driver
并且驱动程序位于“libs”文件夹
答案 0 :(得分:0)
您应该检查您的postgres驱动程序库是否在您的构建路径中,如果是,还要在应用程序中启用它的导出。 这是JDBC postgresql driver not found in android project
的副本