Java org.apache.derby.client.am.SqlException JSP和JSTL查询
我需要帮助。我使用的是JavaDB,这是一个集成了netbeans的服务器 但是当我尝试从jsp页面内部使用JSTL查询时,会触发一个错误。我正在读一本书,但是我不能在我的电脑上执行代码。我相信我的数据库服务器配置有问题 错误 web.xmlJava org.apache.derby.client.am.SqlException JSP和JSTL查询,java,jsp,java-ee-6,Java,Jsp,Java Ee 6,我需要帮助。我使用的是JavaDB,这是一个集成了netbeans的服务器 但是当我尝试从jsp页面内部使用JSTL查询时,会触发一个错误。我正在读一本书,但是我不能在我的电脑上执行代码。我相信我的数据库服务器配置有问题 错误 web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<resource-ref>
<res-ref-name>jdbc/sample</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</web-app>
30
jdbc/示例
javax.sql.DataSource
容器
可分享
index.jsp
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
Document : index
Created on : Aug 28, 2010, 7:52:34 PM
Author : heffel
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!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>JSP Page</title>
</head>
<body>
<h2>Hello World!</h2>
<sql:query var="allRows" dataSource="jdbc/sample">
SELECT name, city, state FROM customer
</sql:query>
<table border="1">
<thead>
<tr>
<th>Name</th>
<th>Location</th>
</tr>
</thead>
<tbody>
<c:forEach var="currentRow"
items="${allRows.rows}">
<tr>
<td>${currentRow.name}</td>
<td>${currentRow.city},
${currentRow.state}
</td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
JSP页面
你好,世界!
从客户中选择名称、城市、州
名称
位置
${currentRow.name}
${currentRow.city},
${currentRow.state}
您在哪里调用此查询:从产品中选择*代码>它似乎不在您的index.jsp
页面中。对不起。我更正了代码,但程序继续显示此错误错误非常自我描述,您的模式中是否真的有表customer
?您是否正确配置了数据源
连接池?如何配置?我很抱歉,如果您使用Tomcat作为应用程序服务器,您应该阅读本文:
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
Document : index
Created on : Aug 28, 2010, 7:52:34 PM
Author : heffel
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!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>JSP Page</title>
</head>
<body>
<h2>Hello World!</h2>
<sql:query var="allRows" dataSource="jdbc/sample">
SELECT name, city, state FROM customer
</sql:query>
<table border="1">
<thead>
<tr>
<th>Name</th>
<th>Location</th>
</tr>
</thead>
<tbody>
<c:forEach var="currentRow"
items="${allRows.rows}">
<tr>
<td>${currentRow.name}</td>
<td>${currentRow.city},
${currentRow.state}
</td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>