Advertisement
Guest User

Untitled

a guest
Aug 15th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. public class SQLConnection
  2. {
  3. Connection conn;//default Connection
  4. String url;
  5. Settings settings;
  6.  
  7. public SQLConnection()throws InstantiationException, IllegalAccessException
  8. {
  9. settings = new ReadWrite().readIn();
  10.  
  11. try {
  12. Class.forName("com.mysql.jdbc.Driver").newInstance();//Specifys the package to use
  13. url = "jdbc:mysql://homepages.cs.ncl.ac.uk:3306/t2015t21"; //+ settings.getDBadr() + "/" + settings.getDBname();
  14. conn = DriverManager.getConnection("jdbc:mysql://homepages.cs.ncl.ac.uk:3306/t2015t21");//,"t2015t21", "CubFur?%");//settings.getDBusername(),settings.getDBpassword());//Makes the connection with the given parameters
  15. }catch (ClassNotFoundException e)
  16. {
  17. System.out.println("A ClassNotFound exception occured! Unrecoverable error, terminating server application.");
  18. System.exit(1);
  19. }
  20. catch(SQLException e)
  21. {
  22. System.out.println("An SQL exception occured!\n"+ e.toString());
  23. }
  24.  
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement