Search code examples
javaspringhibernatedb2appfuse

Appfuse 3.5 and DB2


I am trying to create a webapp using appfuse. By default appfuse configures the app to work with a MySQL database, however I'd like use a DB2 database. Since Appfuse uses hibernate and Spring this should be a fairly straightforward configuration change but I haven't been able to get it to work. I get the following error on all my SQL calls:

create table role (
    id bigint generated by default as identity,
    description varchar(64),
    name varchar(20),
    primary key (id)
);
HHH000389: Unsuccessful: create table role (id bigint generated by default as identity, description varchar(64), name varchar(20), primary key (id))
DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=;;imary key (id));END-OF-STATEMENT, DRIVER=4.19.26

Here is how I have configured hibernate and the jdbc connection:

<jdbc.groupId>com.ibm.db2</jdbc.groupId>
<jdbc.artifactId>db2jcc4</jdbc.artifactId>
<jdbc.version>10.5</jdbc.version>
<jdbc.driverClassName>com.ibm.db2.jcc.DB2Driver</jdbc.driverClassName>
<jdbc.url>jdbc:db2://<IP Address>:<Port>/<DBName>:currentSchema=<schemaName>;</jdbc.url>
<jdbc.username><username></jdbc.username>
<jdbc.password><password></jdbc.password>
<jdbc.validationQuery><![CDATA[SELECT 1 FROM sysibm.sysdummy1;]]></jdbc.validationQuery>

<hibernate.dialect>org.hibernate.dialect.DB2Dialect</hibernate.dialect>

I don't understand where I'm going wrong. I can use the same db2jcc4.jar and connection parameters to connect to the DB through netbeans and copy and paste the sql from above and it executes without error. So I don't believe it's a syntax error as the SQLCODE=104, SQLSTATE42601 indicates. I'm at a loss of what I'm doing wrong. Any help you can give me is greatly appreciated!


Solution

  • I'm not sure if this is the correct answer but it worked: I removed the validation Query.

    If anyone knows of a better answer or why this worked please share.

    Thank you!