* [ 1852099 ] Simplication of Connection Profile
* [ 1854500 ] CStatement should always close connection if not using trx
This commit is contained in:
parent
2c79b7ff79
commit
35fa73dbdb
|
|
@ -47,13 +47,15 @@ public class CConnection implements Serializable, Cloneable
|
||||||
/** Connection profiles */
|
/** Connection profiles */
|
||||||
public static ValueNamePair[] CONNECTIONProfiles = new ValueNamePair[]{
|
public static ValueNamePair[] CONNECTIONProfiles = new ValueNamePair[]{
|
||||||
new ValueNamePair("L", "LAN"),
|
new ValueNamePair("L", "LAN"),
|
||||||
new ValueNamePair("T", "Terminal Server"),
|
|
||||||
new ValueNamePair("V", "VPN"),
|
new ValueNamePair("V", "VPN"),
|
||||||
new ValueNamePair("W", "WAN") };
|
new ValueNamePair("W", "WAN") };
|
||||||
|
|
||||||
/** Connection Profile LAN */
|
/** Connection Profile LAN */
|
||||||
public static final String PROFILE_LAN = "L";
|
public static final String PROFILE_LAN = "L";
|
||||||
/** Connection Profile Terminal Server */
|
/**
|
||||||
|
* Connection Profile Terminal Server
|
||||||
|
* @deprecated
|
||||||
|
**/
|
||||||
public static final String PROFILE_TERMINAL = "T";
|
public static final String PROFILE_TERMINAL = "T";
|
||||||
/** Connection Profile VPM */
|
/** Connection Profile VPM */
|
||||||
public static final String PROFILE_VPN = "V";
|
public static final String PROFILE_VPN = "V";
|
||||||
|
|
@ -572,8 +574,10 @@ public class CConnection implements Serializable, Cloneable
|
||||||
&& m_connectionProfile.equals(connectionProfile))) // same
|
&& m_connectionProfile.equals(connectionProfile))) // same
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (PROFILE_TERMINAL.equals(connectionProfile))
|
||||||
|
connectionProfile = PROFILE_LAN;
|
||||||
|
|
||||||
if (PROFILE_LAN.equals(connectionProfile)
|
if (PROFILE_LAN.equals(connectionProfile)
|
||||||
|| PROFILE_TERMINAL.equals(connectionProfile)
|
|
||||||
|| PROFILE_VPN.equals(connectionProfile)
|
|| PROFILE_VPN.equals(connectionProfile)
|
||||||
|| PROFILE_WAN.equals(connectionProfile))
|
|| PROFILE_WAN.equals(connectionProfile))
|
||||||
{
|
{
|
||||||
|
|
@ -665,18 +669,18 @@ public class CConnection implements Serializable, Cloneable
|
||||||
public boolean isServerProcess()
|
public boolean isServerProcess()
|
||||||
{
|
{
|
||||||
return (Ini.isClient()
|
return (Ini.isClient()
|
||||||
&& (getConnectionProfile().equals(PROFILE_TERMINAL)
|
&& (getConnectionProfile().equals(PROFILE_VPN)
|
||||||
|| getConnectionProfile().equals(PROFILE_VPN)
|
|
||||||
|| getConnectionProfile().equals(PROFILE_WAN) ));
|
|| getConnectionProfile().equals(PROFILE_WAN) ));
|
||||||
} // isServerProcess
|
} // isServerProcess
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this a Terminal Server ?
|
* Is this a Terminal Server ?
|
||||||
* @return true if client and Terminal
|
* @return true if client and Terminal
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public boolean isTerminalServer()
|
public boolean isTerminalServer()
|
||||||
{
|
{
|
||||||
return Ini.isClient() && getConnectionProfile().equals(PROFILE_TERMINAL);
|
return false;
|
||||||
} // isTerminalServer
|
} // isTerminalServer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -953,8 +957,9 @@ public class CConnection implements Serializable, Cloneable
|
||||||
public Exception testDatabase(boolean retest)
|
public Exception testDatabase(boolean retest)
|
||||||
{
|
{
|
||||||
// At this point Application Server Connection is tested.
|
// At this point Application Server Connection is tested.
|
||||||
if (DB.isRemoteObjects() || isRMIoverHTTP())
|
if (DB.isRemoteObjects())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (!retest && m_ds != null && m_okDB)
|
if (!retest && m_ds != null && m_okDB)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
@ -1213,7 +1218,7 @@ public class CConnection implements Serializable, Cloneable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//hengsin, don't test datasource for wan profile
|
//hengsin, don't test datasource for wan profile
|
||||||
if (!DB.isRemoteObjects() && !isRMIoverHTTP())
|
if (!DB.isRemoteObjects())
|
||||||
{
|
{
|
||||||
if (m_db != null) // test class loader ability
|
if (m_db != null) // test class loader ability
|
||||||
m_db.getDataSource(this);
|
m_db.getDataSource(this);
|
||||||
|
|
@ -1595,7 +1600,7 @@ public class CConnection implements Serializable, Cloneable
|
||||||
setDbPort (svr.getDbPort ());
|
setDbPort (svr.getDbPort ());
|
||||||
setDbName (svr.getDbName ());
|
setDbName (svr.getDbName ());
|
||||||
setDbUid (svr.getDbUid ());
|
setDbUid (svr.getDbUid ());
|
||||||
if (isRMIoverHTTP() || DB.isRemoteObjects())
|
if (DB.isRemoteObjects())
|
||||||
setDbPwd ("");
|
setDbPwd ("");
|
||||||
else
|
else
|
||||||
setDbPwd (svr.getDbPwd ());
|
setDbPwd (svr.getDbPwd ());
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,6 @@ public class CConnectionDialog extends CDialog implements ActionListener
|
||||||
/** Connection Profiles */
|
/** Connection Profiles */
|
||||||
CConnection.CONNECTIONProfiles = new ValueNamePair[]{
|
CConnection.CONNECTIONProfiles = new ValueNamePair[]{
|
||||||
new ValueNamePair("L", res.getString("LAN")),
|
new ValueNamePair("L", res.getString("LAN")),
|
||||||
new ValueNamePair("T", res.getString("TerminalServer")),
|
|
||||||
new ValueNamePair("V", res.getString("VPN")),
|
new ValueNamePair("V", res.getString("VPN")),
|
||||||
new ValueNamePair("W", res.getString("WAN"))
|
new ValueNamePair("W", res.getString("WAN"))
|
||||||
};
|
};
|
||||||
|
|
@ -119,7 +118,7 @@ public class CConnectionDialog extends CDialog implements ActionListener
|
||||||
private CLabel appsPortLabel = new CLabel();
|
private CLabel appsPortLabel = new CLabel();
|
||||||
private CTextField appsPortField = new CTextField();
|
private CTextField appsPortField = new CTextField();
|
||||||
private CButton bTestApps = new CButton();
|
private CButton bTestApps = new CButton();
|
||||||
private CCheckBox cbOverwrite = new CCheckBox();
|
//private CCheckBox cbOverwrite = new CCheckBox();
|
||||||
private CLabel dbUidLabel = new CLabel();
|
private CLabel dbUidLabel = new CLabel();
|
||||||
private CTextField dbUidField = new CTextField();
|
private CTextField dbUidField = new CTextField();
|
||||||
private JPasswordField dbPwdField = new JPasswordField();
|
private JPasswordField dbPwdField = new JPasswordField();
|
||||||
|
|
@ -164,7 +163,7 @@ public class CConnectionDialog extends CDialog implements ActionListener
|
||||||
appsPortField.setColumns(10);
|
appsPortField.setColumns(10);
|
||||||
bTestApps.setText(res.getString("TestApps"));
|
bTestApps.setText(res.getString("TestApps"));
|
||||||
bTestApps.setHorizontalAlignment(JLabel.LEFT);
|
bTestApps.setHorizontalAlignment(JLabel.LEFT);
|
||||||
cbOverwrite.setText(res.getString("Overwrite"));
|
//cbOverwrite.setText(res.getString("Overwrite"));
|
||||||
dbUidLabel.setText(res.getString("DBUidPwd"));
|
dbUidLabel.setText(res.getString("DBUidPwd"));
|
||||||
dbUidField.setColumns(10);
|
dbUidField.setColumns(10);
|
||||||
connectionProfileLabel.setText(res.getString("ConnectionProfile"));
|
connectionProfileLabel.setText(res.getString("ConnectionProfile"));
|
||||||
|
|
@ -195,8 +194,8 @@ public class CConnectionDialog extends CDialog implements ActionListener
|
||||||
//
|
//
|
||||||
centerPanel.add(bTestApps, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0
|
centerPanel.add(bTestApps, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0
|
||||||
,GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 12, 0), 0, 0));
|
,GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 12, 0), 0, 0));
|
||||||
centerPanel.add(cbOverwrite, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0
|
//centerPanel.add(cbOverwrite, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0
|
||||||
,GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0, 5, 0, 12), 0, 0));
|
//,GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0, 5, 0, 12), 0, 0));
|
||||||
// DB
|
// DB
|
||||||
centerPanel.add(dbTypeLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0
|
centerPanel.add(dbTypeLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0
|
||||||
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0));
|
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0));
|
||||||
|
|
@ -238,7 +237,7 @@ public class CConnectionDialog extends CDialog implements ActionListener
|
||||||
nameField.addActionListener(this);
|
nameField.addActionListener(this);
|
||||||
appsHostField.addActionListener(this);
|
appsHostField.addActionListener(this);
|
||||||
appsPortField.addActionListener(this);
|
appsPortField.addActionListener(this);
|
||||||
cbOverwrite.addActionListener(this);
|
//cbOverwrite.addActionListener(this);
|
||||||
bTestApps.addActionListener(this);
|
bTestApps.addActionListener(this);
|
||||||
//
|
//
|
||||||
dbTypeField.addActionListener(this);
|
dbTypeField.addActionListener(this);
|
||||||
|
|
@ -437,8 +436,8 @@ public class CConnectionDialog extends CDialog implements ActionListener
|
||||||
bTestApps.setIcon(getStatusIcon(m_cc.isAppsServerOK(false)));
|
bTestApps.setIcon(getStatusIcon(m_cc.isAppsServerOK(false)));
|
||||||
// bTestApps.setToolTipText(m_cc.getRmiUri());
|
// bTestApps.setToolTipText(m_cc.getRmiUri());
|
||||||
|
|
||||||
cbOverwrite.setVisible(m_cc.isAppsServerOK(false));
|
//cbOverwrite.setVisible(m_cc.isAppsServerOK(false));
|
||||||
boolean rw = cbOverwrite.isSelected() || !m_cc.isAppsServerOK(false);
|
boolean rw = !m_cc.isAppsServerOK(false);
|
||||||
//
|
//
|
||||||
dbTypeLabel.setReadWrite(rw);
|
dbTypeLabel.setReadWrite(rw);
|
||||||
dbTypeField.setReadWrite(rw);
|
dbTypeField.setReadWrite(rw);
|
||||||
|
|
|
||||||
|
|
@ -255,7 +255,7 @@ public class GridTabVO implements Evaluatee, Serializable
|
||||||
return mTabVO.initFields;
|
return mTabVO.initFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CConnection.get().isRMIoverHTTP() || CConnection.get().getDatabase().getStatus() == null)
|
if (CConnection.get().isServerObjects())
|
||||||
{
|
{
|
||||||
CLogger.get().log(Level.SEVERE, "Application server not available.");
|
CLogger.get().log(Level.SEVERE, "Application server not available.");
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -331,8 +331,8 @@ public class GridTabVO implements Evaluatee, Serializable
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (CConnection.get().isRMIoverHTTP())
|
if (CConnection.get().isServerObjects())
|
||||||
CLogger.get().log(Level.SEVERE, "WAN - Application server not available.");
|
CLogger.get().log(Level.SEVERE, "Remote Connection - Application server not available.");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ import java.util.Calendar;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adempiere Callable Statement
|
* Adempiere Callable Statement
|
||||||
*
|
*
|
||||||
|
|
@ -71,7 +72,10 @@ public class CCallableStatement extends CPreparedStatement implements CallableSt
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
Trx trx = p_vo.getTrxName() == null ? null : Trx.get(p_vo.getTrxName(), true);
|
Trx trx = p_vo.getTrxName() == null ? null : Trx.get(p_vo.getTrxName(), true);
|
||||||
if (trx != null)
|
if (trx != null)
|
||||||
|
{
|
||||||
conn = trx.getConnection();
|
conn = trx.getConnection();
|
||||||
|
useTransactionConnection = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (p_vo.getResultSetConcurrency() == ResultSet.CONCUR_UPDATABLE)
|
if (p_vo.getResultSetConcurrency() == ResultSet.CONCUR_UPDATABLE)
|
||||||
|
|
|
||||||
|
|
@ -593,14 +593,12 @@ public class CLogMgt
|
||||||
boolean remoteObjects = DB.isRemoteObjects();
|
boolean remoteObjects = DB.isRemoteObjects();
|
||||||
boolean remoteProcess = DB.isRemoteProcess();
|
boolean remoteProcess = DB.isRemoteProcess();
|
||||||
String realCP = CConnection.PROFILE_LAN;
|
String realCP = CConnection.PROFILE_LAN;
|
||||||
if (cc.isRMIoverHTTP() && cc.isAppsServerOK(false))
|
if (cc.isRMIoverHTTP())
|
||||||
realCP = CConnection.PROFILE_WAN;
|
realCP = CConnection.PROFILE_WAN;
|
||||||
else if (remoteObjects && remoteProcess)
|
else if (remoteObjects && remoteProcess)
|
||||||
realCP = CConnection.PROFILE_VPN;
|
realCP = CConnection.PROFILE_VPN;
|
||||||
else if (remoteProcess)
|
|
||||||
realCP = CConnection.PROFILE_TERMINAL;
|
|
||||||
sb.append(cc.getConnectionProfileText(realCP));
|
sb.append(cc.getConnectionProfileText(realCP));
|
||||||
sb.append(": Tunnel=").append(cc.isRMIoverHTTP() && cc.isAppsServerOK(false))
|
sb.append(": Tunnel=").append(cc.isRMIoverHTTP())
|
||||||
.append(", Objects=").append(remoteObjects)
|
.append(", Objects=").append(remoteObjects)
|
||||||
.append(", Process=").append(remoteProcess);
|
.append(", Process=").append(remoteProcess);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,10 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
Trx trx = p_vo.getTrxName() == null ? null : Trx.get(p_vo.getTrxName(), true);
|
Trx trx = p_vo.getTrxName() == null ? null : Trx.get(p_vo.getTrxName(), true);
|
||||||
if (trx != null)
|
if (trx != null)
|
||||||
|
{
|
||||||
conn = trx.getConnection();
|
conn = trx.getConnection();
|
||||||
|
useTransactionConnection = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (p_vo.getResultSetConcurrency() == ResultSet.CONCUR_UPDATABLE)
|
if (p_vo.getResultSetConcurrency() == ResultSet.CONCUR_UPDATABLE)
|
||||||
|
|
@ -152,19 +155,7 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
|
||||||
else
|
else
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
// Try locally
|
throw new IllegalStateException("Remote Connection - Application server not available");
|
||||||
if (!CConnection.get().isRMIoverHTTP() && CConnection.get().getDatabase().getStatus() != null)
|
|
||||||
{
|
|
||||||
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
|
} // executeQuery
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -222,18 +213,7 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
|
||||||
else
|
else
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
// Try locally
|
throw new IllegalStateException("Remote Connection - Application server not available");
|
||||||
if (!CConnection.get().isRMIoverHTTP() && CConnection.get().getDatabase().getStatus() != null)
|
|
||||||
{
|
|
||||||
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
|
} // executeUpdate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -940,18 +920,7 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
|
||||||
else
|
else
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
// Try locally
|
throw new IllegalStateException("Remote Connection - Application server not available");
|
||||||
if (!CConnection.get().isRMIoverHTTP() && CConnection.get().getDatabase().getStatus() != null)
|
|
||||||
{
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,11 @@ import org.compiere.interfaces.*;
|
||||||
*/
|
*/
|
||||||
public class CStatement implements Statement
|
public class CStatement implements Statement
|
||||||
{
|
{
|
||||||
|
protected boolean useTransactionConnection = false;
|
||||||
|
|
||||||
|
private boolean close = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepared Statement Constructor
|
* Prepared Statement Constructor
|
||||||
*
|
*
|
||||||
|
|
@ -67,7 +72,10 @@ public class CStatement implements Statement
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
Trx trx = p_vo.getTrxName() == null ? null : Trx.get(p_vo.getTrxName(), true);
|
Trx trx = p_vo.getTrxName() == null ? null : Trx.get(p_vo.getTrxName(), true);
|
||||||
if (trx != null)
|
if (trx != null)
|
||||||
|
{
|
||||||
conn = trx.getConnection();
|
conn = trx.getConnection();
|
||||||
|
useTransactionConnection = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (p_vo.getResultSetConcurrency() == ResultSet.CONCUR_UPDATABLE)
|
if (p_vo.getResultSetConcurrency() == ResultSet.CONCUR_UPDATABLE)
|
||||||
|
|
@ -164,17 +172,7 @@ public class CStatement implements Statement
|
||||||
else
|
else
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
// Try locally
|
throw new IllegalStateException("Remote Connection - Application server not available");
|
||||||
if (!CConnection.get().isRMIoverHTTP() && CConnection.get().getDatabase().getStatus() != null)
|
|
||||||
{
|
|
||||||
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
|
} // executeQuery
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -223,17 +221,7 @@ public class CStatement implements Statement
|
||||||
else
|
else
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
// Try locally
|
throw new IllegalStateException("Remote Connection - Application server not available");
|
||||||
if (!CConnection.get().isRMIoverHTTP() && CConnection.get().getDatabase().getStatus() != null)
|
|
||||||
{
|
|
||||||
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
|
} // executeUpdate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -752,11 +740,12 @@ public class CStatement implements Statement
|
||||||
Connection conn = p_stmt.getConnection();
|
Connection conn = p_stmt.getConnection();
|
||||||
p_stmt.close();
|
p_stmt.close();
|
||||||
|
|
||||||
if (!conn.isClosed() && conn.getAutoCommit())
|
if (!close && !useTransactionConnection)
|
||||||
{
|
{
|
||||||
conn.close();
|
conn.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
close = true;
|
||||||
} // close
|
} // close
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|
@ -927,18 +916,7 @@ public class CStatement implements Statement
|
||||||
else
|
else
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
// Try locally
|
throw new IllegalStateException("Remote Connection - Application server not available");
|
||||||
if (!CConnection.get().isRMIoverHTTP() && CConnection.get().getDatabase().getStatus() != null)
|
|
||||||
{
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|
@ -971,10 +949,18 @@ public class CStatement implements Statement
|
||||||
|
|
||||||
public void setPoolable(boolean a) throws SQLException{};
|
public void setPoolable(boolean a) throws SQLException{};
|
||||||
|
|
||||||
public boolean isClosed() throws SQLException{ return false;}
|
public boolean isClosed() throws SQLException{ return close;}
|
||||||
|
|
||||||
public boolean isWrapperFor(java.lang.Class c) throws SQLException{ return false;}
|
public boolean isWrapperFor(java.lang.Class c) throws SQLException{ return false;}
|
||||||
|
|
||||||
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException{return null;}
|
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException{return null;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return is using transaction connection
|
||||||
|
*/
|
||||||
|
public boolean isUseTransactionConnection() {
|
||||||
|
return useTransactionConnection;
|
||||||
|
}
|
||||||
|
|
||||||
} // CStatement
|
} // CStatement
|
||||||
|
|
|
||||||
|
|
@ -245,14 +245,10 @@ public final class DB
|
||||||
* @return True if success, false otherwise
|
* @return True if success, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean connect() {
|
public static boolean connect() {
|
||||||
//wan profile
|
//wan and vpn profile ( remote connection )
|
||||||
if (CConnection.get().isRMIoverHTTP())
|
if (isRemoteObjects())
|
||||||
return CConnection.get().isAppsServerOK(true);
|
return CConnection.get().isAppsServerOK(true);
|
||||||
|
|
||||||
//vpn profile
|
|
||||||
if (isRemoteObjects() && CConnection.get().isAppsServerOK(true))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
//direct connection
|
//direct connection
|
||||||
boolean success =false;
|
boolean success =false;
|
||||||
try
|
try
|
||||||
|
|
@ -306,14 +302,10 @@ public final class DB
|
||||||
//bug [1637432]
|
//bug [1637432]
|
||||||
if (s_cc == null) return false;
|
if (s_cc == null) return false;
|
||||||
|
|
||||||
//wan profile
|
//wan/vpn profile ( remote connection )
|
||||||
if (CConnection.get().isRMIoverHTTP())
|
if (CConnection.get().isServerObjects())
|
||||||
return s_cc.isAppsServerOK(createNew);
|
return s_cc.isAppsServerOK(createNew);
|
||||||
|
|
||||||
//vpn
|
|
||||||
if (isRemoteObjects() && s_cc.isAppsServerOK(createNew))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
//direct connection
|
//direct connection
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
CLogErrorBuffer eb = CLogErrorBuffer.get(false);
|
CLogErrorBuffer eb = CLogErrorBuffer.get(false);
|
||||||
|
|
@ -387,11 +379,8 @@ public final class DB
|
||||||
*/
|
*/
|
||||||
public static Connection createConnection (boolean autoCommit, int trxLevel)
|
public static Connection createConnection (boolean autoCommit, int trxLevel)
|
||||||
{
|
{
|
||||||
//wan/vpn profile
|
//wan/vpn profile ( remote connection )
|
||||||
if (CConnection.get().isRMIoverHTTP() ||
|
if (CConnection.get().isServerObjects())
|
||||||
(CConnection.get().isServerObjects() &&
|
|
||||||
CConnection.get().isAppsServerOK(false) &&
|
|
||||||
CConnection.get().getDatabase().getStatus() == null))
|
|
||||||
return new ServerConnection();
|
return new ServerConnection();
|
||||||
|
|
||||||
Connection conn = s_cc.getConnection (autoCommit, trxLevel);
|
Connection conn = s_cc.getConnection (autoCommit, trxLevel);
|
||||||
|
|
@ -423,11 +412,8 @@ public final class DB
|
||||||
*/
|
*/
|
||||||
public static Connection createConnection (boolean autoCommit, boolean readOnly, int trxLevel)
|
public static Connection createConnection (boolean autoCommit, boolean readOnly, int trxLevel)
|
||||||
{
|
{
|
||||||
//wan/vpn profile
|
//wan/vpn profile ( remote connection )
|
||||||
if (CConnection.get().isRMIoverHTTP() ||
|
if (CConnection.get().isServerObjects())
|
||||||
( CConnection.get().isServerObjects() &&
|
|
||||||
CConnection.get().isAppsServerOK(false) &&
|
|
||||||
CConnection.get().getDatabase().getStatus() == null ))
|
|
||||||
return new ServerConnection();
|
return new ServerConnection();
|
||||||
|
|
||||||
Connection conn = s_cc.getConnection (autoCommit, trxLevel);
|
Connection conn = s_cc.getConnection (autoCommit, trxLevel);
|
||||||
|
|
@ -1478,8 +1464,7 @@ public final class DB
|
||||||
//avoid infinite loop
|
//avoid infinite loop
|
||||||
if (s_cc == null) return false;
|
if (s_cc == null) return false;
|
||||||
|
|
||||||
return CConnection.get().isServerObjects()
|
return CConnection.get().isServerObjects();
|
||||||
&& CConnection.get().isAppsServerOK(false);
|
|
||||||
} // isRemoteObjects
|
} // isRemoteObjects
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue