org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 8 in the jsp file: /insertUser.jsp
Connection cannot be resolved to a type
5: <%
6:
7: Class.forName("com.mysql.jdbc.Driver").newInstance();
8: Connection con=Java.sql.DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/ch2","root","abcd1234!");
9: con.close();
10: out.println("OK");
11:
An error occurred at line: 8 in the jsp file: /insertUser.jsp
Java.sql.DriverManager cannot be resolved to a type
5: <%
6:
7: Class.forName("com.mysql.jdbc.Driver").newInstance();
8: Connection con=Java.sql.DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/ch2","root","abcd1234!");
9: con.close();
10: out.println("OK");
11:
代码是:
<%@ page contentType="text/html; charset=UTF-8" language="Java" import="Java.sql.*,Java.io.*"%>
<html>
<body>
<center>往数据库中添加数据:<hr>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con=Java.sql.DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/ch2","root","abcd1234!");
con.close();
out.println("OK");
%>
<center>
</body>
</html>
就是连不上,伤脑筋啊!
刚才按您的写法试了,怎么还是报这个错误。。呜,伤不起啊
exceptionorg.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the jsp file: /insertUser.jsp
Connection cannot be resolved to a type
3:
4: 往数据库中添加数据:
5: <%
6: Connection conn=null;