我在Mac上安装了tomcat9和eclipse,但是每次运行项目时,它都会给我一些错误
上配置时间
public class DBConnection {
public static Connection getConnectionToDatabase() {
Connection connection = null;
try {
// load the driver class
Class.forName("com.mysql.jdbc.Driver");
System.out.println("MySQL JDBC Driver Registered!");
// get hold of the DriverManager
connection = DriverManager.getConnection("jdbc:mysql://localhost:portnnumber/hplus", "root", "root");
} catch (ClassNotFoundException e) {
System.out.println("Where is your MySQL JDBC Driver?");
e.printStackTrace();
} catch (SQLException e) {
System.out.println("Connection Failed! Check output console");
e.printStackTrace();
}
if (connection != null) {
System.out.println("Connection made to DB!");
}
return connection;
}
}