3
votes

I use Netbeans 8.0.2 on Windows. I wrote an example JSP page

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<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 APP.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>

but if I execute this page, I get

javax.servlet.ServletException: 
            SELECT name, city, state FROM APP.customer
        : Table/view 'APP.CUSTOMER' is not exist.

sample database is a demo Derby database. I use GlassFish Server 4.1, JDK 7, Java EE 7. All these are in the default installation of Netbeans. I use default settings of GlassFish Server.

I see sample database connection at Services tab. It is jdbc:derby://localhost:1527/sample. I see this url in SamplePool connection pool properties of GlassFish. This connection pool is used in jdbc/sample JDBC resource. APP.CUSTOMER table is exist in sample database.

What do I do wrong?

1

1 Answers

3
votes

I'm not sure what is wrong but try the following:

  • copy derbyclient.jar from glassfish4/javadb/lib to glassfish4/glassfish/lib/endorsed
  • restart Glassfish
  • change your code to the following:

    <sql:setDataSource var="snapshot" driver="org.apache.derby.jdbc.ClientDataSource"
                       url="jdbc:derby://localhost:1527/sample"
                       user="app"  password="app"/>
    <sql:query var="allRows" dataSource="${snapshot}">
        SELECT name, city, state FROM APP.customer
    </sql:query>
    

To play with a basic example this should be sufficient, but you may not want to use it in production.