/**
* Reconnect to the database.
*/
public void reconnect()
{
SQLConnectionState connState = new SQLConnectionState();
if (_conn != null)
{
try
{
connState.saveState(_conn, getProperties(), _msgHandler);
}
catch (SQLException ex)
{
s_log.error("Unexpected SQLException", ex);
}
}
OpenConnectionCommand cmd = new OpenConnectionCommand(_app, _alias,
_user, _password, connState.getConnectionProperties());
try
{
closeSQLConnection();
_app.getSessionManager().fireConnectionClosedForReconnect(this);
}
catch (SQLException ex)
{
final String msg = s_stringMgr.getString("Session.error.connclose");
s_log.error(msg, ex);
_msgHandler.showErrorMessage(msg);
_msgHandler.showErrorMessage(ex, this.getExceptionFormatter());
}
try
{
cmd.execute();
_conn = cmd.getSQLConnection();
if (connState != null)
{
connState.restoreState(_conn, _msgHandler);
getProperties().setAutoCommit(connState.getAutoCommit());
}
final String msg = s_stringMgr.getString("Session.reconn", _alias.getName());
_msgHandler.showMessage(msg);
_app.getSessionManager().fireReconnected(this);
startKeepAliveTaskIfNecessary();