主题:jsp连接数据库遇到的问题??
程序的意思是:连接数据库查询数据库的所有内容
<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<table border=1>
<tr><td>id</td><td>name</td><td>age</td><td>part</td></tr>
<%
Class.forName("com.mysl.jdbc.Driver");
Connection con=java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","root");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from student");
while(rs.next()){
out.println("<tr>");
out.println("<td>"+rs.getString("id")+"</td>");
out.println("<td>"+rs.getString("name")+"</td>");
out.println("<td>"+rs.getString("age")+"</td>");
out.println("<td>"+rs.getString("part")+"</td>");
out.println("</tr>");
}
rs.close();
stmt.close();
con.close();
%>
</table>
</body>
</html>
出现的问题是:javax.servlet.ServletException: com.mysl.jdbc.Driver
可是我已经把mysql驱动的.jar文件放到WEB-INF\lib\了
如何解决请各位帮帮忙了.
<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<table border=1>
<tr><td>id</td><td>name</td><td>age</td><td>part</td></tr>
<%
Class.forName("com.mysl.jdbc.Driver");
Connection con=java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","root");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from student");
while(rs.next()){
out.println("<tr>");
out.println("<td>"+rs.getString("id")+"</td>");
out.println("<td>"+rs.getString("name")+"</td>");
out.println("<td>"+rs.getString("age")+"</td>");
out.println("<td>"+rs.getString("part")+"</td>");
out.println("</tr>");
}
rs.close();
stmt.close();
con.close();
%>
</table>
</body>
</html>
出现的问题是:javax.servlet.ServletException: com.mysl.jdbc.Driver
可是我已经把mysql驱动的.jar文件放到WEB-INF\lib\了
如何解决请各位帮帮忙了.