1
Good morning,
I’m trying to make a connection to Android Virtual
servant
in the Eclipse ADT
with JDBC do PostGreSQL 9.1
. To my knowledge
in Android
it’s little I spent a lot of time trying to connect and I didn’t have
any success.
public String conectarDB() throws ExecutionException {
// Variáveis
try {
String driver = "com.postgresql.Driver";
String url = "jdbc:postgresql://127.0.0.1:5432/database";
String user = "postgres";
String pass = "#Servicedesk#@!1";
// Conectar
try {
Class.forName(driver);
Connection con = null;
con = (Connection) DriverManager.getConnection(url, user, pass);
return ("Conexão: Funcionando!");
} catch (ClassNotFoundException e) {
e.printStackTrace();
return ("Erro com Database!");
} catch (SQLException e) {
e.printStackTrace();
return ("Erro com JDBC!");
}
} catch(Exception e) {
e.printStackTrace();
return ("Conexão: Erro no envio de Conexão!");
}
}
Are you getting any of the bugs?
– lfarroco
No... Just display: "Connection: Database Error!"
– Júnior
Then you know it’s a Sqlexception, try trading localhost for 127.0.0.1
– lfarroco
If it is String driver = "org.postgresql.Driver"; = Error with JDBC If it is String driver = "with.postgresql.Driver"; = Error with Database
– Júnior
Need to configure something on Androidmanifest.xml? For Android Virtual recognizes something?
– Júnior