Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- public class MyConnection {
- private static Connection conn;
- public static Connection getConnection(){
- if(conn == null){
- openConnection();
- }
- return conn;
- }
- private static void openConnection(){
- //put in your conn open code here
- try {
- Class.forName("com.mysql.jdbc.Driver");
- url="jdbc:mysql://192.168.20.98:3306/games";
- this.con=DriverManager.getConnection(url,"user","pass");
- } catch (SQLException ex) {
- Logger.getLogger(DBManager.class.getName()).log(Level.SEVERE, null, ex);
- } catch (ClassNotFoundException ex) {
- Logger.getLogger(DBManager.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement