我在Netbeans平台应用程序中看到此输出,我正在使用JPA和嵌入式derby数据库。我希望我的数据库在用户根目录中创建,如果它尚不存在,那么用户没有其他配置。有谁知道下面的例外消息或警告是否会成为问题?
derby.system.home=/home/simgineer/.simdriver
derby.stream.error.file=/home/simgineer/.simdriver/log/derby.log
[EL Info]: 2012-09-12 11:46:42.397--ServerSession(177592104)--file:/home/simgineer/NetBeansProjects/SimDriver/build/cluster/modules/ext/MyDbLib.jar_VmCfgLibPU login successful
Database Class Loader started - derby.database.classpath=''
[EL Warning]: 2012-09-12 11:46:42.763--ServerSession(177592104)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Table/View 'VMCFG' already exists in Schema 'APP'.
Error Code: 30000
Call: CREATE TABLE APP.VMCFG (ID BIGINT NOT NULL, BOOT VARCHAR(30), CDROM VARCHAR(60), CPU VARCHAR(30), ENABLEKVM SMALLINT, HDA VARCHAR(80), MACADDR VARCHAR(30), SOUNDHW VARCHAR(30), VMNAME VARCHAR(30) NOT NULL, PRIMARY KEY (ID))
Query: DataModifyQuery(sql="CREATE TABLE APP.VMCFG (ID BIGINT NOT NULL, BOOT VARCHAR(30), CDROM VARCHAR(60), CPU VARCHAR(30), ENABLEKVM SMALLINT, HDA VARCHAR(80), MACADDR VARCHAR(30), SOUNDHW VARCHAR(30), VMNAME VARCHAR(30) NOT NULL, PRIMARY KEY (ID))")
[EL Warning]: 2012-09-12 11:46:42.876--ServerSession(177592104)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Table/View 'SEQUENCE' already exists in Schema 'APP'.
Error Code: 30000
Call: CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(15), PRIMARY KEY (SEQ_NAME))
Query: DataModifyQuery(sql="CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(15), PRIMARY KEY (SEQ_NAME))")
这是我的persistence.xml
<persistence version="2.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_2_0.xsd">
<persistence-unit name="VmCfgLibPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>mycompany.jpa.Vmcfg</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:derby:myDB;create=true"/>
<property name="javax.persistence.jdbc.password" value="app"/>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<property name="javax.persistence.jdbc.user" value="app"/>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
答案 0 :(得分:1)
您获得的例外情况是因为您多次运行应用程序而不删除表。您可能希望查看此问题及其答案JPA and toplink create-table on if they don't already exist?