Kurt,
Are you sure you are connecting to a MySQL database? The error message looks to
me more like coming from Derby than MySQL. I would say you are still connecting
to a Derby data source while having your OpenJPA properties set up for MySQL.
Cheers,
Milosz
> Hi guys,
>
> I'm working on the Apache jUDDI project and we use the JPA API for
> persistence. One of the JPA implementations we use is OpenJPA. We've
> been using Derby as our default database, which is working fine. However
> when switching it to MySQL I'm getting the following error when OpenJPA
> tries to create the juddiv3 tables:
>
> SEVERE: StandardWrapper.Throwable
> <openjpa-1.2.1-r752877:753278 nonfatal general error>
> org.apache.openjpa.persistence.PersistenceException: Syntax error:
> Encountered "TYPE" at line 1, column 163. {stmnt 7117250 CREATE TABLE
> j3_address (id BIGINT NOT NULL, sort_code VARCHAR(10), tmodel_key
> VARCHAR(255), use_type VARCHAR(255), address_id BIGINT NOT NULL, PRIMARY
> KEY (id)) TYPE = InnoDB} [code=30000, state=42X01]
> at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:553)
> at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:453)
> at
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:159)
> at
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:119)
> at
> org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:189)
> at
> org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
> at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
> at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145)
> at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
> at
> org.apache.juddi.config.PersistenceManager.getEntityManager(PersistenceManager.java:45)
> at
> org.apache.juddi.config.AppConfig.getPersistentConfiguration(AppConfig.java:101)
>
>
> The datasource (webapps/juddiv3/META-INF/context.xml) looks like:
>
> <Context>
> <WatchedResource>WEB-INF/web.xml</WatchedResource>
> <!--
> <Resource name="jdbc/JuddiDS" auth="Container"
> type="javax.sql.DataSource" username="" password=""
> driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
> url="jdbc:derby:juddi-derby-test-db;create=true"
> maxActive="8"
> />
> -->
>
> <!-- mysql -->
> <Resource name="jdbc/JuddiDS" auth="Container"
> type="javax.sql.DataSource" username="root" password=""
> driverClassName="com.mysql.jdbc.Driver"
> url="jdbc:mysql://localhost:3306/juddiv3"
> maxActive="8"
> />
> </Context>
>
> The persistence.xml
> (webapps/juddiv3/WEB-INF/classes/META-INF/persistence.xml) looks like
>
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence 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"
> version="1.0">
> <persistence-unit name="juddiDatabase" transaction-type="RESOURCE_LOCAL">
>
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
> <non-jta-data-source>java:comp/env/jdbc/JuddiDS</non-jta-data-source>
> <!-- entity classes -->
> <class>org.apache.juddi.model.Address</class>
> <class>org.apache.juddi.model.AddressLine</class>
> snip
> <class>org.apache.juddi.model.UddiEntityPublisher</class>
> <properties>
> <property name="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema(SchemaAction='add')"/>
> <property name="openjpa.Log" value="DefaultLevel=TRACE, Tool=INFO"/>
> <property name="openjpa.jdbc.UpdateManager" value="operation-order"/>
> <property name="openjpa.jdbc.DBDictionary"
> value="org.apache.openjpa.jdbc.sql.MySQLDictionary" />
> </properties>
> </persistence-unit>
>
> Why would it not be liking the "TYPE = InnoDB" at the end of the create
> statement (I want to use innodb)? The SQL looks fine to me. I'm using
> MySQL5 and mysql-connector-java-5.1.6.jar. OpenJPA version 2.1.3, Tomcat
> 6.0.20.
>
> Note that if reconfigure the persistence.xml to *not* use the tomcat
> datasource, but rather connect to MySQL directly like so:
>
> <!-- mysql connection properties -->
> <property name="openjpa.ConnectionURL"
> value="jdbc:mysql://localhost:3306/juddiv3"/>
> <property name="openjpa.ConnectionDriverName"
> value="com.mysql.jdbc.Driver"/>
> <property name="openjpa.ConnectionUserName" value="root"/>
> <property name="openjpa.ConnectionPassword" value=""/>
>
> then things work fine!
>
> Any help would be greatly appreciated! Does anyone have a working
> example of how to use a tomcat datasource?
>
> Thx,
>
> --Kurt
>