处理JSP页面时发生异常

时间:2014-01-26 04:06:09

标签: java mysql jsp jdbc connect

org.apache.jasper.JasperException: An exception occurred processing JSP page /registration.jsp at line 9

6:     String lname = request.getParameter("lname");
7:     String email = request.getParameter("email");
8:     Class.forName("com.mysql.jdbc.Driver");
9:     Connection con = DriverManager.getConnection("jdbc:mysql://localhost:8080/dbname",
10:             "root", "NEWPASSWORD");
11:     Statement st = con.createStatement();
12:     ResultSet rs;

有人可以帮助我这是我的jsp连接到mysql代码。我不明白这个错误。

2 个答案:

答案 0 :(得分:0)

我的sql正在端口号 3306

上运行

因此你应该编写如下代码

Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/dbname","root", "NEWPASSWORD");

答案 1 :(得分:0)

String lname = request.getParameter("lname");
String email = request.getParameter("email");
Class.forName("com.mysql.jdbc.Driver");
  

Connection con = DriverManager.getConnection(“jdbc:mysql:// localhost:3306 / dbname”,               “root”,“NEWPASSWORD”);

Statement st = con.createStatement();
ResultSet rs;