Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MySQL {
- private static Connection connection;
- public static Connection getConnection() throws SQLException {
- if (connection != null) if (connection.isValid(1)) return connection; else connection.close();
- try {
- Class.forName("com.mysql.jdbc.Driver");
- } catch (ClassNotFoundException ex) {
- ex.printStackTrace();
- }
- connection = DriverManager.getConnection("jdbc:mysql://<db server ip>:3306/<db name>", "<user>", "<pass>");
- return connection;
- }
- }
Add Comment
Please, Sign In to add comment