Advertisement
Guest User

Untitled

a guest
Mar 27th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package be.howest.ti.moviebase.data.util;
  7.  
  8. import be.howest.ti.moviebase.util.MovieException;
  9. import java.sql.Connection;
  10. import java.sql.DriverManager;
  11. import java.sql.SQLException;
  12.  
  13. /**
  14. *
  15. * @author frederic.vlummens
  16. */
  17. public class MySqlConnection
  18. {
  19. private static final String URL = "jdbc:mysql://localhost/moviebase?useSSL=false"; // database path connection
  20. private static final String UID = "root";
  21. private static final String PWD = "";
  22.  
  23. // loading the class is only required for web applications
  24. static
  25. {
  26. try
  27. {
  28. Class.forName("com.mysql.jdbc.Driver");
  29. }
  30. catch (ClassNotFoundException ex)
  31. {
  32. throw new MovieException("Unable to load database driver.", ex);
  33. }
  34. }
  35.  
  36. public static Connection getConnection() throws SQLException
  37. {
  38. return DriverManager.getConnection(URL, UID, PWD);
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement