Java Reference
In-Depth Information
return str.substring(0, length);
}
}
/**
* Try to open the database connection.
*
* @throws WorkloadException
* Thrown if the open fails.
*/
void tryOpen() throws WorkloadException
{
Exception ex = null;
logger.log(Level.SEVERE,
"Lost connection to database, trying to reconnect.");
for (int i = 1; i < 120; i++)
{
try
{
close();
} catch (Exception e1)
{
logger.log(Level.SEVERE,
"Failed while trying to close lost connection, ignoring...",
e1);
}
ex = null;
try
{
logger.log(Level.SEVERE, "Attempting database reconnect");
open();
logger.log(Level.SEVERE,
"Database connection reestablished");
break;
} catch (Exception e)
{
ex = e;
logger.log(Level.SEVERE, "Reconnect failed", ex);
}
if (ex != null)
{
Search WWH ::




Custom Search