Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package eu.pixeldream.api.sql;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class MySQL {
- private static final String host = "localhost";
- private static final String port = "3306";
- private static final String database = "***";
- private static final String user = "***";
- private static final String pass = "***";
- public static Connection openConnection() {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- } catch (ClassNotFoundException e1) {
- e1.printStackTrace();
- }
- try {
- Connection conn = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, user, pass);
- System.out.println("§2API is connected to the database");
- return conn;
- } catch (SQLException e) {
- System.out.println("§4The connection to the database failed");
- e.printStackTrace();
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement