Using liquibase with Altibase - liquibase

We already have an existing project with liquibase scripts (mysql, postgresql). Now we want to support a new database named Altibase. But when we run liquibase:dropAll liquibase:update we got:
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.5.3:dropAll
(default-cli) on project project-model: Error setting up or running Liquibase:
liquibase.exception.LockException: liquibase.exception.DatabaseException:
Data type module (Name="DATETIME") not found.
[Failed SQL:
CREATE TABLE ALTIBASE.DATABASECHANGELOGLOCK (
ID INT NOT NULL, LOCKED BOOLEAN NOT NULL, LOCKGRANTED datetime,
LOCKEDBY VARCHAR(255),
CONSTRAINT PK_DATABASECHANGELOGLOCK PRIMARY KEY (ID))] -> [Help 1]
Here's the pom's configuration:
<profile>
<id>altibase</id>
<activation>
<property>
<name>env</name>
<value>altibase</value>
</property>
</activation>
<properties>
<db.driver>Altibase.jdbc.driver.AltibaseDriver</db.driver>
<db.url>jdbc:Altibase://ourdomain.cloud:20001/ourdb</db.url>
<db.schema>ALTIBASE</db.schema>
<db.username>admin</db.username>
<db.password>admin</db.password>
</properties>
<dependencies>
<dependency>
<groupId>com.altibase</groupId>
<artifactId>Altibase</artifactId>
<version>1.0.1.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
Note that we installed Altibase jar locally via maven.

I guess the DB is not directly supported by liquibase. And it does not seem to have a data type DATETIME.
Checkout the section "Using Unsupported Databases" on the this site: https://www.liquibase.org/databases.html.
Maybe use the optional parameter --currentDateTimeFunction=<value>. Also see this site: https://www.liquibase.org/documentation/command_line.html

Altibase has DATE data type. And, It's DATE data type is same with other DBMSs' DATETIME data type.
Altibase's DATE data type can handle date data with micro seconds unit.

Related

"Cannot find database driver: Driver class was not specified and could not be determined from the url" error on using liquibase-hibernate plugin

I am trying to generate changeLog from diffs between a Database and Persistence Entities.
I am using the liquibase hibernate plugin
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
</configuration>
<dependencies>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate4</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.7.3.RELEASE</version>
</dependency>
</dependencies>
</plugin>
</plugins>
and my liquibase.properties goes like this
changeLogFile=classpath:liquibase-changeLog.xml
url=jdbc:postgres://localhost:5432/oauth_reddit
username=tutorialuser
password=tutorialmy5ql
driver=org.postgresql.Driver
referenceUrl=com.sample.App
?dialect=org.hibernate.dialect.PostgreSQLDialect
diffChangeLogFile=src/main/resources/liquibase-diff-changeLog.xml
while executing mvn liquibase:diff, I am getting the following error
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.4.1:diff (default-cli) on project prototype-liquibase-migration: Error setting up or running Liquibase: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url (com.sample.App?dialect=org.hibernate.dialect.PostgreSQLDialect) -> [Help 1]
I have specified the Driver in the liquibase properties, but it seems that it is not taking.What could have I done wrong ?
The problem was with my referenceUrl in liquibase.properties The referenceUrl is using package scan, so the url has to start with hibernate:spring:.
I changed
referenceUrl=com.sample.App?=org.hibernate.dialect.PostgreSQLDialect
into
referenceUrl=hibernate:spring:com.sample.App?dialect=org.hibernate.dialect.PostgreSQLDialect
This solved my problem.

Spring config server with JDBC is throwing Invalid config server configuration error

I want to use JDBC mysql with Spring cloud config server, but always failed, this is what I am doing:
Spring cloud version: Finchley.SR2
In POM.xml
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
Inside the application.config:
spring.profiles.active= jdbc
spring.datasource.url=jdbc:mysql://localhost:3306/config_db
spring.datasource.username=root
spring.datasource.password=12345
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.platform= mysql
spring.cloud.config.server.jdbc.sql= SELECT `key`, `value` FROM `properties` WHERE `application`=? AND `profile`=? AND `label`=?;
spring.cloud.config.server.jdbc.order=0
spring.cloud.config.server.default-profile=production
spring.cloud.config.server.default-label=latest
Finally, when I start server, I am getting below errors:
APPLICATION FAILED TO START
Description:
Invalid config server configuration.
Action:
If you are using the git profile, you need to set a Git URI in your configuration. If you are using a native profile and have spring.cloud.config.server.bootstrap=true, you need to use a composite configuration.
I am not using git here, why the error is about git url?
I had the same issue when used MySQL.
It seems to be an issue with MySQL JdbcTemplate (look here).
I switched to H2 to store configuration and it works.
I wonder if there any workaround to use MySQL?
I got the same error when I attempt to remove the DataSourceAutoConfiguration.class on start up i.e.
#SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
When I just used
#SpringBootApplication
everything worked as expected.
My reason for excluding the class was to stop the auto generation of a password on startup.

Eclipselink 2.7.3 not performing 'drop-and-create'

