jeudi 19 février 2015

Spring JDBC error connection

I use Tomcat with Spring (with web services Jersey async) and i set a pool connection in Tomcat like this:



<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver"
maxActive="100" maxIdle="50" maxWait="10000" name="jdbc/UsersDB"
password="secret" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/DB"
username="root" />


In my JDBC class for example i have:



public String getMFromToken(String token) {

logger.info(TAG_LOG + " "
+ "prima della richiesta JDBC id" );

int id = jdbcTemplateObject.queryForObject(sqlGetToken, new Object [] {token}, Integer.class);

logger.info(TAG_LOG + " "
+ "recuperato id " + id );

String sqlGetMFromCred = "select matricola from stud where cred_id = ?";

logger.info(TAG_LOG + " "
+ "prima della richiesta JDBC matricola" );

String matricola = jdbcTemplateObject.queryForObject(sqlGetMFromCred, new Object [] {id},String.class);

logger.info(TAG_LOG + " "
+ "recuperata matricola " + matricola );

return matricola;
}


If I do not do requests (requests that require a query to the database) to tomcat for a long time, tomcat response me a 500 error, but if i call any requests (requests not require a query to the db) all works.


So the problem is some configuration of Spring (i think)..Why Spring not work if i wait long time to do any request ?


sorry for my bad english


Aucun commentaire:

Enregistrer un commentaire