* [ 1656849 ] WAN: every time when a query fails is tried to run locally
This commit is contained in:
parent
cd095c4350
commit
7a4012db51
|
@ -139,13 +139,26 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
|
|||
{
|
||||
log.log(Level.SEVERE, "AppsServer error", ex);
|
||||
p_remoteErrors++;
|
||||
if (ex instanceof SQLException)
|
||||
throw (SQLException)ex;
|
||||
else if (ex instanceof RuntimeException)
|
||||
throw (RuntimeException)ex;
|
||||
else
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
// Try locally
|
||||
if (!CConnection.get().isRMIoverHTTP())
|
||||
{
|
||||
log.warning("Execute locally");
|
||||
p_stmt = local_getPreparedStatement (false, null); // shared connection
|
||||
p_vo.clearParameters(); // re-use of result set
|
||||
ResultSet rs = ((PreparedStatement)p_stmt).executeQuery();
|
||||
return rs;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException("WAN - Application server not available");
|
||||
}
|
||||
} // executeQuery
|
||||
|
||||
/**
|
||||
|
@ -193,15 +206,28 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
|
|||
log.log(Level.SEVERE, "AppsServer not found");
|
||||
}
|
||||
}
|
||||
catch (RemoteException ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.log(Level.SEVERE, "AppsServer error", ex);
|
||||
if (ex instanceof SQLException)
|
||||
throw (SQLException)ex;
|
||||
else if (ex instanceof RuntimeException)
|
||||
throw (RuntimeException)ex;
|
||||
else
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
// Try locally
|
||||
if (!CConnection.get().isRMIoverHTTP())
|
||||
{
|
||||
log.warning("execute locally");
|
||||
p_stmt = local_getPreparedStatement (false, null); // shared connection
|
||||
p_vo.clearParameters(); // re-use of result set
|
||||
return ((PreparedStatement)p_stmt).executeUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException("WAN - Application server not available");
|
||||
}
|
||||
} // executeUpdate
|
||||
|
||||
/**
|
||||
|
@ -877,13 +903,24 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
|
|||
{
|
||||
log.log(Level.SEVERE, "AppsServer error", ex);
|
||||
p_remoteErrors++;
|
||||
if (ex instanceof RuntimeException)
|
||||
throw (RuntimeException)ex;
|
||||
else
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
// Try locally
|
||||
if (!CConnection.get().isRMIoverHTTP())
|
||||
{
|
||||
log.warning("Execute locally");
|
||||
p_stmt = local_getPreparedStatement (false, null); // shared connection
|
||||
p_vo.clearParameters(); // re-use of result set
|
||||
return local_getRowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException("WAN - Application server not available");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Result as RowSet for local system.
|
||||
|
|
|
@ -150,15 +150,28 @@ public class CStatement implements Statement
|
|||
p_remoteErrors++;
|
||||
}
|
||||
}
|
||||
catch (RemoteException ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.log(Level.SEVERE, "AppsServer error", ex);
|
||||
p_remoteErrors++;
|
||||
if (ex instanceof SQLException)
|
||||
throw (SQLException)ex;
|
||||
else if (ex instanceof RuntimeException)
|
||||
throw (RuntimeException)ex;
|
||||
else
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
// Try locally
|
||||
if (!CConnection.get().isRMIoverHTTP())
|
||||
{
|
||||
log.warning("execute locally");
|
||||
p_stmt = local_getStatement (false, null); // shared connection
|
||||
return p_stmt.executeQuery(p_vo.getSql());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException("WAN - Application server not available");
|
||||
}
|
||||
} // executeQuery
|
||||
|
||||
|
||||
|
@ -196,15 +209,28 @@ public class CStatement implements Statement
|
|||
p_remoteErrors++;
|
||||
}
|
||||
}
|
||||
catch (RemoteException ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.log(Level.SEVERE, "AppsServer error", ex);
|
||||
p_remoteErrors++;
|
||||
if (ex instanceof SQLException)
|
||||
throw (SQLException)ex;
|
||||
else if (ex instanceof RuntimeException)
|
||||
throw (RuntimeException)ex;
|
||||
else
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
// Try locally
|
||||
if (!CConnection.get().isRMIoverHTTP())
|
||||
{
|
||||
log.warning("execute locally");
|
||||
p_stmt = local_getStatement (false, null); // shared connection
|
||||
return p_stmt.executeUpdate(p_vo.getSql());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException("WAN - Application server not available");
|
||||
}
|
||||
} // executeUpdate
|
||||
|
||||
/**
|
||||
|
@ -860,13 +886,24 @@ public class CStatement implements Statement
|
|||
{
|
||||
log.log(Level.SEVERE, "AppsServer error", ex);
|
||||
p_remoteErrors++;
|
||||
if (ex instanceof RuntimeException)
|
||||
throw (RuntimeException)ex;
|
||||
else
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
// Try locally
|
||||
if (!CConnection.get().isRMIoverHTTP())
|
||||
{
|
||||
log.warning("Execute locally");
|
||||
p_stmt = local_getStatement(false, null); // shared connection
|
||||
p_vo.clearParameters(); // re-use of result set
|
||||
return local_getRowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException("WAN - Application server not available");
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Get Result as RowSet for Remote.
|
||||
|
|
|
@ -61,6 +61,8 @@ public final class DB
|
|||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger (DB.class);
|
||||
|
||||
private static Object s_ccLock = new Object();
|
||||
|
||||
/** SQL Statement Separator "; " */
|
||||
public static final String SQLSTATEMENT_SEPARATOR = "; ";
|
||||
|
||||
|
@ -228,9 +230,7 @@ public final class DB
|
|||
|
||||
DB.closeTarget();
|
||||
//
|
||||
if (s_cc == null)
|
||||
s_cc = cc;
|
||||
synchronized (s_cc) // use as mutex
|
||||
synchronized(s_ccLock)
|
||||
{
|
||||
s_cc = cc;
|
||||
s_connections = null;
|
||||
|
@ -239,6 +239,7 @@ public final class DB
|
|||
}
|
||||
if ( isRemoteObjects() == false)
|
||||
s_cc.setDataSource();
|
||||
|
||||
log.config(s_cc + " - DS=" + s_cc.isDataSource());
|
||||
// Trace.printStack();
|
||||
} // setDBTarget
|
||||
|
@ -249,8 +250,14 @@ public final class DB
|
|||
*/
|
||||
public static boolean connect() {
|
||||
//wan profile
|
||||
if (DB.isRemoteObjects()) return true;
|
||||
if (CConnection.get().isRMIoverHTTP())
|
||||
return CConnection.get().isAppsServerOK(true);
|
||||
|
||||
//vpn profile
|
||||
if (isRemoteObjects() && CConnection.get().isAppsServerOK(true))
|
||||
return true;
|
||||
|
||||
//direct connection
|
||||
boolean success =false;
|
||||
try
|
||||
{
|
||||
|
@ -284,8 +291,14 @@ public final class DB
|
|||
if (s_cc == null) return false;
|
||||
|
||||
//wan profile
|
||||
if (DB.isRemoteObjects()) return true;
|
||||
if (CConnection.get().isRMIoverHTTP())
|
||||
return s_cc.isAppsServerOK(createNew);
|
||||
|
||||
//vpn
|
||||
if (isRemoteObjects() && s_cc.isAppsServerOK(createNew))
|
||||
return true;
|
||||
|
||||
//direct connection
|
||||
boolean success = false;
|
||||
CLogErrorBuffer eb = CLogErrorBuffer.get(false);
|
||||
if (eb != null && eb.isIssueError())
|
||||
|
@ -322,7 +335,7 @@ public final class DB
|
|||
public static Connection getConnectionRW (boolean createNew)
|
||||
{
|
||||
//wan profile
|
||||
if (DB.isRemoteObjects()) return null;
|
||||
if (CConnection.get().isRMIoverHTTP()) return null;
|
||||
|
||||
// check health of connection
|
||||
try
|
||||
|
@ -374,7 +387,7 @@ public final class DB
|
|||
public static Connection getConnectionID ()
|
||||
{
|
||||
//wan profile
|
||||
if (DB.isRemoteObjects()) return null;
|
||||
if (CConnection.get().isRMIoverHTTP()) return null;
|
||||
|
||||
if (s_connectionID != null)
|
||||
{
|
||||
|
@ -405,11 +418,11 @@ public final class DB
|
|||
public static Connection getConnectionRO ()
|
||||
{
|
||||
//wan profile
|
||||
if (DB.isRemoteObjects()) return null;
|
||||
if (CConnection.get().isRMIoverHTTP()) return null;
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (s_cc) // use as mutex as s_connection is null the first time
|
||||
synchronized(s_ccLock)
|
||||
{
|
||||
if (s_connections == null)
|
||||
s_connections = createConnections (Connection.TRANSACTION_READ_COMMITTED); // see below
|
||||
|
@ -485,8 +498,8 @@ public final class DB
|
|||
*/
|
||||
public static Connection createConnection (boolean autoCommit, int trxLevel)
|
||||
{
|
||||
//wan and vpn
|
||||
if (isRemoteObjects()) return null;
|
||||
//wan profile
|
||||
if (CConnection.get().isRMIoverHTTP()) return null;
|
||||
|
||||
Connection conn = s_cc.getConnection (autoCommit, trxLevel);
|
||||
if (CLogMgt.isLevelFinest())
|
||||
|
@ -708,6 +721,7 @@ public final class DB
|
|||
}
|
||||
}
|
||||
s_connections = null;
|
||||
|
||||
// RW connection
|
||||
try
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue