title: Spring boot Failed to validate a newly established connection
body: <p>I have deployed my Spring Boot web app in Azure cloud. Using a MySQL DB which is limited to only 4 connections. Following is the datasource properties</p>
  
  <pre><code>spring.datasource.url=jdbc:mysql://hostname:3306/dbname
  spring.datasource.username=username
  spring.datasource.password=password
  spring.datasource.max-active=4
  spring.datasource.connection-test-query="SELECT 1"
  spring.datasource.test-while-idle=true
  spring.datasource.test-on-borrow=true
  </code></pre>
  
  <p>Since my app loses the db connection and not recovering from it I have added the test-on-borrow property. I am using JDBCTemplate.</p>
  
  <p>I am getting the following exception very frequently and still the app works. I need to know whether this exception is because of the datasource properties or the limited number of connection(4). If I increase the connection will this exception go away. </p>
  
  <p><strong>Exception Message</strong></p>
  
  <pre><code>Could not get JDBC Connection; nested exception is java.sql.SQLException: Failed to validate a newly established connection.Failed to validate a newly established connection.
  </code></pre>
  
  <p><strong>Failed Method</strong></p>
  
  <pre><code>org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection
  </code></pre>