Advertisement
Guest User

Untitled

a guest
Apr 6th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. package DbLayer;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5.  
  6. /**
  7. * Created by Gabrielle on 04-04-16.
  8. */
  9. public class DbCon {
  10. Connection con;
  11.  
  12. public DbCon(){
  13.  
  14. try{
  15. Class.forName("org.postgresql.Driver");
  16. con = DriverManager.getConnection(
  17. "jdbc:postgresql://localhost:5432/Project3","project3", "project3");
  18.  
  19. System.out.println("Verbinding succesvol: " + con.getSchema());
  20. }
  21. catch(Exception ex){
  22. System.out.println("Verbinding fout: " + ex.getMessage());
  23. }
  24. }
  25.  
  26.  
  27. public String[] readDiefstallen(){
  28. return new String[] {"Test data 1"," Test data 2"};
  29. }
  30.  
  31.  
  32. public void closeConnection(){
  33. try{
  34. con.close();
  35. }
  36. catch(Exception ex){
  37. System.out.println("Error: "+ex.getMessage());
  38. }
  39.  
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement