/* */ package connectmysql; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author vandercammen.b */ public class ConnectMySQL { /** * @param args the command line arguments */ public static void main(String[] args) { try { Class.forName("com.mysql.jdbc.Driver"); Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/myDB", "user", "password"); System.out.println("connection open"); connection.close(); System.out.println("connection closed"); } catch (Exception ex) { Logger.getLogger(ConnectMySQL.class.getName()).log(Level.SEVERE, null, ex); } } }