1

I'm seeing this output in a Netbeans platform app where i'm using JPA with and embedded derby database. I want my db to be created in the user root directory if it does not already exist so there is no additional configuration by the user. Does anyone know if the Exceptions messages or warnings below will be an issue?

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))")

Here is my 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>
simgineer
  • 1,754
  • 2
  • 22
  • 49

1 Answers1

1

The exceptions you are getting are because you run your application several times without dropping the tables. You might want to look at this question and its answers JPA and toplink create-table on if they don't already exist?

Community
  • 1
  • 1
sheidaei
  • 9,842
  • 20
  • 63
  • 86
  • 1
    Thanks for the link. I don't want to drop the tables if they already exist as I'm using this in an embedded mode and don't want to have extra steps for the user to create the db. Its funny there is an excepted answer on the question you linked but it doesn't answer the question but says you can generate DDL script instead. I just want the system to not try to create the table if it already exist as advertised in the spec that Pascal mentioned. – simgineer Sep 12 '12 at 20:31