Q:

Netbeans Error : Schema doesnt exist

So i am trying to access my underlying database in java application in netbeans through a simple jsp page :
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<sql:query var="rslt" dataSource="jdbc/cart">
   select isbn, title, quantity, price from dbsample.books
</sql:query>
<html>
<head>
     <title>JDBC Connection Test</title>
 </head>
 <body>
    <h1>Available books:</h1>
    <c:forEach var="book" items="${rslt.rows}">
        <b>Isbn:</b> ${book.isbn}<br/>
        <b>Title:</b> ${book.title}<br/>
        <b>Price:</b> $${book.price}<br/>
        <b>In stock:</b> ${book.quantity}<br/>
        <br/>
    </c:forEach>
 </body>
</html>

but i am getting this error : 

select isbn, title, quantity, price from dbsample.books : Schema 'DBSAMPLE' does not exist

This is the stack trace:

javax.servlet.ServletException: 
      select isbn, title, quantity, price from dbsample.books
  : Schema 'DBSAMPLE' does not exist
      at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:951)
      at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:886)
      at org.apache.jsp.testPage_jsp._jspService(testPage_jsp.java:80)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
      at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:875)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:739)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:575)
      at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:546)
      at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:428)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:378)
      at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:630)
      at com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:363)
      at com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:153)
      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:99)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
      at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
      at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
      at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
      at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
      at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
      at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
      at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
      at java.lang.Thread.run(Thread.java:724)
  Caused by: java.sql.SQLSyntaxErrorException: Schema 'DBSAMPLE' does not exist
      at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
      at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
      at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
      at com.sun.gjc.spi.base.ConnectionHolder.prepareStatement(ConnectionHolder.java:586)
      at com.sun.gjc.spi.jdbc40.ConnectionWrapper40.prepareCachedStatement(ConnectionWrapper40.java:255)
      at com.sun.gjc.spi.jdbc40.ConnectionWrapper40.prepareCachedStatement(ConnectionWrapper40.java:52)
      at com.sun.gjc.spi.ManagedConnectionImpl.prepareCachedStatement(ManagedConnectionImpl.java:992)
      at com.sun.gjc.spi.jdbc40.ConnectionWrapper40.prepareStatement(ConnectionWrapper40.java:173)
      at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doEndTag(QueryTagSupport.java:255)
      at org.apache.jsp.testPage_jsp._jspx_meth_sql_query_0(testPage_jsp.java:119)
      at org.apache.jsp.testPage_jsp._jspService(testPage_jsp.java:60)
      ... 47 more
  Caused by: org.apache.derby.client.am.SqlException: Schema 'DBSAMPLE' does not exist
      at org.apache.derby.client.am.Statement.completeSqlca(Unknown Source)
      at org.apache.derby.client.net.NetStatementReply.parsePrepareError(Unknown Source)
      at org.apache.derby.client.net.NetStatementReply.parsePRPSQLSTTreply(Unknown Source)
      at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
      at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
      at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
      at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
      at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
      at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
      at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
      at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
      ... 56 more

Now i have checked my web.xml. the deployment descriptor is correct to the best of my knowledge. I have checked my datasource it seems correct to according to my persistance.xml I pinged the database pool and it was successful too. My schema is named dbsample and has a table named books. 
So i cant figure out why it is saying to my DBSAMPLE doesnt exist. Any help would be highly appreciated.
EDIT # 1 when executing the sql command in database it works totally fine.

A:

Although I might be a little late to answer this, but I came across the same problem and solved it. 
The problem was that I did not set the JDBC resource in my persistnece.xml. I added this to my persistence.xml:
<jta-data-source>jdbc/resourcename</jta-data-source>

Change jdbc/resourcename to your JDBC resource!

