users@glassfish.java.net

(eclipse helios,GF 3.0.1,centOS) java.sql.SQLException: Can't create table

From: <forums_at_java.net>
Date: Thu, 14 Apr 2011 12:10:25 -0500 (CDT)

hello,

I'm using eclipse and glassfish, on centOS (like redhat).

it's eclipse helios, with the adapter for glassfish 3.0.1.

I created from a book some entities in a project, and an EJB project
contained in an EAR project.

the EAR project has some references from the EJB project and from the
JPA project (it's a java project).

when I deploy the EAR project, I 've got this error :

cannot Deploy ear2
Deployment Error for module: ear2: Error occurred during deployment:
Exception while loading the app : EJB Container initialization error. Please
see server.log for more details.
PER01003: Deployment encountered SQL Exceptions:
    PER01000: Got SQLException executing statement "CREATE TABLE
t_category (ID BIGINT NOT NULL, DESCRIPTION VARCHAR(255) NOT NULL, NAME
VARCHAR(30) NOT NULL, PRIMARY KEY (ID))":
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 't_category'
already exists
    PER01000: Got SQLException executing statement "CREATE TABLE t_product
(ID BIGINT NOT NULL, DESCRIPTION VARCHAR(255) NOT NULL, NAME VARCHAR(30) NOT
NULL, category_fk BIGINT NOT NULL, PRIMARY KEY (ID))":
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 't_product'
already exists
    PER01000: Got SQLException executing statement "CREATE TABLE t_item
(ID BIGINT NOT NULL, image LONGBLOB, NAME VARCHAR(30) NOT NULL, unit_cost
FLOAT NOT NULL, product_fk BIGINT NOT NULL, PRIMARY KEY (ID))":
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 't_item' already
exists
    PER01000: Got SQLException executing statement "CREATE TABLE
t_customer (ID BIGINT NOT NULL, date_of_birth DATE, EMAIL VARCHAR(255),
FIRSTNAME VARCHAR(30) NOT NULL, LASTNAME VARCHAR(30) NOT NULL, LOGIN
VARCHAR(8) NOT NULL UNIQUE, PASSWORD VARCHAR(8) NOT NULL, TELEPHONE
VARCHAR(255), address_fk BIGINT, PRIMARY KEY (ID))":
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 't_customer'
already exists
    PER01000: Got SQLException executing statement "CREATE TABLE t_address
(ID BIGINT NOT NULL, CITY VARCHAR(100) NOT NULL, COUNTRY VARCHAR(50) NOT
NULL, STATE VARCHAR(255), STREET1 VARCHAR(255) NOT NULL, STREET2
VARCHAR(255), zip_code VARCHAR(8) NOT NULL, PRIMARY KEY (ID))":
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 't_address'
already exists
    PER01000: Got SQLException executing statement "CREATE TABLE t_order
(ID BIGINT NOT NULL, order_date DATE, credit_card_expiry_date VARCHAR(5),
credit_card_number VARCHAR(30), credit_card_type VARCHAR(255), customer_fk
BIGINT NOT NULL, address_fk BIGINT NOT NULL, PRIMARY KEY (ID))":
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 't_order' already
exists
    PER01000: Got SQLException executing statement "CREATE TABLE
t_order_line (ID BIGINT NOT NULL, QUANTITY INTEGER NOT NULL, item_fk BIGINT
NOT NULL, PRIMARY KEY (ID))":
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 't_order_line'
already exists
    PER01000: Got SQLException executing statement "CREATE TABLE
t_order_order_line (order_fk BIGINT NOT NULL, order_line_fk BIGINT NOT NULL,
PRIMARY KEY (order_fk, order_line_fk))":
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table
't_order_order_line' already exists
    PER01000: Got SQLException executing statement "ALTER TABLE t_product
ADD CONSTRAINT FK_t_product_category_fk FOREIGN KEY (category_fk) REFERENCES
t_category (ID)": java.sql.SQLException: Can't create table
'base2.#sql-1e3b_fe' (errno: 121)
    PER01000: Got SQLException executing statement "ALTER TABLE t_item ADD
CONSTRAINT FK_t_item_product_fk FOREIGN KEY (product_fk) REFERENCES t_product
(ID)": java.sql.SQLException: Can't create table 'base2.#sql-1e3b_fe' (errno:
121)
    PER01000: Got SQLException executing statement "ALTER TABLE t_customer