Using the following config in persistence.xml
<property name="eclipselink.flush-clear.cache" value="Drop"/>
<property name="eclipselink.cache.shared.default" value="false"/>
<property name="eclipselink.cache.shared" value="false"/>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
According to the docs that is the configuration:
EclipseLink will attempt to DROP all tables, then CREATE all tables.
If any issues are encountered, EclipseLink will follow the default
behavior of your specific database and JDBC driver combination, then
continue with the next statement.
This is useful in development if the schema frequently changes or
during testing when the existing data needs to be cleared.
Note: Using drop-and-create will remove all of the data in the tables
when they are dropped. You should never use option on a production
schema that has valuable data in the database. If the schema changed
dramatically, there could be old constraints in the database that
prevent the dropping of the old tables. This may require the old
schema to be dropped through another mechanism.
Using the following dependencies:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
<version>2.7.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.7.3</version>
</dependency>
What am I doing wrong ?

liquibase generateChangeLog changelogSchemaName

Is it possible to generate change log using generateChangeLog command for non default user schema. I've tried to do it using defaultSchemaName argument but it it didn't worked out. Liquibase is throwing
java.lang.RuntimeException: Cannot use default schema name myschema on M
icrosoft SQL Server because the login schema of the current user (dbo) is different and MSSQL does not support setting the default schema per session.
I've also tried to use maven plugin but only dbo schema has been dumped. Plugin configuration looks like follows:
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<propertyFile>src/main/liquibase.properties</propertyFile>
<changelogSchemaName>mySchema</changelogSchemaName>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
</configuration>
</plugin>
In my case I was able to get liquibase-maven-plugin to process a different schema via the property defaultSchemaName, which I put into a liquibase.properties file, referenced from the POM.
defaultSchemaName: EXAMPLE
I tried other properties with no luck.

Maven warning "Overriding profile: 'null'..."

What are possible causes of the following maven warning:
Overriding profile: 'null' (source: pom) with new instance from source: pom
I've tried commenting out my entire default profile as the warning mentions "profile", but that didn't help. I've also tried commenting out my reporting options and the warning still shows up.
I've ran maven with the -X flag and the warning shows up immediately after my hamcrest dependency is brought in, but commenting it out doesn't eliminate the warning.
EDIT: additional information per request:
Output from mvn help:active-profiles:
Active Profiles for Project 'com.sophware.XXX:main:jar:0.0.1-SNAPSHOT':
The following profiles are active:
- default (source: pom)
Output from mvn help:all-profiles:
[INFO] Listing Profiles for Project: com.sophware.XXX:main:jar:0.0.1-SNAPSHOT
Profile Id: default (Active: true , Source: pom)
default is indeed the id of the profile that I use in my pom. At this point, I only have one profile, although I expect to add more in the future.
Resolution:
Peter was right about the problem. The problem stems from not having an id element within a maven profile. In my case, a pom file was being pulled in because of my miglayout dependency.
Upon looking through the dependent pom's, I found that miglayout, indeed, does not use id's in its profiles:
<profile>
<activation>
<os>
<family>windows</family>
<arch>x86</arch>
</os>
</activation>
<dependencies>
<dependency>
<groupId>org.eclipse.swt.win32.win32</groupId>
<artifactId>x86</artifactId>
<version>3.3.0-v3346</version>
<optional>true</optional>
</dependency>
</dependencies>
</profile>
There's a number of other profiles missing id's as well as well, each of which cause the warning to be present.
This is easy to reproduce in Maven 2.2.9. The only cause of this is two maven profiles are defined without a profile id element in the same pom.xml, thus the ids are treated null. I don't know what the use case for such a profile is, but Maven 2.2.9 silently allows such a profile to exist, unless you try to override it of course - you get the mentioned warning.
Here is a simple pom that will reproduce the error. Notice the missing <id> element for each profile.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mngxxxx</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>parent</name>
<profiles>
<profile>
<activation>
<property><name>foo</name></property>
</activation>
</profile>
<profile>
<activation>
<property><name>foo</name></property>
</activation>
</profile>
</profiles>
</project>
Simply type mvn -X validate -Dfoo=true and you should see near the top of the output the warning message. This is caused by the second profile definition trying to override the first.
The relevant code in Maven 2 that emits this warning is in DefaultProfileManager.java line 123.
In Maven 3, this has changed. Using the latest maven 3.0-alpha-6 you get.
[ERROR] The build could not read 1 project -> [Help 1]
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[ERROR] profiles.profile.id must be unique but found duplicate profile with id default # org.apache.maven.its.mngxxxx:parent:1.0-SNAPSHOT, /Users/plynch/dev/apache/maven/core-integration-testing/mytests/mng-xxxx-IT/src/test/resources/mng-xxxx/pom.xml
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:285)
at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:402)
at org.apache.maven.DefaultMaven.getProjectsForMavenReactor(DefaultMaven.java:351)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:171)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:104)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:422)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:157)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
[ERROR] The project org.apache.maven.its.mngxxxx:parent:1.0-SNAPSHOT (/Users/plynch/dev/apache/maven/core-integration-testing/mytests/mng-xxxx-IT/src/test/resources/mng-xxxx/pom.xml) has 1 error
[ERROR] profiles.profile.id must be unique but found duplicate profile with id default
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
Notice also that the missing <id> will cause Maven 3 to apply a 'default' profile id.
Lastly in a multi-module build, should a parent pom define a profile with the same id as one in the child, there is no warning or other indication emitted from Maven.