0
I’m trying to connect the Android
directly with PostgreSQL
.
Include in the project package: postgresql-9.1-903.jdbc4.jar and I’m using PostgreSQL 9.1
.
But I can’t successfully make the connection.
I modified the code and it returns me:
"Error: Driver!"
I’m using JDBC
: postgresql-9.1-903.jdbc4.jar.
I modified the code and it’s wrong:
Connection: Database Error!
Follows 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!";
}
}
Is there an error? has log?
– Thiago Luiz Domacoski
How do I view the log and send it to you?
– Júnior
Add this to (Catch exception e) { e.printStackTrace(); Return false;} and check the bottom tab Android Monitror
– Thiago Luiz Domacoski
I’m not using Android Studio is too heavy for machine I’m using. Even without Postgresql there is no error even with } catch(Exception e) { e.printStackTrace(); Return false; }
– Júnior