Guest User

Untitled

a guest
Dec 29th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3. import java.sql.SQLException;
  4.  
  5. public class ConnectionFactory {
  6.  
  7. private final String DATA_BASE = "data_base";
  8. private final String USER = "root";
  9. private final String PASSWORD = "";
  10. private final String DRIVER = "com.mysql.jdbc.Driver";
  11.  
  12. public Connection getConnection() {
  13.  
  14. try {
  15. Class.forName(DRIVER);
  16. return DriverManager.getConnection(
  17. "jdbc:mysql://localhost/" + DATA_BASE + "?useTimezone=true&serverTimezone=UTC", USER, PASSWORD);
  18. }catch(SQLException | ClassNotFoundException e) {
  19. throw new RuntimeException(e);
  20. }
  21. }
  22.  
  23. }
Add Comment
Please, Sign In to add comment