import [Link].
Connection;
import [Link];
import [Link];
public class DatabaseConnection {
private static final String URL = "jdbc:mysql://localhost:3306/cafe_manager";
private static final String USER = "root"; // Replace with your MySQL username
private static final String PASSWORD = ""; // Replace with your MySQL password
private static Connection connection = null;
public static Connection getConnection() {
if (connection == null) {
try {
connection = [Link](URL, USER, PASSWORD);
[Link]("Database connected successfully.");
} catch (SQLException e) {
[Link]("Failed to connect to database: " +
[Link]());
}
}
return connection;
}
public static void closeConnection() {
if (connection != null) {
try {
[Link]();
connection = null;
[Link]("Database connection closed.");
} catch (SQLException e) {
[Link]("Error closing connection: " + [Link]());
}
}
}
}