在java类中写了测试可以运行,但是到jsp中无法运行
问题相关代码,请勿粘贴截图
<%
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/first", "root", "root");
String sql = "select * from student";
PreparedStatement preparedStatement = connection.prepareStatement(sql);
ResultSet resultSet = preparedStatement.executeQuery();
while (resultSet.next()){
out.print(resultSet.getInt("Sno")+" ");
out.print(resultSet.getString("Sname")+" ");
out.print(resultSet.getInt("Sage")+" ");
out.print(resultSet.getString("Ssex")+" ");
out.print(resultSet.getString("Sdept")+" "+"
");
}
resultSet.close();
preparedStatement.close();
connection.close();
%>
运行结果及报错内容
数据库密码什么的都对,