Dhanabalan
Dhanabalan

Reputation: 572

Unable to connect openshift mysql using spring boot

I have created application in openshit (tomcat7 type) using spring boot. Below is my connection properties

# Remote Datasource Configuration
spring.datasource.url=jdbc:mysql://127.3.175.2:3306/sivam
spring.datasource.username=xxx
spring.datasource.password=yyy

When I tried to deploy my application, Its not connecting to the DB. Unfortunately I am unable to the logs now due to proxy settings. The same code is working fine in my system with local database credentials.

# Local Datasource Configuration
spring.datasource.url=jdbc:mysql://localhost:3306/sivam
spring.datasource.username=xxx
spring.datasource.password =yyy

Also I have checked remote db credentials using normal JDBC connections (Class.forName() etc) and its deployed correctly & fetching the records from openshift mysql db. So my difficulty is only on spring boot, Do I need to make any specific changes for this?

Upvotes: 1

Views: 573

Answers (1)

Dhanabalan
Dhanabalan

Reputation: 572

Finally I found the issue and fixed it. Actually issue is spring boot's latest version using tomcat version compiled with Java 7, so we need to do few workarounds to make it work.

<properties>
    <tomcat.version>7.0.59</tomcat.version>
</properties>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
    <exclusions>
        <exclusion>
            <groupId>javax.transaction</groupId>
            <artifactId>javax.transaction-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
    <groupId>org.jboss.spec.javax.transaction</groupId>
    <artifactId>jboss-transaction-api_1.2_spec</artifactId>
    <version>1.0.0.Final</version>
</dependency>

My application is deployed into openshift PaaS server and working as expected.

Upvotes: 1

Related Questions