我尝试使用jsp将mysql连接到eclipse。
我已添加mysql连接器,并将其复制到web-inf/lib
并且运行了wamp服务器,但显示以下内容:
Unable to connect to databasejava.lang.ClassNotFoundException: com.mysql.jdbc.Driver
代码是:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%@ page import ="java.sql.*" %>
<%
try {
String connectionURL = "jdbc:mysql://localhost/3306/movie_booking";
Connection connection =null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "root", "");
if(!connection.isClosed())
out.println("Successfully connected to " + "MySQL server using TCP/IP...");
connection.close();
}catch(Exception ex){
out.println("Unable to connect to database"+ex);
}
%>
</body>
</html>