import [Link].
Connection;
import [Link];
import [Link];
public class SchoolDBConnection {
public static void main(String[] args) {
// Database credentials and URL
String url = "jdbc:mysql://localhost:3306/school"; // 'school' is your DB name
String username = "root"; // replace with your MySQL username
String password = "1234"; // replace with your MySQL password
// Try-with-resources automatically closes connection
try (Connection con = [Link](url, username,
password)) {
if (con != null) {
[Link]("✅ Database connection successful!");
} else {
[Link]("❌ Connection failed!");
}
} catch (SQLException e) {
[Link]("❌ Error connecting to database!");
[Link]();
}
}
}