问题遇到的现象和发生背景
org.apache.jasper.JasperException: 在 [16] 行处理 [/NewFile.jsp] 时发生异常
问题相关代码
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<html>
<head>
<title>通过JSP打开数据表</title>
</head>
<body>
<%
out.print("JSP");
Class.forName("com.mysql.cj.jdbc.Driver"); //驱动程序名
String url="jdbc:mysql://localhost:3306/scott?"+
"useSSL=false&serverTimezone=CST&characterEncoding=utf-8"; //数据库名
String user = "root"; //数据库用户名
String password = "123456"; //数据库用户密码
Connection conn = DriverManager.getConnection(url, user, password);//连接状态
if(conn != null){
out.print("数据库连接成功!");
out.print("<br />");
Statement stmt = null;
ResultSet rs = null;
String sql = "SELECT *FROM emp;"; //查询语句
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
out.print("查询结果:");
out.print("<br />");
out.println("姓名"+" "+"工作 "+" "+"薪金");
out.print("<br />");
while (rs.next()) {
out.println(rs.getString("ENAME")+"   "+rs.getString("JOB")+"   "+rs.getInt("SAL")); //将查询结果输出
}
}
else{
out.print("连接失败!");
}
%>
</body>
</html>