Hi all, I have a java code that executes a query on a SQL Server database.
Here is the java code:
try
{
EndUserIfc user = getUser();
String userId = (String) params.get("UserId");
String strSQL = "SELECT NOMINATIVO, CODICE, DEBITORE FROM UTENTI WHERE USER_ID='" + userId + "'";
Connection cnn = getConnection("DbSqlSrv");
Statement stm = cnn.createStatement();
ResultSet rst = stm.executeQuery(strSQL);
if(rst.next())
{
user.setAttribute("NOMINATIVO", rst.getString(1));
user.setAttribute("CODICE", rst.getString(2));
user.setAttribute("DEBITORE", rst.getString(3));
} else
{
user.setAttribute("NOMINATIVO", "");
user.setAttribute("CODICE", "");
user.setAttribute("DEBITORE", "");
}
} catch(Exception e)
{
myLogger.write("ERROR: " + e.toString());
} finally
{
try
{
rst.close();
stm.close();
cnn.close();
} catch(Exception e)
{
myLogger.write("WARNING: " + e.toString());
}
}
As you can see in case of error the exception is written into a log file.
Sometimes happens that is not possible to execute the query and in my log file I can see the following error:
ERROR: java.sql.SQLException: ConnectionPool[DbSqlSrv] size [50]: timed-out
The database seems to work fine.
After few minutes the application re-starts working fine.
Is there anybody that can help me to understand what's happening?
Thank you very much.