Advertisement
Guest User

Untitled

a guest
Sep 19th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. package dao;
  2.  
  3. try{
  4. String dbURL = "jdbc:postgresql://localhost:5432/database";
  5. String user = "postgres";
  6. String pass = "123456";
  7. Connection conn = DriverManager.getConnection(dbURL, user, pass);
  8.  
  9. if (conn != null) {
  10. return true;
  11. } else {
  12. return true;
  13. }
  14.  
  15. } catch(Exception e){
  16. return false;
  17. }
  18.  
  19. }
  20.  
  21. try{
  22. conn.close();
  23. Log.i("PostgreSQL","Desconectado.");
  24. } catch(Exception erro){
  25. Log.e("PostgreSQL","Erro: "+erro);
  26. }
  27. }
  28.  
  29. } catch(Exception erro){
  30. Log.e("PostgreSQL","Erro: "+erro);
  31. return null;
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement