Advertisement
Guest User

Untitled

a guest
Mar 8th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. /**
  2. * Created by Casvan on 8-3-2016.
  3. */
  4. import java.sql.Connection;
  5. import java.sql.DriverManager;
  6.  
  7.  
  8. /**
  9. *
  10. * @author Casvan
  11. */
  12.  
  13. public class DatabaseConnector {
  14.  
  15. private static Connection connection = null;
  16. public DatabaseConnector(){
  17.  
  18. }
  19.  
  20. public Connection connectToDatabase() {
  21. //IP ADRES FROM DATABASE
  22. //String url = "jdbc:mysql://localhost:3306/";
  23.  
  24.  
  25. try {Class.forName("org.postgresql.Driver");
  26.  
  27. } catch (ClassNotFoundException e) {
  28.  
  29. System.out.println("Where is your PostgreSQL JDBC Driver? "
  30. + "Include in your library path!");
  31. e.printStackTrace();
  32.  
  33.  
  34. }
  35. try {
  36. connection = DriverManager.getConnection(
  37. "jdbc:postgresql://localhost:8080/Verplaatsingsysteem", "postgres",
  38. "fontys");
  39. } catch (Exception e) {
  40. return null;
  41. }
  42. return connection;
  43. }
  44.  
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement