mysql connection on remote virtual machine in spring boot

时间:2017-08-03 07:10:46

标签: mysql jpa spring-boot database-connection virtual-machine

I have created a project in Spring boot and JPA which is deployed on a VM and my database is on another VM. At time of deployment it is taking to much time to connect to the database and also for every request(read/write operation) also it is taking more time then normal (when mysql was on the same VM).

My application.properties file is:

spring.datasource.url=jdbc:mysql://<remoteip>:3306/dbname?useSSL=false
spring.datasource.username=root
spring.datasource.password =root
// Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle=true
spring.datasource.validationQuery=SELECT 1

And gradle file

compile('mysql:mysql-connector-java')
compile("org.springframework.boot:spring-boot-starter-data-rest")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile('org.springframework.boot:spring-boot-starter-web')
compile("org.springframework.boot:spring-boot-starter-undertow:1.5.1.RELEASE")

Is this happening because JPA creating connection pool? i am using undertow server.

0 个答案:

没有答案