OSGi enroute : How to use MySQL instead of default H2

52 Views Asked by At

I am studying OSGi, and when I use OSGi enroute code template I have an issue with database connection.
I am trying switch to use MySQL but it seems not work.
It works fine with default H2 configuration.

{
    ":configurator:resource-version": 1,
    ":configurator:symbolic-name": "my.app.config",
    ":configurator:version": "1.0-SNAPSHOT",
    "org.apache.aries.tx.control.jdbc.xa~microservice": {
        "name": "app.database",
        "osgi.jdbc.driver.class": "org.h2.Driver",
        "url": "jdbc:h2:./data/database"
    },
    "my.app.impl.AlarmDAOImpl": {
        "provider.target": "(name=app.database)"
    }
}

But when change to use MySQL like this:

{
    ":configurator:resource-version": 1,
    ":configurator:symbolic-name": "my.app.config",
    ":configurator:version": "1.0-SNAPSHOT",
    "org.apache.aries.tx.control.jdbc.xa~microservice": {
        "name": "app.database",
        "osgi.jdbc.driver.class": "com.mysql.cj.Driver",
        "url": "jdbc:mysql://root:123@localhost:3306/test?useSSL=false"
    },
    "my.app.impl.AlarmDAOImpl": {
        "provider.target": "(name=app.database)"
    }
}

My app seems to get crash and I cannot access the REST endpoint anymore.
Can anyone help me take a look at my configuration?

0

There are 0 best solutions below