Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. //Crear connexió amb la base de dades
  2. private boolean beginConnection() {
  3. boolean result = true;
  4. if (connected) {
  5. System.err.println("ERROR: Ja estàs connectat a la base de dades");
  6. result = false;
  7. } else {
  8. try {
  9. connection = DriverManager.getConnection("jdbc:postgresql://localhost:" + port + "/" + DB_NAME, username, password);
  10. System.out.println("SUCCESS: Connexió establerta");
  11. connected = true;
  12. } catch (SQLException e) {
  13. System.err.println("ERROR: No s'ha pogut establir la connexió amb la base de dades");
  14. //e.printStackTrace();
  15. result = false;
  16. }
  17. }
  18. return result;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement