在class.formname那里报错,错误提示语法错误,看不出来在哪啊,没错啊?
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ page import="com.mysql.jdbc.Connection" %>
<%@ page import="com.mysql.jdbc.ResultSet" %>
<%@ page import="com.mysql.jdbc.Statement" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>图书清单</title>
<style type="text/css">
table {
border: 2px #CCCCCC solid;
width: 360px;
}
td,th {
height: 30px;
border: #CCCCCC 1px solid;
}
</style>
</head>
<body>
<%
//驱动程序名
String driverName = "com.mysql.jdbc.Driver";
//数据库用户名
String userName = "root";
//密码
String userPasswd = "";
//数据库名
String dbName = "hibernate";
//表名
String tableName = "book";
//联结字符串
String url = "jdbc:mysql://localhost:3306/" + dbName + "?user="+ userName + "&password=" + userPasswd;
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = (Connection)DriverManager.getConnection(url);
Statement statement = (Statement) connection.createStatement();
String sql = "SELECT * FROM " + tableName;
ResultSet rs = (ResultSet)statement.executeQuery(sql);
%>
<br>
<br>
<table align="center">
<tr>
<th>
<%
out.print("图书名称");
%>
</th>
<th>
<%
out.print("作者");
%>
</th>
<th>
<%
out.print("出版社");
%>
</th>
<th>
<%
out.print("出版日期");
%>
</th>
<th>
<%
out.print("类别");
%>
</th>
</tr>
<%
while (rs.next()) {
%>
<tr>
<td>
<%
out.print(rs.getString(1));
%>
</td>
<td>
<%
out.print(rs.getString(2));
%>
</td>
<td>
<%
out.print(rs.getString(3));
%>
</td>
<td>
<%
out.print(rs.getString(4));
%>
</td>
<td>
<%
out.print(rs.getString(5));
%>
</td>
</tr>
<%
}
%>
</table>
<div align="center">
<br> <br> <br>
<%
out.print("数据查询成功,恭喜你");
%>
</div>
<%
rs.close();
statement.close();
connection.close();
%>
</body>
</html>
慕标琳琳
神不在的星期二
相关分类