Advertisement
Guest User

Untitled

a guest
Jul 1st, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. public class DatabaseControl {
  2.     Connection conn;
  3.    
  4.     public DatabaseControl()
  5.     {
  6.     }
  7.  
  8.     public static Connection getConnection(String dbURL, String user, String password)
  9.     throws SQLException, ClassNotFoundException {
  10.         Class.forName("com.mysql.jdbc.Driver");
  11.         return DriverManager.getConnection(dbURL, user, password);
  12.     }
  13.    
  14.     public void open()
  15.     {
  16.         try
  17.         {
  18.             conn = getConnection("jdbc:mysql://sql.ewi.tudelft.nl/DataBaseNaam", "user", "password");
  19.         }catch(Exception e)
  20.         {
  21.             e.printStackTrace();
  22.         }
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement