I'm trying to connect Android
directly to PostgreSQL
.
Include in the project package: postgresql-9.1-903.jdbc4.jar and I'm using PostgreSQL 9.1
.
But I can not successfully connect.
I modified the code and it returns me:
"Error: Driver!"
I'm using JDBC
: postgresql-9.1-903.jdbc4.jar .
I have modified the code and it is giving error:
Connection: Error Database!
Follow the code:
// Conectar
public String conectarDB() {
// Variáveis
String driver = "org.postgresql.Driver";
String dbURL = "jdbc:postgresql://localhost:5432/database";
String user = "postgres";
String pass = "123456";
try{
//Carrega o driver
Class.forName(driver);
Connection conn = DriverManager.getConnection(dbURL, user, pass);
return "Conexão: Ok!";
} catch(ClassNotFoundException e) {
e.printStackTrace();
return "Conexão: Erro Driver!";
} catch (SQLException e) {
e.printStackTrace();
return "Conexão: Erro Database!";
}
}