在class.formname那里报错,错误提示语法错误,看不出来在哪啊,没错啊?
pageEncoding="utf-8"%>
图书清单table {
border: 2px #CCCCCC solid;
width: 360px;
}
td,th {
height: 30px;
border: #CCCCCC 1px solid;
}
//驱动程序名
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);
%>
out.print("图书名称"); %> | out.print("作者"); %> | out.print("出版社"); %> | out.print("出版日期"); %> | out.print("类别"); %> |
---|
while (rs.next()) {
%>
out.print(rs.getString(1));
%>
out.print(rs.getString(2));
%>
out.print(rs.getString(3));
%>
out.print(rs.getString(4));
%>
out.print(rs.getString(5));
%>
}
%>
out.print("数据查询成功,恭喜你");
%>
rs.close();
statement.close();
connection.close();
%>