0
我想用jsp數據檢索,但它顯示 錯誤連接到MS SQL數據庫時處理JSP頁面/databaseTest.jsp例外,在第13行JSP示例使用Tomcat
我的代碼是:
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.io.*,java.util.*,java.sql.*" %>
<%@page import="javax.servlet.http.*,javax.servlet.*" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSTL sql:query Tag</title>
</head>
<body>
<sql:setDataSource var="ds" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/JSPTUTORIAL"
user="root" password="root"/>
<sql:query dataSource="${ds}" var="result">
SELECT * FROM Employees;
</sql:query>
<h4>Employee Table</h4>
<table border="1" width="100%">
<tr>
<th>Employee ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Age</th>
</tr>
<c:forEach var="row" items="${result.rows}"/>
<tr>
<td><c:out value="${row.id}"/></td>
<td><c:out value="${row.first}"/></td>
<td><c:out value="${row.last}"/></td>
<td><c:out value="${row.age}"/></td>
</tr>
</table>
</body>