I have created a spring boot application. When I put load on the application after sometime load on database server started increasing and I got started socket read time out error.
2016-10-24 21:56:10 [pool-3-thread-296] ERROR o.h.e.jdbc.spi.SqlExceptionHelper - IO Error: Socket read timed out
2016-10-24 21:56:10 [pool-3-thread-296] ERROR
Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Could not open connection
Here is the properties file details of Springboot application
spring.datasource.url=jdbc:oracle:thin:#<ip>:1521:<dbname>
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
spring.datasource.initial-size=100
spring.datasource.maxActive=1500
spring.datasource.validationQuery=select 1 from dual
spring.jpa.hibernate.dialect = org.hibernate.dialect.Oracle10gDialect
spring.jpa.show-sql = true
spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy
spring.datasource.pool-prepared-statements=true
spring.datasource.pool-prepared-statements-cache-size=500
spring.datasource.max-open-prepared-statements=500
Since the error is very generic , I am not able to figure out why I am getting socket read timeout exception.
I also need to know what does "[pool-3-thread-296]" mean in exception log ?
Have you tried this? This worked for me
https://springframework.guru/configuring-spring-boot-for-oracle/
Related
Application: Java spring boot + mysql
Story:
application log showed "Could not open JDBC Connecton for transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure"
Recovery of the DB instance has been triggered since hardware problem occurred in RDS instance
After 10 mins, the recovery is done.
application log showed "Could not commit JDBC transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed." instead of previous exception.
After 45 mins, application resumed normal without manual operations.
Questions:
Will restarting the application solve the problem instantly?
Manual operation might not be the best to resolve such problem. But if I want it be auto resumed shortly, anything I can do to the setting datasource properties? i.e. set spring.datasource.justswap.time-between-eviction-runs-millis shorter?
Current datasource setting:
spring.datasource.xxx.maxActive=700
spring.datasource.xxx.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.xxx.test-on-borrow=false
spring.datasource.xxx.test-while-idle=true
spring.datasource.xxx.time-between-eviction-runs-millis=3600000
spring.datasource.druid.stat-view-servlet.enabled=false
I read a lot of questions here in stackoverflow about this subject and I ended with the following code in my application-prd.properties:
#PRD IP
spring.datasource.url=
spring.datasource.username=
spring.datasource.password=
# Fix for DB Connection
spring.datasource.tomcat.max-active=10
spring.datasource.tomcat.initial-size=5
spring.datasource.tomcat.max-idle=5
spring.datasource.tomcat.min-idle=1
spring.datasource.tomcat.test-while-idle=true
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.validation-query=SELECT 1 FROM DUAL
spring.datasource.tomcat.time-between-eviction-runs-millis=5000
spring.datasource.tomcat.min-evictable-idle-time-millis=60000
#Error fix for JSON conversion
spring.jackson.parser.allow-unquoted-control-chars=true
But, for some reason, the Tomcat with my Spring application suddenly loses the connection with the database, giving the following error:
Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
I don't know what should I do. Its been weeks that I'm struggling with it. Is there anything else that I can do? Or can I say that is a firewall issue and the infrastructure team should check something?
Thank you
Also check for connection leaks, might be some txns not closing connection properly that's why pool went out of threshold.
After following the instruction of buildin Shopizer from this link
https://github.com/shopizer-ecommerce/shopizer
and after building and moving sm-shop.war to Tomcat webapps folder and then accessing the url:
http://localhost:8080/sm-shop/shop
I'm facing this error
HTTP Status 500 - Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Could not open connection
So, what is the problem, can anybody help ?
It expects this DB configuration.
You have two options:
Configure your own local DB and fill it with your connection and authentication details (config is using MySQL).
Uncomment H2 database config and comment out MySQL config. H2 is embedded database and therefore you wouldn't need to install anything.
I am Getting following error when ever i am starting my tomcat
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.ConnectException
MESSAGE: Connection refused
I am getting this error even with out using any application in my tomcat.
Could you please help me why tomcat is looking for mysql connect at the time of start
Regards
May be you have configured a Tomcat Datasource Resource in your server.xml or context.xml in your ${CATALINA_BASE}/conf directory. So, whenever tomcat starts it tries to create the connection pool for your datasource and it is not able to communicate to the db server host. This is highly possible if you don't use mysql in your application
After a SQL Server database restart, my Tomcat 6 Spring web applications receives an SQL exception on the first attempt to query the database. Note: Tomcat 6 has continued to run during the SQL Server restart and I'm using myBatis. The exception is as follows:
org.springframework.dao.DataAccessResourceFailureException:
Error querying database. Cause: java.sql.SQLException: I/O Error: Connection reset
Any subsequent queries execute fine (without exception). How can I prevent this exception on the first query?
Set up your pool to test connections before giving them to your application
use testOnBorrow=true and (for instance) validationQuery="select 1" in your db pool connection