users@glassfish.java.net

java.sql.SQLSyntaxErrorException:table 'WEB_BOOKSTORE_BOOKS' does not exist

From: <glassfish_at_javadesktop.org>
Date: Tue, 31 Mar 2009 06:53:25 PDT

Hi everybody,

I know there is a thread having the same subject by Jose Alvarez de Lara, but the answer he got does not seem to work for me.
I am also trying to run the Books example from the Java EE Tutorial. I use Eclipse, Glassfishv3-prelude and the JavaDB which came with the server. As persistence provider I use EclipseLink, which also came with the server.
I have made a database BookDB, and populated the table WEB_BOOKSTORE_BOOKS in schema APP. I can make a connection to this database using Data Tools in Eclipse and the ping succeeds.
On the server I made a connection pool (BookDBPool) for this database, and here the ping also succeeds. I made a jdbc-resource jdbc/BookDB for this connection pool.
This is persistence.xml :
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
  <persistence-unit name="book" transaction-type="JTA">
          <!-- provider>oracle.toplink.essentials.PersistenceProvider</provider> -->
          <jta-data-source>jdbc/BookDB</jta-data-source>
          <class>com.sun.bookstore.database.Book</class>
  </persistence-unit>
</persistence>
I removed the <provider> tag, so it uses the default provider, EclipseLink.

In my entity class is the following Table-annotation:
@Entity
@Table(name = "WEB_BOOKSTORE_BOOKS", schema = "APP")
public class Book implements Serializable {.....

The application deploys without warnings or errors. When I try to run, I get:
SEVERE: StandardWrapperValve[BookStoreServlet]: PWC1406: Servlet.service() for servlet BookStoreServlet threw exception
Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 1.0.1 (Build 20080905)): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: Table/View 'APP.WEB_BOOKSTORE_BOOKS' does not exist.
Error Code: -1
Call: SELECT BOOKID, INVENTORY, SURNAME, PRICE, FIRSTNAME, CALENDAR_YEAR, ONSALE, TITLE, DESCRIPTION FROM APP.WEB_BOOKSTORE_BOOKS WHERE (BOOKID = ?)
        bind => [203]
Query: ReadObjectQuery(com.sun.bookstore.database.Book)
        at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:322)

I also tried this with
@Table(name = "WEB_BOOKSTORE_BOOKS")
and with
@Table(name = "APP.WEB_BOOKSTORE_BOOKS")
but that did not help.

I consulted the EclipseLink tutorials on this @Table annotation, but I can't find any clues as to what I am missing. How should I specify the name of the table?

Regards, Dries Knottnerus
[Message sent by forum member 'driesknottnerus' (driesknottnerus)]

http://forums.java.net/jive/thread.jspa?messageID=339852