2016-08-14 19 views
0

私のWebアプリケーションは現在完全に動作しており、データをmysqlデータベースに永続させています。私が接続で理解できないのは、しばらくしてからデータベースに接続を落として、アプリケーションとの接続を維持するためにTomcatを停止して再起動する必要があるということです。 Tomcat Webサーバーまたはmysqlデータベースにセッションのタイムアウトが設定されていますか?スプリングブートと休止状態のmysqlデータベース接続を切断し続ける

以下は、春の起動時の私のapplication.propertiesです。

debug=true 

spring.datasource.url=jdbc:mysql://localhost/database 
spring.datasource.username=username 
spring.datasource.password=pass 
spring.datasource.driverClassName=com.mysql.jdbc.Driver 

spring.jpa.hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect 
spring.jpa.generate-ddl=true 
spring.jpa.show-sql=true 

logging.level.org.hibernate.SQL=DEBUG 


Below is the exception: 

Exception: org.springframework.dao.DataAccessResourceFailureException: could not prepare statement; nested exception is org.hibernate.exception.JDBCConnectionException: could not prepare statement 

あなたのお手伝いを助けてください。

ドナルド

+0

jdbc接続のURLを投稿してください。このようなものでなければなりません 'url =" jdbc:mysql:// localhost:3306/hposg' –

+0

[this](http://stackoverflow.com/questions/32622233/hibernate-property-to-keep-接続する)が役に立ちます –

+0

spring.datasource.testOnBorrow = true spring.datasource.validationQuery = SELECT 1 –

答えて

0

これは私の仕事です。あなたのapplication.propertiesに追加するだけです。

spring.datasource.testOnBorrow=true 
spring.datasource.validationQuery=SELECT 1