jsp连接MySQL问题 要疯了,请各位大虾帮帮忙啊!!!跪谢
这是我按照网上说的配置的环境变量:我就编写了以下代码,测试与mysql的连接:名字是first.jsp,并将其放在了tomcat\webapps\myapp\first....
这是我按照网上说的配置的环境变量:
我就编写了以下代码,测试与mysql的连接:名字是first.jsp,并将其放在了tomcat\webapps\myapp\first.jsp中, myapp是我新建的目录
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page contentType="text/html;charset=GB2312"%>
<html>
<head>
<title>first.jsp
</title></head>
<body>
<% try
{
Connection con;
Statement stmt;
ResultSet rs;
Class.forName("com.mysql.jdbc.Driver");
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
String dbUrl= "jdbc:mysql://localhost:3306/first?useUnicode=true&characterEncoding=GB2312";
String dbUser="test";
String dbPwd ="123456";
con = java.sql.DriverManager.getConnection(dbUrl,dbUser,dbPwd);
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT id,name from about");
out.println("<table border =1 width=400>");
while(rs.next())
{
int col1 =rs.getInt(1);
String col2 =rs.getString(2);
out.println("<tr><td>"+col1+"</td><td>"+col2+"</td><td>");
}
out.println("</table>");
rs.close();
stmt.close();
con.close();
}
catch(Exception e){ out.println(e.getMessage());}
%>
</body></html>
启动tomcat后,输入 http://localhost:8080/myapp/first.jsp
请问这是什么问题啊,,我都快急死了,都上火了,配了好几个礼拜了,请帮忙!!!!
我的qq84509893,那位可以给我讲讲啊,急毕设!
刚才那个错误是:
然后就产生错误提示:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:553)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:136)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:307)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802) 展开
我就编写了以下代码,测试与mysql的连接:名字是first.jsp,并将其放在了tomcat\webapps\myapp\first.jsp中, myapp是我新建的目录
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page contentType="text/html;charset=GB2312"%>
<html>
<head>
<title>first.jsp
</title></head>
<body>
<% try
{
Connection con;
Statement stmt;
ResultSet rs;
Class.forName("com.mysql.jdbc.Driver");
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
String dbUrl= "jdbc:mysql://localhost:3306/first?useUnicode=true&characterEncoding=GB2312";
String dbUser="test";
String dbPwd ="123456";
con = java.sql.DriverManager.getConnection(dbUrl,dbUser,dbPwd);
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT id,name from about");
out.println("<table border =1 width=400>");
while(rs.next())
{
int col1 =rs.getInt(1);
String col2 =rs.getString(2);
out.println("<tr><td>"+col1+"</td><td>"+col2+"</td><td>");
}
out.println("</table>");
rs.close();
stmt.close();
con.close();
}
catch(Exception e){ out.println(e.getMessage());}
%>
</body></html>
启动tomcat后,输入 http://localhost:8080/myapp/first.jsp
请问这是什么问题啊,,我都快急死了,都上火了,配了好几个礼拜了,请帮忙!!!!
我的qq84509893,那位可以给我讲讲啊,急毕设!
刚才那个错误是:
然后就产生错误提示:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:553)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:136)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:307)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询