ADD CONSTRAINT FK_t_customer_address_fk FOREIGN KEY (address_fk) REFERENCES
t_address (ID)": java.sql.SQLException: Can't create table
'base2.#sql-1e3b_fe' (errno: 121)
    PER01000: Got SQLException executing statement "ALTER TABLE t_order
ADD CONSTRAINT FK_t_order_address_fk FOREIGN KEY (address_fk) REFERENCES
t_address (ID)": java.sql.SQLException: Can't create table
'base2.#sql-1e3b_fe' (errno: 121)
    PER01000: Got SQLException executing statement "ALTER TABLE t_order
ADD CONSTRAINT FK_t_order_customer_fk FOREIGN KEY (customer_fk) REFERENCES
t_customer (ID)": java.sql.SQLException: Can't create table
'base2.#sql-1e3b_fe' (errno: 121)
    PER01000: Got SQLException executing statement "ALTER TABLE
t_order_line ADD CONSTRAINT FK_t_order_line_item_fk FOREIGN KEY (item_fk)
REFERENCES t_item (ID)": java.sql.SQLException: Can't create table
'base2.#sql-1e3b_fe' (errno: 121)
    PER01000: Got SQLException executing statement "ALTER TABLE
t_order_order_line ADD CONSTRAINT FK_t_order_order_line_order_fk FOREIGN KEY
(order_fk) REFERENCES t_order (ID)": java.sql.SQLException: Can't create
table 'base2.#sql-1e3b_fe' (errno: 121)
    PER01000: Got SQLException executing statement "ALTER TABLE
t_order_order_line ADD CONSTRAINT FK_t_order_order_line_order_line_fk FOREIGN
KEY (order_line_fk) REFERENCES t_order_line (ID)": java.sql.SQLException:
Can't create table 'base2.#sql-1e3b_fe' (errno: 121)
    PER01000: Got SQLException executing statement "CREATE TABLE SEQUENCE
(SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(38), PRIMARY KEY
(SEQ_NAME))": com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table
'SEQUENCE' already exists
    PER01000: Got SQLException executing statement "INSERT INTO
SEQUENCE(SEQ_NAME, SEQ_COUNT) values ('SEQ_GEN', 0)":
com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException:
Duplicate entry 'SEQ_GEN' for key 'PRIMARY'

the errors are multibles : some because I didn't cleared the database
(althought I specified "drop-and-create-tables" in the persistence.xml file),
and some due to an "error 121", whose I can't say nothing...I don't
understand.

I created a connection pool and a datasource in glassfish, and here is my
persistence.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<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="jpa3">
        <jta-data-source>jdbc/MyDS1</jta-data-source>
        <class>entities.Category</class>
        <class>entities.Product</class>
        <class>entities.Item</class>
        <class>entities.Customer</class>
        <class>entities.Address</class>
        <class>entities.Order</class>
        <class>entities.OrderLine</class>
        <class>entities.CreditCard</class>
        <properties>
            <property name="eclipselink.ddl-generation"
value="drop-and-create-tables" />
            <property name="eclipselink.ddl-generation.output-mode"
                value="database" />
            <property name="eclipselink.target-database"
value="MySQL" />
            <property name="eclipselink.logging.level" value="INFO"
/>

</properties>

can you help me?

 

olivier

 


--
[Message sent by forum member 'lolveley']
View Post: http://forums.java.net/node/792020