Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package examplediploma.dbutils;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class DbConnectionUtils {
- private static final String JDBC_MYSQL_HOST = "jdbc:mysql://localhost:3306/";
- private static final String MYSQL_JDBC_DRIVER_NAME = "com.mysql.jdbc.Driver";
- private static final String DB_NAME = "sourceit";
- private static final String USERNAME = "root";
- private static final String PASSWORD = "root";
- public static Connection getConnection() {
- try {
- Class.forName(MYSQL_JDBC_DRIVER_NAME);
- return DriverManager.getConnection(JDBC_MYSQL_HOST
- + DB_NAME,
- USERNAME,
- PASSWORD);
- } catch (ClassNotFoundException | SQLException e) {
- throw new RuntimeException(e);
- }
- }
- }
Add Comment
Please, Sign In to add comment