Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/mydatabase"; String user = "myusername"; String password = "mypassword"; Connection conn = DriverManager.getConnection(url, user, password);This code creates a Connection object using the url, username, and password for the MySQL database specified. The DriverManager handles finding and using the correct driver for the specified database. Package Library: java.sql.