Hi everyone,
I set up a small project for my own use and ran into an issue when I tried to add Liquibase. I decided to use Derby DB that comes with GlassFish (3.1.1.).For some reasons I want to have Liquibase initialization embedded into my code.
In its simplest form the code that initializes the DB looks like this
@Singleton
@Startup
public class ServiceStarter {
.
.
.
@Resource(name=“jdbc/__default”)
private DataSource dataSource;
@PostConstruct
public void onInitialize() {
connection = dataSource.getConnection();
ResourceAccessor classLoaderResourceAccessor = new ClassLoaderResourceAccessor();
ResourceAccessor fileSystemResourceAccessor = new FileSystemResourceAccessor();
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
LOGGER.info(database.getDatabaseProductName());
LOGGER.info(database.getDatabaseProductVersion());
database.setDefaultSchemaName(“APP”);
Liquibase liquibase = new Liquibase(CHANGELOG_FILE_NAME,
new CompositeResourceAccessor(classLoaderResourceAccessor, fileSystemResourceAccessor), database);
liquibase.update(“production”);
When this method is run in a startup singleton EJB (@Startup annotated) it throws an exception:
liquibase.exception.LockException: liquibase.exception.DatabaseException: Error executing SQL
CREATE TABLE APP.DATABASECHANGELOGLOCK (ID INT NOT NULL, LOCKED BOOLEAN NOT NULL, LOCKGRANTED TIMESTAMP, LOCKEDBY VARCHAR(255), CONSTRAINT PK_DATABASECHANGELOGLOCK PRIMARY KEY (ID)); on jdbc:derby://localhost:1527/sun-appserv-samples;;create=true
Błąd składniowy: BOOLEAN.
The DB vendor and version written out by the LOGGER in the code above are Apache Derby and 10.6.2.1 - (999685) which seems correct.
I tried to run the CREATE TABLE statement manually in the DB and sure enough - it complains about the BOOLEAN colum.
I consulted Derby documentation (http://db.apache.org/derby/docs/10.6/ref/crefsqlj31068.html) and as one can see BOOLEAN is not on the list of allowed column types.
So it looks that Liquibase correctly recognizes the vendor (Derby) but then attempts to run a SQL statement that yields a syntax error in a Derby DB.
Is this a bug or am I missing somthing obvious? I’m using liquibase 2.0.3.
Best regards,
Konrad Ciborowski
Kraków, Poland