Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [kapua-dev] Using the KapuaLiquibaseClient with an external H2 database

Hi,

I successfuly got the liquibase client to connect to an external DB using this :

new KapuaLiquibaseClient("jdbc:h2:tcp://localhost:3306/kapuadb;MODE=MySQL",
"kapua", "kapua", Optional.of("kapuadb")).update();

Now I am encountering the same issue : DATABASECHANGELOG is created twice by the liquibase client, hence raising an error.

During tests I also found something else, but i am not sure it is a bug : when this script is executed (  kapua/commons/src/main/resources/liquibase/0.3.0/system_configuration-id_check_positive.xml ) it raise an error because it tries to access the tables directly (e.g. ALTER TABLE sys_configuration instead of ALTER TABLE KAPUADB.sys_configuration). what do you think ?

thanks !



On Mon, Nov 26, 2018 at 9:47 AM Jean-Baptiste Trystram <jbtrystram@xxxxxxxxxx> wrote:
Hello Stefano !

Thanks for your suggestion. I had tried this before, but gave it a go again to be sure.. In my case it do not work for my application, for some reason.
I tried to add the options running the tests as well but they are also ignored. I what conditions the JVM env variables are taken into account ?

On Thu, Nov 22, 2018 at 7:54 PM Morson, Stefano <stefano.morson@xxxxxxxxxxxx> wrote:

Hi Jean-Baptiste,


    before going into more details about the context, I would try with setting the following system variables at the JVM level:


-Dcommons.db.schema.update=true

-Dcommons.db.connection.host=<your-host> (e.g. 127.0.0.1)

-Dcommons.db.connection.port=3306 


they override the defaults in the kapua-environment-setting.properties file, other defaults are usually ok (i.e. if you don't need specific schema names). Sometimes this is enough to let it start successfully but it depends on the your application setup.

S


From: kapua-dev-bounces@xxxxxxxxxxx <kapua-dev-bounces@xxxxxxxxxxx> on behalf of Jean-Baptiste Trystram <jbtrystram@xxxxxxxxxx>
Sent: Thursday, November 22, 2018 4:47:02 PM
To: kapua-dev@xxxxxxxxxxx
Subject: [kapua-dev] Using the KapuaLiquibaseClient with an external H2 database
 
Hello,

I am trying to use the Kapua Device Registry engine to implement the Hono Device registry API. In order to to that I used the original work of Dejan B. that you can find here.
I have a small PoC application working and I want to have this running in the proper docker way, i.e. splitting the application between several containers.

In order to do that I need to use the liquibase client to connect to an external database, accessible through the network.
I've been playing a little bit with the client and there is an issue when I tried to set the Jdbc URL to an external server.
The issue is that the LiquibaseClient will try to create "DATABASECHANGELOG" multiple times.

Here is my test scenario :
Running the H2 database in another JVM : java -cp h2-1.4.197.jar org.h2.tools.Server
create the database with
CREATE SCHEMA IF NOT EXISTS KAPUA;

Then in https://github.com/eclipse/kapua/blob/develop/service/liquibase/src/test/java/org/eclipse/kapua/service/liquibase/KapuaLiquibaseClientTest.java, replacing "jdbc:h2:mem:kapua;MODE=MySQL" with "jdbc:h2:tcp://localhost:9092/~/kapua;MODE=MySQL" and specify the correct username when needed.

Then, if I run the tests with mvn verify (from the directory kapua/service/liquibase/ ), the tests fails :
[main] ERROR o.e.k.s.l.KapuaLiquibaseClient - Error while running Liquibase scripts!
liquibase.exception.DatabaseException: Table "DATABASECHANGELOG" already exists;

I have atached the full output to this email. Some bits are in french sorry, But they are bot duplicates of the english errors.

Is that expected ? How can we get the liquibase client to play nice with an external H2 instance ?
I'm happy to provide more details if you need!

btw, you can have a look at this device registry project here, any feedback is welcome ! :)

Thanks,
Jean-Baptiste Trystram
_______________________________________________
kapua-dev mailing list
kapua-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/kapua-dev

Back to the top