Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class ConnectionFactory {
- private final String DATA_BASE = "data_base";
- private final String USER = "root";
- private final String PASSWORD = "";
- private final String DRIVER = "com.mysql.jdbc.Driver";
- public Connection getConnection() {
- try {
- Class.forName(DRIVER);
- return DriverManager.getConnection(
- "jdbc:mysql://localhost/" + DATA_BASE + "?useTimezone=true&serverTimezone=UTC", USER, PASSWORD);
- }catch(SQLException | ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
- }
Add Comment
Please, Sign In to add comment