我正在创建我的第一个RestFul应用程序,我在Java / Netbeans开发方面缺乏经验。
我有一个包含很少表的MySQL数据库;我基于数据库创建了一个新的Web应用程序项目和实体类。然后我基于实体类创建了一个RestFul Web服务。
一切都很好,直到这一点。
当我尝试测试RestFul服务时,我得到 error
:
type Exception report
messageInternal Server Error
descriptionThe server encountered an internal error that prevented it
from fulfilling this request.
exception
javax.servlet.ServletException: javax.ejb.EJBException root cause
javax.ejb.EJBException root cause
javax.persistence.PersistenceException: Exception [EclipseLink-4002]
(Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd):
org.eclipse.persistence.exceptions.DatabaseException Internal
Exception: java.sql.SQLSyntaxErrorException: Table/View 'PERSON' does
not exist. Error Code: 30000 Call: SELECT id, email, first_name,
last_name FROM person Query: ReadAllQuery(referenceClass=Person
sql="SELECT id, email, first_name, last_name FROM person") root cause
Exception [EclipseLink-4002] (Eclipse Persistence Services -
2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal
Exception: java.sql.SQLSyntaxErrorException: Table/View 'PERSON' does
not exist. Error Code: 30000 Call: SELECT id, email, first_name,
last_name FROM person Query: ReadAllQuery(referenceClass=Person
sql="SELECT id, email, first_name, last_name FROM person") root cause
java.sql.SQLSyntaxErrorException: Table/View 'PERSON' does not exist.
root cause
org.apache.derby.client.am.SqlException: Table/View 'PERSON' does not
exist.
这是我的 glassfish-resources.xml file
<resources>
<jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="mysql_shoppinglist_db_rootPool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
<property name="serverName" value="localhost"/>
<property name="portNumber" value="3306"/>
<property name="databaseName" value="shoppinglist_db"/>
<property name="User" value="root"/>
<property name="Password" value="xxxxxxxx"/>
<property name="URL" value="jdbc:mysql://localhost:3306/shoppinglist_db?zeroDateTimeBehavior=convertToNull"/>
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
</jdbc-connection-pool>
<jdbc-resource enabled="true" jndi-name="shoppinglist_db" object-type="user" pool-name="mysql_shoppinglist_db_rootPool"/>
</resources>
persistence.xml file
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="ShoppingListPU" transaction-type="JTA">
<jta-data-source>shoppinglist_db</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties/>
</persistence-unit>
</persistence>
我检查过,我确实可以访问数据库并存在表格。
请帮助我,我不知道该怎么做。
由于