title: java.sql.SQLSyntaxErrorException: Table/View 'x' does not exist
body: <p>I am trying to run a web application called <code>AddressBook</code> (JSF with Facelets) in the NetBeans 8.0.2 IDE with GlassFish 4.1 that accesses a relational database via the following code in the managed bean:</p>
  
  <pre><code>@Resource( name="jdbc/addressbook" )
  DataSource dataSource;
  </code></pre>
  
  <p>When I run the application I get the following error in the browser:</p>
  
  <pre><code>java.sql.SQLSyntaxErrorException: Table/View 'ADDRESSES' 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 addressbook.AddressBean.getAddresses(AddressBean.java:157)
  </code></pre>
  
  <p>AddressBean.java line 157 is:</p>
  
  <pre><code>PreparedStatement getAddresses = connection.prepareStatement(
              "SELECT FIRSTNAME, LASTNAME, STREET, CITY, STATE, ZIP " +
              "FROM ADDRESSES ORDER BY LASTNAME, FIRSTNAME" );
  </code></pre>
  
  <p><strong>The addressbook database which contains the ADDRESSES table is created via the following steps:</strong> </p>
  
  <ol>
  <li><p>Create Connection Pool</p>
  
  <ol>
  <li>Right click on GlassFish server and select View Domain Admin Console  </li>
  <li>In the GlassFish web page in Common Tasks on the left column click on </li>
  <li>JDBC Connection Pools  </li>
  <li>Clicked the New Button and added the following entries:<br>
  <ul>
  <li>AddressBookPool for the Name  </li>
  <li>javax.sql.DataSource for Resource Type   </li>
  <li>JavaDB for the Database Vendor  </li>
  </ul></li>
  <li>Click Next and scroll to Additional Properties and set the following 
  fields:<br>
  <ul>
  <li>Attributes:  ;create=true  </li>
  <li>DatabaseName: addressbook  </li>
  <li>Password: APP  </li>
  <li>Click Finish  </li>
  </ul></li>
  </ol></li>
  <li><p>Create Data Source Name</p>
  
  <ol>
  <li>In the GlassFish web page in Common Tasks on the left column click on<br>
  JDBC  Resources</li>
  <li>Click the New Button and specify JDBC/addressbook as the JNDI name  </li>
  <li>Select AddressBookPool as the Pool name  </li>
  </ol></li>
  </ol>
  
  <p>When I return to the NetBeans Services tab, addressbook has been created under Java DB.    </p>
  
  <p>I successfully connect to the database:  jdbc:derby://localhost:1527/addressbook [APP on APP] and make APP the default schema</p>
  
  <p>I open a file in NetBeans: addressbook.sql which contains SQL  to populate   addressbook.  I run it on the above connection and ADDRESSES table is created   and I am able to view the data. </p>
  
  <p>The AddressBook properties has Java DB Driver as a library.  </p>