I have spring boot application that uses MySQL datasource. I see the connection to datasource keeps dying.
when I restart my tomcat, everything looks good. I am using embedded tomcat container from spring boot.
Here is how I create my datasource bean
@Bean(name="helloDataSource")
@Primary
@ConfigurationProperties(prefix="spring.datasource")
public DataSource helloDataSource() {
return DataSourceBuilder.create().build();
}
application.properties
spring.datasource.username=adfdf
spring.datasource.url=jdbc:mysql://localhost:3306/my_db
spring.datasource.password=adfdf
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.tomcat.max-wait=10000
spring.datasource.tomcat.max-active=100
spring.datasource.tomcat.min-idle=10
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.validation-query=select 1
spring.datasource.tomcat.remove-abandoned=true
Here is the stacktrace
"exception": "org.springframework.dao.DataAccessResourceFailureException",
"message": "PreparedStatementCallback; SQL [UPDATE my_table SET key= ? WHERE item_key= ?]; No operations allowed after connection closed.; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.",
stack_trace":"j.n.SocketException: Broken pipe\n\tat j.n.SocketOutputStream.socketWrite0(Unknown Source)\n\tat j.n.SocketOutputStream.socketWrite(Unknown Source)\n\tat j.n.SocketOutputStream.write(Unknown Source)\n\tat j.i.BufferedOutputStream.flushBuffer(Unknown Source)\n\tat j.i.BufferedOutputStream.flush(Unknown Source)\n\tat c.mysql.jdbc.MysqlIO.send(MysqlIO.java:3591)\n\tat c.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2417)\n\tat c.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2582)\n\tat c.m.j.ConnectionImpl.execSQL(ConnectionImpl.java:2535)\n\tat c.m.j.PreparedStatement.executeInternal(PreparedStatement.java:1911)\n\t... 38 frames truncated\n"}