Spring JDBC Template not responding after specific Hits

Viewed 419

I am Using Spring JDBC template .

In My Controller class method I am trying to get data using below code.

String sql = "select id, query_sql, CONVERT_TZ(sync_datetime,'+00:00','-05:30') as  sync_datetime "
        + "from tblsync_master where id=1";
List<Map<String, Object>> data = template.queryForList(sql);

At the initial state I am getting the response.

But After continuous hit I am not getting any response from this query

List<Map<String, Object>> data = template.queryForList(sql);

and it is not giving any error.

I have tried using setting timeout for query.

template.setQueryTimeout(3);

My application.properties file configurations is.

spring.datasource.url=jdbc:mysql://localhost/test
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.hibernate.naming.strategy=org.hibernate.cfg.EJB3NamingStrategy
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.show.sql=false
hibernate.hbm2ddl.auto=update
#hibernate 5 naming property
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

#max active connection with mysql
#spring.datasource.tomcat.max-active=10
spring.jta.bitronix.datasource.max-pool-size=25

spring.datasource.tomcat.testOnBorrow=true
spring.datasource.tomcat.validationQuery=SELECT 1
spring.datasource.dbcp2.test-on-borrow=true

Is there any proprieties or configuration I need to set.

EDIT

My code in Controller class method.

public ResponseEntity<String> saveProjectData() throws JSONException {

        try {

            logger.info("IN Controller");

            template.setQueryTimeout(3);


            String sql = "select id, query_sql, CONVERT_TZ(sync_datetime,'+00:00','-05:30') as  sync_datetime from tblsync_master where id=1";


            List<Map<String, Object>> data = template.queryForList(sql);

            logger.info("Data From sync master for id 1 is ---- > " + data.toString());

            return new ResponseEntity("success", HttpStatus.OK);

            }catch(Exception e){

            return new ResponseEntity("fail", HttpStatus.INTERNAL_SERVER_ERROR);
            }}

Please Help.

0 Answers
Related