diff --git a/.classpath b/.classpath
index c860e9e197..6a1b0bdaca 100644
--- a/.classpath
+++ b/.classpath
@@ -1,125 +1,124 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 3356a56fdf..3adcd379e0 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,7 +1,8 @@
-#Sun Aug 03 07:33:03 SGT 2008
+#Fri Oct 24 10:43:33 SGT 2008
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
+instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/JasperReports/src/org/compiere/report/ReportStarter.java b/JasperReports/src/org/compiere/report/ReportStarter.java
index 27b5cb8108..2d9cb357b8 100644
--- a/JasperReports/src/org/compiere/report/ReportStarter.java
+++ b/JasperReports/src/org/compiere/report/ReportStarter.java
@@ -46,7 +46,6 @@ import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.util.JRLoader;
import org.compiere.db.CConnection;
-import org.compiere.db.ServerConnection;
import org.compiere.interfaces.MD5;
import org.compiere.interfaces.MD5Home;
import org.compiere.model.MAttachment;
@@ -352,14 +351,7 @@ public class ReportStarter implements ProcessCall, ClientProcess {
*/
protected Connection getConnection()
{
- if (DB.isRemoteObjects())
- {
- return new ServerConnection();
- }
- else
- {
- return DB.getConnectionRW();
- }
+ return DB.getConnectionRW();
}
/**
diff --git a/base/src/org/compiere/db/CConnection.java b/base/src/org/compiere/db/CConnection.java
index 8a8243d897..7a410aa860 100644
--- a/base/src/org/compiere/db/CConnection.java
+++ b/base/src/org/compiere/db/CConnection.java
@@ -27,8 +27,6 @@ import javax.swing.JOptionPane;
import org.compiere.*;
import org.compiere.interfaces.*;
import org.compiere.util.*;
-import org.jboss.security.SecurityAssociation;
-import org.jboss.security.SimplePrincipal;
/**
* Adempiere Connection Descriptor
@@ -45,12 +43,12 @@ public class CConnection implements Serializable, Cloneable
private static CLogger log = CLogger.getCLogger (CConnection.class);
/** Connection profiles */
+ @Deprecated
public static ValueNamePair[] CONNECTIONProfiles = new ValueNamePair[]{
- new ValueNamePair("L", "LAN"),
- new ValueNamePair("V", "VPN"),
- new ValueNamePair("W", "WAN") };
+ new ValueNamePair("L", "LAN")};
/** Connection Profile LAN */
+ @Deprecated
public static final String PROFILE_LAN = "L";
/**
* Connection Profile Terminal Server
@@ -58,8 +56,10 @@ public class CConnection implements Serializable, Cloneable
**/
public static final String PROFILE_TERMINAL = "T";
/** Connection Profile VPM */
+ @Deprecated
public static final String PROFILE_VPN = "V";
/** Connection Profile WAN */
+ @Deprecated
public static final String PROFILE_WAN = "W";
/**
@@ -199,7 +199,7 @@ public class CConnection implements Serializable, Cloneable
private String m_db_name = "MyDBName";
/** Connection Profile */
- private String m_connectionProfile = null;
+ private String m_connectionProfile = PROFILE_LAN;
/** In Memory connection */
private boolean m_bequeath = false;
@@ -545,71 +545,43 @@ public class CConnection implements Serializable, Cloneable
/**
* RMI over HTTP
+ *
+ * Deprecated, always return false
* @return true if RMI over HTTP (Wan Connection Profile)
+ * @deprecated
*/
public boolean isRMIoverHTTP ()
{
- return Ini.isClient()
- && getConnectionProfile().equals(PROFILE_WAN);
+ return false;
} // isRMIoverHTTP
/**
* Set Connection Profile
* @param connectionProfile connection profile
+ * @deprecated
*/
public void setConnectionProfile (ValueNamePair connectionProfile)
{
if (connectionProfile != null)
- setConnectionProfile(connectionProfile.getValue());
+ setConnectionProfile(PROFILE_LAN);
} // setConnectionProfile
/**
* Set Connection Profile
* @param connectionProfile connection profile
+ * @deprecated
*/
public void setConnectionProfile (String connectionProfile)
{
- if (connectionProfile == null
- || (m_connectionProfile != null
- && m_connectionProfile.equals(connectionProfile))) // same
- return;
-
- if (PROFILE_TERMINAL.equals(connectionProfile))
- connectionProfile = PROFILE_LAN;
-
- if (PROFILE_LAN.equals(connectionProfile)
- || PROFILE_VPN.equals(connectionProfile)
- || PROFILE_WAN.equals(connectionProfile))
- {
- if (m_connectionProfile != null)
- {
- log.config(m_connectionProfile + " -> " + connectionProfile);
- m_connectionProfile = connectionProfile;
- if (PROFILE_WAN.equals(m_connectionProfile))
- setAppsPort(80);
- else
- setAppsPort(DEFAULT_APP_SERVER_PORT);
- Ini.setProperty(Ini.P_CONNECTION, toStringLong());
- }
- else
- m_connectionProfile = connectionProfile;
-
- //hengsin, reset initial context and env
- m_iContext = null;
- m_env = null;
- }
- else
- log.warning("Invalid: " + connectionProfile);
} // setConnectionProfile
/**
* Get Connection Profile
* @return connection profile
+ * @deprecated
*/
public String getConnectionProfile ()
{
- if (m_connectionProfile != null)
- return m_connectionProfile;
return PROFILE_LAN;
} // getConnectionProfile
@@ -617,6 +589,7 @@ public class CConnection implements Serializable, Cloneable
* Get Connection Profile Text
* @param connectionProfile
* @return connection profile text
+ * @deprecated
*/
public String getConnectionProfileText (String connectionProfile)
{
@@ -631,6 +604,7 @@ public class CConnection implements Serializable, Cloneable
/**
* Get Connection Profile Text
* @return connection profile text
+ * @deprecated
*/
public String getConnectionProfileText ()
{
@@ -640,6 +614,7 @@ public class CConnection implements Serializable, Cloneable
/**
* Get Connection Profile
* @return connection profile
+ * @deprecated
*/
public ValueNamePair getConnectionProfilePair ()
{
@@ -654,23 +629,21 @@ public class CConnection implements Serializable, Cloneable
/**
* Should objects be created on Server ?
* @return true if client and VPN/WAN
+ * @deprecated
*/
public boolean isServerObjects()
{
- return (Ini.isClient()
- && (getConnectionProfile().equals(PROFILE_VPN)
- || getConnectionProfile().equals(PROFILE_WAN) ));
+ return false;
} // isServerObjects
/**
* Should objects be created on Server ?
* @return true if client and Terminal/VPN/WAN
+ * @deprecated
*/
public boolean isServerProcess()
{
- return (Ini.isClient()
- && (getConnectionProfile().equals(PROFILE_VPN)
- || getConnectionProfile().equals(PROFILE_WAN) ));
+ return false;
} // isServerProcess
/**
@@ -956,10 +929,6 @@ public class CConnection implements Serializable, Cloneable
*/
public Exception testDatabase(boolean retest)
{
- // At this point Application Server Connection is tested.
- if (DB.isRemoteObjects())
- return null;
-
if (!retest && m_ds != null && m_okDB)
return null;
@@ -1093,7 +1062,6 @@ public class CConnection implements Serializable, Cloneable
sb.append ("name=").append (m_name)
.append (",AppsHost=").append (m_apps_host)
.append (",AppsPort=").append (m_apps_port)
- .append (",Profile=").append (getConnectionProfile())
.append (",type=").append (m_type)
.append (",DBhost=").append (m_db_host)
.append (",DBport=").append (m_db_port)
@@ -1121,9 +1089,6 @@ public class CConnection implements Serializable, Cloneable
setAppsHost (attributes.substring (attributes.indexOf ("AppsHost=") + 9, attributes.indexOf (",AppsPort=")));
int index = attributes.indexOf("AppsPort=");
setAppsPort (attributes.substring (index + 9, attributes.indexOf (",", index)));
- index = attributes.indexOf("Profile=");
- if (index > 0) // new attribute, may not exist
- setConnectionProfile(attributes.substring(index+8, attributes.indexOf (",", index)));
//
setType (attributes.substring (attributes.indexOf ("type=")+5, attributes.indexOf (",DBhost=")));
setDbHost (attributes.substring (attributes.indexOf ("DBhost=") + 7, attributes.indexOf (",DBport=")));
@@ -1159,7 +1124,6 @@ public class CConnection implements Serializable, Cloneable
&& cc.getAppsPort() == m_apps_port
&& cc.getDbHost().equals (m_db_host)
&& cc.getDbPort() == m_db_port
- && cc.getConnectionProfile().equals(getConnectionProfile())
&& cc.getDbName().equals(m_db_name)
&& cc.getType().equals(m_type)
&& cc.getDbUid().equals(m_db_uid)
@@ -1217,12 +1181,8 @@ public class CConnection implements Serializable, Cloneable
break;
}
}
- //hengsin, don't test datasource for wan profile
- if (!DB.isRemoteObjects())
- {
- if (m_db != null) // test class loader ability
- m_db.getDataSource(this);
- }
+ if (m_db != null) // test class loader ability
+ m_db.getDataSource(this);
}
catch (NoClassDefFoundError ee)
{
@@ -1448,7 +1408,7 @@ public class CConnection implements Serializable, Cloneable
* Get Initial Environment
* @param AppsHost host
* @param AppsPort port
- * @param RMIoverHTTP true if tunnel through HTTP
+ * @param RMIoverHTTP ignore
* @param principal
* @param credential
* @return environment
@@ -1459,21 +1419,9 @@ public class CConnection implements Serializable, Cloneable
// Set Environment
Hashtable env = new Hashtable();
String connect = AppsHost;
- if (RMIoverHTTP)
- {
- env.put (Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.HttpNamingContextFactory");
- if (AppsHost.indexOf("://") == -1)
- connect = "http://" + AppsHost + ":" + AppsPort
- + "/invoker/JNDIFactory";
- env.put(Context.PROVIDER_URL, connect);
- }
- else
- {
- env.put (Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
- if (AppsHost.indexOf("://") == -1)
- connect = "jnp://" + AppsHost + ":" + AppsPort;
- env.put (Context.PROVIDER_URL, connect);
- }
+ if (AppsHost.indexOf("://") == -1)
+ connect = "jnp://" + AppsHost + ":" + AppsPort;
+ env.put (Context.PROVIDER_URL, connect);
env.put (Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
// HTTP - default timeout 0
env.put (org.jnp.interfaces.TimedSocketFactory.JNP_TIMEOUT, "5000"); // timeout in ms
@@ -1483,13 +1431,13 @@ public class CConnection implements Serializable, Cloneable
if (principal != null && credential != null)
{
- SecurityAssociation.setPrincipal(new SimplePrincipal(principal));
- SecurityAssociation.setCredential(credential);
+ env.put (Context.INITIAL_CONTEXT_FACTORY,"org.jboss.security.jndi.JndiLoginInitialContextFactory");
+ env.put(Context.SECURITY_PRINCIPAL, principal);
+ env.put(Context.SECURITY_CREDENTIALS, credential);
}
else
{
- SecurityAssociation.setPrincipal(null);
- SecurityAssociation.setCredential(null);
+ env.put (Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
}
return env;
@@ -1600,10 +1548,7 @@ public class CConnection implements Serializable, Cloneable
setDbPort (svr.getDbPort ());
setDbName (svr.getDbName ());
setDbUid (svr.getDbUid ());
- if (DB.isRemoteObjects())
- setDbPwd ("");
- else
- setDbPwd (svr.getDbPwd ());
+ setDbPwd (svr.getDbPwd ());
setBequeath (false);
//
setFwHost (svr.getFwHost ());
diff --git a/base/src/org/compiere/db/CConnectionDialog.java b/base/src/org/compiere/db/CConnectionDialog.java
index 87089b1dd6..c1955bda2d 100644
--- a/base/src/org/compiere/db/CConnectionDialog.java
+++ b/base/src/org/compiere/db/CConnectionDialog.java
@@ -122,8 +122,6 @@ public class CConnectionDialog extends CDialog implements ActionListener
private CLabel dbUidLabel = new CLabel();
private CTextField dbUidField = new CTextField();
private JPasswordField dbPwdField = new JPasswordField();
- private CLabel connectionProfileLabel = new CLabel();
- private CComboBox connectionProfileField = new CComboBox(CConnection.CONNECTIONProfiles);
private boolean isCancel = true;
@@ -166,8 +164,6 @@ public class CConnectionDialog extends CDialog implements ActionListener
//cbOverwrite.setText(res.getString("Overwrite"));
dbUidLabel.setText(res.getString("DBUidPwd"));
dbUidField.setColumns(10);
- connectionProfileLabel.setText(res.getString("ConnectionProfile"));
- connectionProfileField.addActionListener(this);
this.getContentPane().add(mainPanel, BorderLayout.CENTER);
mainPanel.add(centerPanel, BorderLayout.CENTER);
mainPanel.add(southPanel, BorderLayout.SOUTH);
@@ -187,51 +183,47 @@ public class CConnectionDialog extends CDialog implements ActionListener
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
centerPanel.add(appsPortField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
- centerPanel.add(connectionProfileLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
- ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0));
- centerPanel.add(connectionProfileField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0
- ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0));
//
- centerPanel.add(bTestApps, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0
+ centerPanel.add(bTestApps, new GridBagConstraints(1, 3, 1, 1, 0.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
//,GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0, 5, 0, 12), 0, 0));
// DB
- centerPanel.add(dbTypeLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0
+ centerPanel.add(dbTypeLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0));
- centerPanel.add(dbTypeField, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0
+ centerPanel.add(dbTypeField, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0));
- centerPanel.add(cbBequeath, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0
+ centerPanel.add(cbBequeath, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 12), 0, 0));
- centerPanel.add(hostLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0
+ centerPanel.add(hostLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0));
- centerPanel.add(hostField, new GridBagConstraints(1, 6, 2, 1, 0.0, 0.0
+ centerPanel.add(hostField, new GridBagConstraints(1, 5, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0));
- centerPanel.add(portLabel, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0
+ centerPanel.add(portLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
- centerPanel.add(dbPortField, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0
+ centerPanel.add(dbPortField, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
- centerPanel.add(sidLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0
+ centerPanel.add(sidLabel, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
- centerPanel.add(sidField, new GridBagConstraints(1, 8, 2, 1, 0.0, 0.0
+ centerPanel.add(sidField, new GridBagConstraints(1, 7, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0));
- centerPanel.add(dbUidLabel, new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0
+ centerPanel.add(dbUidLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
- centerPanel.add(dbUidField, new GridBagConstraints(1, 9, 1, 1, 0.0, 0.0
+ centerPanel.add(dbUidField, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
- centerPanel.add(dbPwdField, new GridBagConstraints(2, 9, 1, 1, 1.0, 0.0
+ centerPanel.add(dbPwdField, new GridBagConstraints(2, 8, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 12), 0, 0));
- centerPanel.add(cbFirewall, new GridBagConstraints(1, 10, 2, 1, 0.0, 0.0
+ centerPanel.add(cbFirewall, new GridBagConstraints(1, 9, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 12), 0, 0));
- centerPanel.add(fwHostLabel, new GridBagConstraints(0, 11, 1, 1, 0.0, 0.0
+ centerPanel.add(fwHostLabel, new GridBagConstraints(0, 10, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
- centerPanel.add(fwHostField, new GridBagConstraints(1, 11, 2, 1, 0.0, 0.0
+ centerPanel.add(fwHostField, new GridBagConstraints(1, 10, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0));
- centerPanel.add(fwPortLabel, new GridBagConstraints(0, 12, 1, 1, 0.0, 0.0
+ centerPanel.add(fwPortLabel, new GridBagConstraints(0, 11, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
- centerPanel.add(fwPortField, new GridBagConstraints(1, 12, 1, 1, 0.0, 0.0
+ centerPanel.add(fwPortField, new GridBagConstraints(1, 11, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
- centerPanel.add(bTestDB, new GridBagConstraints(1, 13, 1, 1, 0.0, 0.0
+ centerPanel.add(bTestDB, new GridBagConstraints(1, 12, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 12, 0), 0, 0));
//
nameField.addActionListener(this);
@@ -260,8 +252,6 @@ public class CConnectionDialog extends CDialog implements ActionListener
appsPortLabel.setVisible(false);
appsPortField.setVisible(false);
bTestApps.setVisible(false);
- connectionProfileLabel.setVisible(false);
- connectionProfileField.setVisible(false);
}
else // Client
cbBequeath.setVisible(false);
@@ -342,16 +332,6 @@ public class CConnectionDialog extends CDialog implements ActionListener
dispose();
return;
}
- else if (src == connectionProfileField)
- {
- ValueNamePair pp = (ValueNamePair)connectionProfileField.getSelectedItem();
- m_cc.setConnectionProfile(pp.getValue());
- if (m_cc.isRMIoverHTTP())
- appsPortField.setText(APPS_PORT_HTTP);
- else
- appsPortField.setText(APPS_PORT_JNP);
- return;
- }
else if (src == dbTypeField)
{
if (dbTypeField.getSelectedItem() == null)
@@ -395,9 +375,6 @@ public class CConnectionDialog extends CDialog implements ActionListener
else
m_cc.setAppsHost("localhost");
//
- ValueNamePair pp = (ValueNamePair)connectionProfileField.getSelectedItem();
- m_cc.setConnectionProfile(pp.getValue());
- //
m_cc.setType((String)dbTypeField.getSelectedItem());
m_cc.setDbHost(hostField.getText());
m_cc.setDbPort(dbPortField.getText());
@@ -420,19 +397,6 @@ public class CConnectionDialog extends CDialog implements ActionListener
appsHostField.setText(m_cc.getAppsHost());
appsPortField.setText(String.valueOf(m_cc.getAppsPort()));
//
- String cp = m_cc.getConnectionProfile();
- ValueNamePair cpPP = null;
- for (int i = 0; i < CConnection.CONNECTIONProfiles.length; i++)
- {
- if (cp.equals(CConnection.CONNECTIONProfiles[i].getValue()))
- {
- cpPP = CConnection.CONNECTIONProfiles[i];
- break;
- }
- }
- if (cpPP == null) // LAN
- cpPP = CConnection.CONNECTIONProfiles[0];
- connectionProfileField.setSelectedItem(cpPP);
bTestApps.setIcon(getStatusIcon(m_cc.isAppsServerOK(false)));
// bTestApps.setToolTipText(m_cc.getRmiUri());
diff --git a/base/src/org/compiere/db/CallableStatementProxy.java b/base/src/org/compiere/db/CallableStatementProxy.java
new file mode 100644
index 0000000000..4ed3b4ff43
--- /dev/null
+++ b/base/src/org/compiere/db/CallableStatementProxy.java
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * Copyright (C) 2008 Low Heng Sin *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * You should have received a copy of the GNU General Public License along *
+ * with this program; if not, write to the Free Software Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.util.logging.Level;
+
+import org.adempiere.exceptions.DBException;
+import org.compiere.util.CStatementVO;
+import org.compiere.util.DB;
+import org.compiere.util.Trx;
+
+/**
+ * Dynamic proxy for the CCallableStatement
+ * @author Low Heng Sin
+ */
+public class CallableStatementProxy extends PreparedStatementProxy {
+
+ public CallableStatementProxy(CStatementVO vo) {
+ super(vo);
+ }
+
+ public CallableStatementProxy(int resultSetType, int resultSetConcurrency,
+ String sql0, String trxName) {
+ super(resultSetType, resultSetConcurrency, sql0, trxName);
+ }
+
+ /**
+ * Initialise the prepared statement wrapper object
+ */
+ protected void init()
+ {
+ try
+ {
+ Connection conn = null;
+ Trx trx = p_vo.getTrxName() == null ? null : Trx.get(p_vo.getTrxName(), true);
+ if (trx != null)
+ {
+ conn = trx.getConnection();
+ }
+ else
+ {
+ if (p_vo.getResultSetConcurrency() == ResultSet.CONCUR_UPDATABLE)
+ m_conn = DB.getConnectionRW ();
+ else
+ m_conn = DB.getConnectionRO();
+ conn = m_conn;
+ }
+ if (conn == null)
+ throw new DBException("No Connection");
+ p_stmt = conn.prepareCall(p_vo.getSql(), p_vo.getResultSetType(), p_vo.getResultSetConcurrency());
+ return;
+ }
+ catch (Exception e)
+ {
+ log.log(Level.SEVERE, p_vo.getSql(), e);
+ throw new DBException(e);
+ }
+ }
+}
diff --git a/base/src/org/compiere/db/PreparedStatementProxy.java b/base/src/org/compiere/db/PreparedStatementProxy.java
new file mode 100644
index 0000000000..fd68950896
--- /dev/null
+++ b/base/src/org/compiere/db/PreparedStatementProxy.java
@@ -0,0 +1,104 @@
+/******************************************************************************
+ * Copyright (C) 2008 Low Heng Sin *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * You should have received a copy of the GNU General Public License along *
+ * with this program; if not, write to the Free Software Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.logging.Level;
+
+import javax.sql.RowSet;
+
+import org.adempiere.exceptions.DBException;
+import org.compiere.util.CCachedRowSet;
+import org.compiere.util.CStatementVO;
+import org.compiere.util.DB;
+import org.compiere.util.Trx;
+
+/**
+ * Dynamic proxy for the CPreparedStatement interface
+ * @author Low Heng Sin
+ */
+public class PreparedStatementProxy extends StatementProxy {
+
+ public PreparedStatementProxy(int resultSetType, int resultSetConcurrency,
+ String sql0, String trxName) {
+ if (sql0 == null || sql0.length() == 0)
+ throw new IllegalArgumentException("sql required");
+
+ p_vo = new CStatementVO(resultSetType, resultSetConcurrency, DB
+ .getDatabase().convertStatement(sql0));
+
+ p_vo.setTrxName(trxName);
+
+ init();
+ } // PreparedStatementProxy
+
+ public PreparedStatementProxy(CStatementVO vo)
+ {
+ super(vo);
+ } // PreparedStatementProxy
+
+ /**
+ * Initialise the prepared statement wrapper object
+ */
+ protected void init() {
+ try {
+ Connection conn = null;
+ Trx trx = p_vo.getTrxName() == null ? null : Trx.get(p_vo
+ .getTrxName(), true);
+ if (trx != null) {
+ conn = trx.getConnection();
+ } else {
+ if (p_vo.getResultSetConcurrency() == ResultSet.CONCUR_UPDATABLE)
+ m_conn = DB.getConnectionRW();
+ else
+ m_conn = DB.getConnectionRO();
+ conn = m_conn;
+ }
+ if (conn == null)
+ throw new DBException("No Connection");
+ p_stmt = conn.prepareStatement(p_vo.getSql(), p_vo
+ .getResultSetType(), p_vo.getResultSetConcurrency());
+ } catch (Exception e) {
+ log.log(Level.SEVERE, p_vo.getSql(), e);
+ throw new DBException(e);
+ }
+ }
+
+ @Override
+ protected RowSet getRowSet()
+ {
+ log.finest("local_getRowSet");
+
+ RowSet rowSet = null;
+ ResultSet rs = null;
+ PreparedStatement pstmt = (PreparedStatement)p_stmt;
+ try
+ {
+ rs = pstmt.executeQuery();
+ rowSet = CCachedRowSet.getRowSet(rs);
+ }
+ catch (Exception ex)
+ {
+ log.log(Level.SEVERE, p_vo.toString(), ex);
+ throw new RuntimeException (ex);
+ }
+ finally
+ {
+ DB.close(rs);
+ }
+ return rowSet;
+ } // local_getRowSet
+
+}
diff --git a/base/src/org/compiere/db/ProxyFactory.java b/base/src/org/compiere/db/ProxyFactory.java
new file mode 100644
index 0000000000..b61ed39b8f
--- /dev/null
+++ b/base/src/org/compiere/db/ProxyFactory.java
@@ -0,0 +1,106 @@
+/******************************************************************************
+ * Copyright (C) 2008 Low Heng Sin *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * You should have received a copy of the GNU General Public License along *
+ * with this program; if not, write to the Free Software Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.lang.reflect.Proxy;
+
+import org.compiere.util.CCallableStatement;
+import org.compiere.util.CPreparedStatement;
+import org.compiere.util.CStatement;
+import org.compiere.util.CStatementVO;
+
+/**
+ *
+ * Factory class to instantiate dynamic proxy for CStatement, CPreparedStatement and CCallableStatement
+ * @author Low Heng Sin
+ *
+ */
+public class ProxyFactory {
+
+ /**
+ *
+ * @param resultSetType
+ * @param resultSetConcurrency
+ * @param trxName
+ * @return CStatement proxy
+ */
+ public static CStatement newCStatement(int resultSetType,
+ int resultSetConcurrency, String trxName) {
+ return (CStatement)Proxy.newProxyInstance(CStatement.class.getClassLoader(),
+ new Class[]{CStatement.class},
+ new StatementProxy(resultSetType, resultSetConcurrency, trxName));
+ }
+
+ /**
+ *
+ * @param resultSetType
+ * @param resultSetConcurrency
+ * @param sql
+ * @param trxName
+ * @return CPreparedStatement proxy
+ */
+ public static CPreparedStatement newCPreparedStatement(int resultSetType,
+ int resultSetConcurrency, String sql, String trxName) {
+ return (CPreparedStatement)Proxy.newProxyInstance(CPreparedStatement.class.getClassLoader(),
+ new Class[]{CPreparedStatement.class},
+ new PreparedStatementProxy(resultSetType, resultSetConcurrency, sql, trxName));
+ }
+
+ /**
+ *
+ * @param resultSetType
+ * @param resultSetConcurrency
+ * @param sql
+ * @param trxName
+ * @return CCallableStatement proxy
+ */
+ public static CCallableStatement newCCallableStatement(int resultSetType,
+ int resultSetConcurrency, String sql, String trxName) {
+ return (CCallableStatement)Proxy.newProxyInstance(CCallableStatement.class.getClassLoader(),
+ new Class[]{CCallableStatement.class},
+ new CallableStatementProxy(resultSetType, resultSetConcurrency, sql, trxName));
+ }
+
+ /**
+ *
+ * @param info
+ * @return CStatement proxy
+ */
+ public static CStatement newCStatement(CStatementVO info) {
+ return (CStatement)Proxy.newProxyInstance(CStatement.class.getClassLoader(),
+ new Class[]{CStatement.class},
+ new StatementProxy(info));
+ }
+
+ /**
+ *
+ * @param info
+ * @return CPreparedStatement proxy
+ */
+ public static CPreparedStatement newCPreparedStatement(CStatementVO info) {
+ return (CPreparedStatement)Proxy.newProxyInstance(CPreparedStatement.class.getClassLoader(),
+ new Class[]{CPreparedStatement.class},
+ new PreparedStatementProxy(info));
+ }
+
+ /**
+ *
+ * @param info
+ * @return CCallableStatement proxy
+ */
+ public static CCallableStatement newCCallableStatement(CStatementVO info) {
+ return (CCallableStatement)Proxy.newProxyInstance(CCallableStatement.class.getClassLoader(),
+ new Class[]{CCallableStatement.class},
+ new CallableStatementProxy(info));
+ }
+}
diff --git a/base/src/org/compiere/db/ServerConnection.java b/base/src/org/compiere/db/ServerConnection.java
deleted file mode 100644
index a1a46af732..0000000000
--- a/base/src/org/compiere/db/ServerConnection.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/**
- * Product: Posterita Web-Based POS, Webstore and Adempiere Plugin
- * Copyright (C) 2007 Posterita Ltd
- * This file is part of POSterita
- *
- * POSterita is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-
-package org.compiere.db;
-
-import java.sql.CallableStatement;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import java.sql.Savepoint;
-import java.sql.Statement;
-import java.util.Map;
-
-import org.compiere.util.DB;
-import org.compiere.util.Trx;
-
-/**
- * Connection that is used to execute query on Server for Client processes
- * Need for Jasper Report processes as the Jasper Manager uses a connection
- *
- * @author Ashley G Ramdass
- */
-public class ServerConnection implements Connection
-{
-
- private String trxName = null;
-
- public ServerConnection() {
- }
-
- public ServerConnection(String trxName) {
- this.trxName = trxName;
- }
-
- public void clearWarnings() throws SQLException
- {
- throw new java.lang.UnsupportedOperationException ("Method clearWarnings() not yet implemented.");
- }
-
- public void close() throws SQLException
- {
- if (trxName != null) {
- Trx trx = Trx.get(trxName, false);
- if (trx != null)
- trx.close();
- trxName = null;
- }
- }
-
- public void commit() throws SQLException
- {
- if (trxName != null) {
- Trx trx = Trx.get(trxName, false);
- if (trx != null)
- trx.commit(true);
- }
- }
-
- public Statement createStatement() throws SQLException
- {
- return DB.createStatement();
- }
-
- public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
- {
- return DB.createStatement(resultSetType, resultSetConcurrency, trxName);
- }
-
- public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- {
- return createStatement(resultSetType, resultSetConcurrency);
- }
-
- public boolean getAutoCommit() throws SQLException
- {
- return (trxName != null);
- }
-
- public String getCatalog() throws SQLException
- {
- throw new java.lang.UnsupportedOperationException ("Method getCatalog() not yet implemented.");
- }
-
- public int getHoldability() throws SQLException
- {
- throw new java.lang.UnsupportedOperationException ("Method getHoldability() not yet implemented.");
- }
-
- public DatabaseMetaData getMetaData() throws SQLException
- {
- throw new java.lang.UnsupportedOperationException ("Method getMetaData() not yet implemented.");
- }
-
- public int getTransactionIsolation() throws SQLException
- {
- return Connection.TRANSACTION_READ_COMMITTED;
- }
-
- public Map> getTypeMap() throws SQLException
- {
- throw new java.lang.UnsupportedOperationException ("Method getTypeMap() not yet implemented.");
- }
-
- public SQLWarning getWarnings() throws SQLException
- {
- return null;
- }
-
- public boolean isClosed() throws SQLException
- {
- return false;
- }
-
- public boolean isReadOnly() throws SQLException
- {
- return false;
- }
-
- public String nativeSQL(String sql) throws SQLException
- {
- throw new java.lang.UnsupportedOperationException ("Method nativeSQL() not yet implemented.");
- }
-
- public CallableStatement prepareCall(String sql) throws SQLException
- {
- return DB.prepareCall(sql);
- }
-
- public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- {
- return DB.prepareCall(sql, resultSetConcurrency, trxName);
- }
-
- public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- {
- return DB.prepareCall(sql, resultSetConcurrency, trxName);
- }
-
- public PreparedStatement prepareStatement(String sql) throws SQLException
- {
- return DB.prepareStatement(sql);
- }
-
- public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
- {
- throw new java.lang.UnsupportedOperationException ("Method prepareStatement() not yet implemented.");
- }
-
- public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
- {
- throw new java.lang.UnsupportedOperationException ("Method prepareStatement() not yet implemented.");
- }
-
- public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
- {
- throw new java.lang.UnsupportedOperationException ("Method prepareStatement() not yet implemented.");
- }
-
- public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- {
- return DB.prepareStatement(sql, resultSetConcurrency, resultSetConcurrency);
- }
-
- public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- {
- return prepareStatement(sql, resultSetType, resultSetConcurrency);
- }
-
- public void releaseSavepoint(Savepoint savepoint) throws SQLException
- {
- throw new java.lang.UnsupportedOperationException ("Method releaseSavepoint() not yet implemented.");
- }
-
- public void rollback() throws SQLException
- {
- if (trxName != null) {
- Trx trx = Trx.get(trxName, false);
- if (trx != null)
- trx.rollback(true);
- }
- }
-
- public void rollback(Savepoint savepoint) throws SQLException
- {
- throw new java.lang.UnsupportedOperationException ("Method rollback() not yet implemented.");
- }
-
- public void setAutoCommit(boolean autoCommit) throws SQLException
- {
- if (autoCommit) {
- if (trxName != null) {
- Trx trx = Trx.get(trxName, false);
- if (trx != null)
- trx.close();
- }
- } else {
- if (trxName == null) {
- trxName = Trx.createTrxName();
- }
- }
- }
-
- public void setCatalog(String catalog) throws SQLException
- {
- throw new java.lang.UnsupportedOperationException ("Method setCatalog() not yet implemented.");
- }
-
- public void setHoldability(int holdability) throws SQLException
- {
- throw new java.lang.UnsupportedOperationException ("Method setHoldability() not yet implemented.");
- }
-
- public void setReadOnly(boolean readOnly) throws SQLException
- {
- }
-
- public Savepoint setSavepoint() throws SQLException
- {
- return setSavepoint(null);
- }
-
- public Savepoint setSavepoint(String name) throws SQLException
- {
- if (trxName == null) {
- trxName = Trx.createTrxName();
- }
- Trx trx = Trx.get(trxName, false);
- return trx.setSavepoint(name);
- }
-
- public void setTransactionIsolation(int level) throws SQLException
- {
- }
-
- public void setTypeMap(Map> arg0) throws SQLException
- {
- throw new java.lang.UnsupportedOperationException ("Method setTypeMap() not yet implemented.");
- }
-
- /* Java 6 support - teo_sarca BF [ 1806700 ] */
- public java.sql.Array createArrayOf(String typeName, Object[] elements) throws SQLException {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
-
- public java.sql.Blob createBlob() throws SQLException {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
-
- public java.sql.Clob createClob() throws SQLException {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
-
- public java.sql.NClob createNClob() throws SQLException {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
-
- public java.sql.SQLXML createSQLXML() throws SQLException {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
-
- public java.sql.Struct createStruct(String typeName, Object[] attributes) throws SQLException {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
-
- public java.util.Properties getClientInfo() throws SQLException {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
-
- public String getClientInfo(String name) throws SQLException {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
-
- public boolean isValid(int timeout) throws SQLException {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
-
- public void setClientInfo(java.util.Properties properties) throws java.sql.SQLClientInfoException {
- }
-
- public void setClientInfo(String name, String value) throws java.sql.SQLClientInfoException {
- }
-
- public boolean isWrapperFor(Class> iface) throws SQLException {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
-
- public T unwrap(Class iface) throws SQLException {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- /* Java 6 support - teo_sarca BF [ 1806700 ] */
-}
diff --git a/base/src/org/compiere/db/StatementProxy.java b/base/src/org/compiere/db/StatementProxy.java
new file mode 100644
index 0000000000..1cd3accf95
--- /dev/null
+++ b/base/src/org/compiere/db/StatementProxy.java
@@ -0,0 +1,198 @@
+/******************************************************************************
+ * Copyright (C) 2008 Low Heng Sin *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * You should have received a copy of the GNU General Public License along *
+ * with this program; if not, write to the Free Software Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.logging.Level;
+
+import javax.sql.RowSet;
+
+import org.adempiere.exceptions.DBException;
+import org.compiere.util.CCachedRowSet;
+import org.compiere.util.CLogger;
+import org.compiere.util.CStatementVO;
+import org.compiere.util.DB;
+import org.compiere.util.Trx;
+
+/**
+ *
+ * Dynamic proxy for the CStatement interface
+ * @author Low Heng Sin
+ */
+public class StatementProxy implements InvocationHandler {
+
+ protected Connection m_conn = null;
+
+ private boolean close = false;
+
+ /** Logger */
+ protected transient CLogger log = CLogger.getCLogger (getClass());
+ /** Used if local */
+ protected transient Statement p_stmt = null;
+ /** Value Object */
+ protected CStatementVO p_vo = null;
+
+ public StatementProxy(int resultSetType, int resultSetConcurrency, String trxName) {
+ p_vo = new CStatementVO (resultSetType, resultSetConcurrency);
+ p_vo.setTrxName(trxName);
+
+ init();
+ }
+
+ public StatementProxy(CStatementVO vo) {
+ p_vo = vo;
+ init();
+ }
+
+ //for subclass
+ protected StatementProxy() {}
+
+ public Object invoke(Object obj, Method method, Object[] args)
+ throws Throwable {
+ String name = method.getName();
+ //handle special case
+ if (name.equals("executeQuery") || name.equals("executeUpdate")
+ || name.equals("execute") || name.equals("addBatch")) {
+ if (args != null && args.length > 0 && args[0] != null && args[0] instanceof String) {
+ String sql = (String)args[0];
+ p_vo.setSql(DB.getDatabase().convertStatement(sql));
+ args[0] = p_vo.getSql();
+ }
+ } else if (name.equals("close") && (args == null || args.length == 0)) {
+ close();
+ return null;
+ } else if (name.equals("getRowSet") && (args == null || args.length == 0)) {
+ return getRowSet();
+ } else if (name.equals("isClosed") && (args == null || args.length == 0)) {
+ return close;
+ } else if (name.equals("finalize") && (args == null || args.length == 0)) {
+ if (p_stmt != null && !close)
+ {
+ this.close();
+ }
+ return null;
+ } else if (name.equals("commit") && (args == null || args.length == 0)) {
+ commit();
+ return null;
+ }
+
+ Method m = p_stmt.getClass().getMethod(name, method.getParameterTypes());
+ return m.invoke(p_stmt, args);
+ }
+
+ /**
+ * Initialise the statement wrapper object
+ */
+ protected void init()
+ {
+ try
+ {
+ Connection conn = null;
+ Trx trx = p_vo.getTrxName() == null ? null : Trx.get(p_vo.getTrxName(), true);
+ if (trx != null)
+ {
+ conn = trx.getConnection();
+ }
+ else
+ {
+ if (p_vo.getResultSetConcurrency() == ResultSet.CONCUR_UPDATABLE)
+ m_conn = DB.getConnectionRW ();
+ else
+ m_conn = DB.getConnectionRO();
+ conn = m_conn;
+ }
+ if (conn == null)
+ throw new DBException("No Connection");
+ p_stmt = conn.createStatement(p_vo.getResultSetType(), p_vo.getResultSetConcurrency());
+ }
+ catch (SQLException e)
+ {
+ log.log(Level.SEVERE, "CStatement", e);
+ throw new DBException(e);
+ }
+ }
+
+ /**
+ * Close
+ * @throws SQLException
+ * @see java.sql.Statement#close()
+ */
+ private void close () throws SQLException
+ {
+ if (close) return;
+
+ try {
+ if (p_stmt != null)
+ {
+ p_stmt.close();
+ }
+ } finally {
+ if (m_conn != null)
+ {
+ try
+ {
+ m_conn.close();
+ }
+ catch (Exception e)
+ {}
+ }
+ m_conn = null;
+ close = true;
+ }
+ } // close
+
+ /**
+ * Execute Query
+ * @return ResultSet or RowSet
+ * @throws SQLException
+ * @see java.sql.PreparedStatement#executeQuery()
+ */
+ protected RowSet getRowSet()
+ {
+ log.finest("getRowSet");
+ RowSet rowSet = null;
+ ResultSet rs = null;
+ try
+ {
+ rs = p_stmt.executeQuery(p_vo.getSql());
+ rowSet = CCachedRowSet.getRowSet(rs);
+ }
+ catch (Exception ex)
+ {
+ log.log(Level.SEVERE, p_vo.toString(), ex);
+ throw new RuntimeException (ex);
+ }
+ finally
+ {
+ DB.close(rs);
+ }
+ return rowSet;
+ } // local_getRowSet
+
+ /**
+ * Commit (if local)
+ * @throws SQLException
+ */
+ private void commit() throws SQLException
+ {
+ if (m_conn != null && !m_conn.getAutoCommit())
+ {
+ m_conn.commit();
+ }
+ } // commit
+}
diff --git a/base/src/org/compiere/interfaces/Server.java b/base/src/org/compiere/interfaces/Server.java
index 356688be0f..5aa1609883 100644
--- a/base/src/org/compiere/interfaces/Server.java
+++ b/base/src/org/compiere/interfaces/Server.java
@@ -9,16 +9,6 @@ package org.compiere.interfaces;
public interface Server
extends javax.ejb.EJBObject
{
- /**
- * Get and create Window Model Value Object
- * @param ctx Environment Properties
- * @param WindowNo number of this window
- * @param AD_Window_ID the internal number of the window, if not 0, AD_Menu_ID is ignored
- * @param AD_Menu_ID ine internal menu number, used when AD_Window_ID is 0
- * @return initialized Window Model */
- public org.compiere.model.GridWindowVO getWindowVO( java.util.Properties ctx,int WindowNo,int AD_Window_ID,int AD_Menu_ID )
- throws java.rmi.RemoteException;
-
/**
* Post Immediate
* @param ctx Client Context
@@ -31,82 +21,6 @@ public interface Server
public java.lang.String postImmediate( java.util.Properties ctx,int AD_Client_ID,int AD_Table_ID,int Record_ID,boolean force,java.lang.String trxName )
throws java.rmi.RemoteException;
- /**
- * Get Prepared Statement ResultSet
- * @param info Result info
- * @param token Security Token
- * @return RowSet
- * @throws NotSerializableException */
- public javax.sql.RowSet pstmt_getRowSet( org.compiere.util.CStatementVO info,org.compiere.util.SecurityToken token )
- throws java.io.NotSerializableException, java.rmi.RemoteException;
-
- /**
- * Get Statement ResultSet
- * @param info Result info
- * @param token Security Token
- * @return RowSet */
- public javax.sql.RowSet stmt_getRowSet( org.compiere.util.CStatementVO info,org.compiere.util.SecurityToken token )
- throws java.rmi.RemoteException;
-
- /**
- * Execute Update
- * @param info Result info
- * @param token Security Token
- * @return row count */
- public int stmt_executeUpdate( org.compiere.util.CStatementVO info,org.compiere.util.SecurityToken token )
- throws java.rmi.RemoteException;
-
- public org.compiere.util.ExecuteResult stmt_execute( org.compiere.util.CStatementVO info,org.compiere.util.SecurityToken token )
- throws java.rmi.RemoteException;
-
- public org.compiere.util.CallableResult callable_execute( org.compiere.util.CStatementVO info,org.compiere.util.SecurityToken token )
- throws java.rmi.RemoteException;
-
- /**
- * Get next number for Key column = 0 is Error.
- * @param AD_Client_ID client
- * @param TableName table name
- * @param trxName optional Transaction Name
- * @return next no */
- public int getNextID( int AD_Client_ID,java.lang.String TableName,java.lang.String trxName )
- throws java.rmi.RemoteException;
-
- /**
- * Get Document No from table
- * @param AD_Client_ID client
- * @param TableName table name
- * @param trxName optional Transaction Name
- * @return document no or null */
- public java.lang.String getDocumentNo( int AD_Client_ID,java.lang.String TableName,java.lang.String trxName )
- throws java.rmi.RemoteException;
-
- /**
- * Get Document No from table
- * @param AD_Client_ID client
- * @param TableName table name
- * @param trxName optional Transaction Name
- * @param po
- * @return document no or null */
- public java.lang.String getDocumentNo( int AD_Client_ID,java.lang.String TableName,java.lang.String trxName,org.compiere.model.PO po )
- throws java.rmi.RemoteException;
-
- /**
- * Get Document No based on Document Type
- * @param C_DocType_ID document type
- * @param trxName optional Transaction Name
- * @return document no or null */
- public java.lang.String getDocumentNo( int C_DocType_ID,java.lang.String trxName,boolean definite )
- throws java.rmi.RemoteException;
-
- /**
- * Get Document No based on Document Type
- * @param C_DocType_ID document type
- * @param trxName optional Transaction Name
- * @param po
- * @return document no or null */
- public java.lang.String getDocumentNo( int C_DocType_ID,java.lang.String trxName,boolean definite,org.compiere.model.PO po )
- throws java.rmi.RemoteException;
-
/**
* Process Remote
* @param ctx Context
@@ -124,16 +38,6 @@ public interface Server
public org.compiere.process.ProcessInfo workflow( java.util.Properties ctx,org.compiere.process.ProcessInfo pi,int AD_Workflow_ID )
throws java.rmi.RemoteException;
- /**
- * Online Payment from Server
- * @param ctx Context
- * @param C_Payment_ID payment
- * @param C_PaymentProcessor_ID processor
- * @param trxName transaction
- * @return true if approved */
- public boolean paymentOnline( java.util.Properties ctx,int C_Payment_ID,int C_PaymentProcessor_ID,java.lang.String trxName )
- throws java.rmi.RemoteException;
-
/**
* Create EMail from Server (Request User)
* @param ctx Context
@@ -158,7 +62,7 @@ public interface Server
throws java.rmi.RemoteException;
/**
- * Create EMail from Server (Request User)
+ * Execute task on server
* @param AD_Task_ID task
* @return execution trace */
public java.lang.String executeTask( int AD_Task_ID )
@@ -172,85 +76,18 @@ public interface Server
public int cacheReset( java.lang.String tableName,int Record_ID )
throws java.rmi.RemoteException;
- /**
- * LOB update
- * @param sql table name
- * @param displayType display type (i.e. BLOB/CLOB)
- * @param value the data
- * @param trxName
- * @param token Security Token
- * @return true if updated */
- public boolean updateLOB( java.lang.String sql,int displayType,java.lang.Object value,java.lang.String trxName,org.compiere.util.SecurityToken token )
- throws java.rmi.RemoteException;
-
/**
* Describes the instance and its content for debugging purpose
* @return Debugging information about the instance and its content */
public java.lang.String getStatus( )
throws java.rmi.RemoteException;
- /**
- * Set savepoint
- * @param trxName
- * @param savePointName
- * @return true if success, false otherwise */
- public org.compiere.util.SavepointVO setSavepoint( java.lang.String trxName,java.lang.String savePointName )
- throws java.rmi.RemoteException;
-
- /**
- * Start remote transaction
- * @param trxName */
- public void startTransaction( java.lang.String trxName )
- throws java.rmi.RemoteException;
-
- /**
- * Close remote transaction
- * @param trxName */
- public void closeTransaction( java.lang.String trxName )
- throws java.rmi.RemoteException;
-
- /**
- * Commit the named transaction on server
- * @param trxName
- * @return true if success, false otherwise */
- public boolean commit( java.lang.String trxName )
- throws java.rmi.RemoteException;
-
- /**
- * Rollback the named transaction on server
- * @param trxName
- * @return true if success, false otherwise */
- public boolean rollback( java.lang.String trxName )
- throws java.rmi.RemoteException;
-
- /**
- * Rollback the named transaction on server
- * @param trxName
- * @return true if success, false otherwise */
- public boolean rollback( java.lang.String trxName,org.compiere.util.SavepointVO savePoint )
- throws java.rmi.RemoteException;
-
/**
* Execute db proces on server
* @param processInfo
* @param procedureName
- * @param trxName
* @return ProcessInfo */
- public org.compiere.process.ProcessInfo dbProcess( org.compiere.process.ProcessInfo processInfo,java.lang.String procedureName,java.lang.String trxName,org.compiere.util.SecurityToken token )
- throws java.rmi.RemoteException;
-
- /**
- * Load fields meta data from database
- * @param gridTabVO
- * @return ArrayList */
- public java.util.ArrayList getFields( org.compiere.model.GridTabVO gridTabVO )
- throws java.rmi.RemoteException;
-
- /**
- * Get table id from ad_table by table name
- * @param tableName
- * @return tableName */
- public int getTableID( java.lang.String tableName )
+ public org.compiere.process.ProcessInfo dbProcess( org.compiere.process.ProcessInfo processInfo,java.lang.String procedureName )
throws java.rmi.RemoteException;
}
diff --git a/base/src/org/compiere/interfaces/ServerLocal.java b/base/src/org/compiere/interfaces/ServerLocal.java
index a7a87d229a..c5b40927ba 100644
--- a/base/src/org/compiere/interfaces/ServerLocal.java
+++ b/base/src/org/compiere/interfaces/ServerLocal.java
@@ -9,15 +9,6 @@ package org.compiere.interfaces;
public interface ServerLocal
extends javax.ejb.EJBLocalObject
{
- /**
- * Get and create Window Model Value Object
- * @param ctx Environment Properties
- * @param WindowNo number of this window
- * @param AD_Window_ID the internal number of the window, if not 0, AD_Menu_ID is ignored
- * @param AD_Menu_ID ine internal menu number, used when AD_Window_ID is 0
- * @return initialized Window Model */
- public org.compiere.model.GridWindowVO getWindowVO( java.util.Properties ctx,int WindowNo,int AD_Window_ID,int AD_Menu_ID ) ;
-
/**
* Post Immediate
* @param ctx Client Context
@@ -29,72 +20,6 @@ public interface ServerLocal
* @return null, if success or error message */
public java.lang.String postImmediate( java.util.Properties ctx,int AD_Client_ID,int AD_Table_ID,int Record_ID,boolean force,java.lang.String trxName ) ;
- /**
- * Get Prepared Statement ResultSet
- * @param info Result info
- * @param token Security Token
- * @return RowSet
- * @throws NotSerializableException */
- public javax.sql.RowSet pstmt_getRowSet( org.compiere.util.CStatementVO info,org.compiere.util.SecurityToken token ) throws java.io.NotSerializableException;
-
- /**
- * Get Statement ResultSet
- * @param info Result info
- * @param token Security Token
- * @return RowSet */
- public javax.sql.RowSet stmt_getRowSet( org.compiere.util.CStatementVO info,org.compiere.util.SecurityToken token ) ;
-
- /**
- * Execute Update
- * @param info Result info
- * @param token Security Token
- * @return row count */
- public int stmt_executeUpdate( org.compiere.util.CStatementVO info,org.compiere.util.SecurityToken token ) ;
-
- public org.compiere.util.ExecuteResult stmt_execute( org.compiere.util.CStatementVO info,org.compiere.util.SecurityToken token ) ;
-
- public org.compiere.util.CallableResult callable_execute( org.compiere.util.CStatementVO info,org.compiere.util.SecurityToken token ) ;
-
- /**
- * Get next number for Key column = 0 is Error.
- * @param AD_Client_ID client
- * @param TableName table name
- * @param trxName optional Transaction Name
- * @return next no */
- public int getNextID( int AD_Client_ID,java.lang.String TableName,java.lang.String trxName ) ;
-
- /**
- * Get Document No from table
- * @param AD_Client_ID client
- * @param TableName table name
- * @param trxName optional Transaction Name
- * @return document no or null */
- public java.lang.String getDocumentNo( int AD_Client_ID,java.lang.String TableName,java.lang.String trxName ) ;
-
- /**
- * Get Document No from table
- * @param AD_Client_ID client
- * @param TableName table name
- * @param trxName optional Transaction Name
- * @param po
- * @return document no or null */
- public java.lang.String getDocumentNo( int AD_Client_ID,java.lang.String TableName,java.lang.String trxName,org.compiere.model.PO po ) ;
-
- /**
- * Get Document No based on Document Type
- * @param C_DocType_ID document type
- * @param trxName optional Transaction Name
- * @return document no or null */
- public java.lang.String getDocumentNo( int C_DocType_ID,java.lang.String trxName,boolean definite ) ;
-
- /**
- * Get Document No based on Document Type
- * @param C_DocType_ID document type
- * @param trxName optional Transaction Name
- * @param po
- * @return document no or null */
- public java.lang.String getDocumentNo( int C_DocType_ID,java.lang.String trxName,boolean definite,org.compiere.model.PO po ) ;
-
/**
* Process Remote
* @param ctx Context
@@ -110,15 +35,6 @@ public interface ServerLocal
* @return process info */
public org.compiere.process.ProcessInfo workflow( java.util.Properties ctx,org.compiere.process.ProcessInfo pi,int AD_Workflow_ID ) ;
- /**
- * Online Payment from Server
- * @param ctx Context
- * @param C_Payment_ID payment
- * @param C_PaymentProcessor_ID processor
- * @param trxName transaction
- * @return true if approved */
- public boolean paymentOnline( java.util.Properties ctx,int C_Payment_ID,int C_PaymentProcessor_ID,java.lang.String trxName ) ;
-
/**
* Create EMail from Server (Request User)
* @param ctx Context
@@ -141,7 +57,7 @@ public interface ServerLocal
public org.compiere.util.EMail createEMail( java.util.Properties ctx,int AD_Client_ID,int AD_User_ID,java.lang.String to,java.lang.String subject,java.lang.String message ) ;
/**
- * Create EMail from Server (Request User)
+ * Execute task on server
* @param AD_Task_ID task
* @return execution trace */
public java.lang.String executeTask( int AD_Task_ID ) ;
@@ -153,74 +69,16 @@ public interface ServerLocal
* @return number of records reset */
public int cacheReset( java.lang.String tableName,int Record_ID ) ;
- /**
- * LOB update
- * @param sql table name
- * @param displayType display type (i.e. BLOB/CLOB)
- * @param value the data
- * @param trxName
- * @param token Security Token
- * @return true if updated */
- public boolean updateLOB( java.lang.String sql,int displayType,java.lang.Object value,java.lang.String trxName,org.compiere.util.SecurityToken token ) ;
-
/**
* Describes the instance and its content for debugging purpose
* @return Debugging information about the instance and its content */
public java.lang.String getStatus( ) ;
- /**
- * Set savepoint
- * @param trxName
- * @param savePointName
- * @return true if success, false otherwise */
- public org.compiere.util.SavepointVO setSavepoint( java.lang.String trxName,java.lang.String savePointName ) ;
-
- /**
- * Start remote transaction
- * @param trxName */
- public void startTransaction( java.lang.String trxName ) ;
-
- /**
- * Close remote transaction
- * @param trxName */
- public void closeTransaction( java.lang.String trxName ) ;
-
- /**
- * Commit the named transaction on server
- * @param trxName
- * @return true if success, false otherwise */
- public boolean commit( java.lang.String trxName ) ;
-
- /**
- * Rollback the named transaction on server
- * @param trxName
- * @return true if success, false otherwise */
- public boolean rollback( java.lang.String trxName ) ;
-
- /**
- * Rollback the named transaction on server
- * @param trxName
- * @return true if success, false otherwise */
- public boolean rollback( java.lang.String trxName,org.compiere.util.SavepointVO savePoint ) ;
-
/**
* Execute db proces on server
* @param processInfo
* @param procedureName
- * @param trxName
* @return ProcessInfo */
- public org.compiere.process.ProcessInfo dbProcess( org.compiere.process.ProcessInfo processInfo,java.lang.String procedureName,java.lang.String trxName,org.compiere.util.SecurityToken token ) ;
-
- /**
- * Load fields meta data from database
- * @param gridTabVO
- * @return ArrayList */
- public java.util.ArrayList getFields( org.compiere.model.GridTabVO gridTabVO ) ;
-
- /**
- * Get table id from ad_table by table name
- * @param tableName
- * @return tableName */
- public int getTableID( java.lang.String tableName ) ;
+ public org.compiere.process.ProcessInfo dbProcess( org.compiere.process.ProcessInfo processInfo,java.lang.String procedureName ) ;
}
diff --git a/base/src/org/compiere/model/GridTabVO.java b/base/src/org/compiere/model/GridTabVO.java
index 53813d3e67..48166680b8 100644
--- a/base/src/org/compiere/model/GridTabVO.java
+++ b/base/src/org/compiere/model/GridTabVO.java
@@ -253,18 +253,6 @@ public class GridTabVO implements Evaluatee, Serializable
*/
private static boolean createFields (GridTabVO mTabVO)
{
- if (DB.isRemoteObjects() && CConnection.get().isAppsServerOK(false))
- {
- remoteCreateFields(mTabVO);
- return mTabVO.initFields;
- }
-
- if (CConnection.get().isServerObjects())
- {
- CLogger.get().log(Level.SEVERE, "Application server not available.");
- return false;
- }
-
//local only or remote fail for vpn profile
mTabVO.Fields = new ArrayList();
@@ -297,50 +285,6 @@ public class GridTabVO implements Evaluatee, Serializable
return mTabVO.Fields.size() != 0;
} // createFields
- private static boolean remoteCreateFields (GridTabVO mTabVO)
- {
-
- Server server = CConnection.get().getServer();
- if (server != null)
- {
- try
- {
- mTabVO.Fields = server.getFields(mTabVO);
- mTabVO.initFields =
- (mTabVO.Fields != null && mTabVO.Fields.size() > 0);
- //sync context
- int size = mTabVO.Fields.size();
- for (int i = 0; i < size; i++)
- {
- GridFieldVO field = (GridFieldVO)mTabVO.Fields.get(i);
- Properties ctx = field.ctx;
- field.setCtx(mTabVO.ctx);
- Set keys = ctx.keySet();
- //check any key added remotely
- for(Iterator k = keys.iterator(); k.hasNext(); )
- {
- Object key = k.next();
- if (mTabVO.ctx.containsKey(key) == false)
- {
- Object value = ctx.get(key);
- mTabVO.ctx.put(key, value);
- }
- }
- }
- } catch (Exception e)
- {
- CLogger.get().log(Level.SEVERE, "Application Server Error: " + e.getLocalizedMessage(), e);
- mTabVO.initFields = false;
- }
- }
- else
- {
- if (CConnection.get().isServerObjects())
- CLogger.get().log(Level.SEVERE, "Remote Connection - Application server not available.");
- }
- return false;
- }
-
/**
* Return the SQL statement used for the MTabVO.create
* @param ctx context
diff --git a/base/src/org/compiere/model/GridTable.java b/base/src/org/compiere/model/GridTable.java
index 4d7808309c..369cde50ed 100644
--- a/base/src/org/compiere/model/GridTable.java
+++ b/base/src/org/compiere/model/GridTable.java
@@ -1213,8 +1213,6 @@ public class GridTable extends AbstractTableModel
Object[] rowDataDB = null;
// Prepare
boolean manualUpdate = ResultSet.CONCUR_READ_ONLY == rs.getConcurrency();
- if (DB.isRemoteObjects())
- manualUpdate = true;
// Manual update if log migration scripts is enabled - teo_sarca BF [ 1901192 ]
if(!manualUpdate && Ini.isPropertyBool(Ini.P_LOGMIGRATIONSCRIPT))
manualUpdate = true;
diff --git a/base/src/org/compiere/model/MPayment.java b/base/src/org/compiere/model/MPayment.java
index a18d27feda..d73354eb3b 100644
--- a/base/src/org/compiere/model/MPayment.java
+++ b/base/src/org/compiere/model/MPayment.java
@@ -457,34 +457,7 @@ public final class MPayment extends X_C_Payment
}
boolean approved = false;
- /** Process Payment on Server */
- if (DB.isRemoteObjects())
- {
- Server server = CConnection.get().getServer();
- try
- {
- if (server != null)
- { // See ServerBean
- String trxName = null; // unconditionally save
- save(trxName); // server reads from disk
- approved = server.paymentOnline (getCtx(), getC_Payment_ID(),
- m_mPaymentProcessor.getC_PaymentProcessor_ID(), trxName);
- if (CLogMgt.isLevelFinest())
- s_log.fine("server => " + approved);
- load(trxName); // server saves to disk
- setIsApproved(approved);
- return approved;
- }
- log.log(Level.WARNING, "AppsServer not found");
- }
- catch (RemoteException ex)
- {
- log.log(Level.SEVERE, "AppsServer error", ex);
- }
- }
- /** **/
-
- // Try locally
+
try
{
PaymentProcessor pp = PaymentProcessor.create(m_mPaymentProcessor, this);
diff --git a/base/src/org/compiere/model/MSequence.java b/base/src/org/compiere/model/MSequence.java
index 7db9fb1468..85550973da 100644
--- a/base/src/org/compiere/model/MSequence.java
+++ b/base/src/org/compiere/model/MSequence.java
@@ -81,30 +81,6 @@ public class MSequence extends X_AD_Sequence
if (TableName == null || TableName.length() == 0)
throw new IllegalArgumentException("TableName missing");
- //get from server
- if (DB.isRemoteObjects())
- {
- Server server = CConnection.get().getServer();
- try
- {
- if (server != null)
- { // See ServerBean
- // hengsin: don't execute getNextID in tranaction to fix performance and locking issue
- int id = server.getNextID(AD_Client_ID, TableName, null);
- s_log.finest("server => " + id);
- if (id < 0)
- throw new DBException("No NextID");
- return id;
- }
- s_log.log(Level.SEVERE, "AppsServer not found - " + TableName);
- }
- catch (RemoteException ex)
- {
- s_log.log(Level.SEVERE, "AppsServer error", ex);
- }
- // Try locally
- }
-
int retValue = -1;
// Check AdempiereSys
@@ -116,7 +92,7 @@ public class MSequence extends X_AD_Sequence
s_log.log(LOGLEVEL, TableName + " - AdempiereSys=" + adempiereSys + " [" + trxName + "]");
//begin vpj-cd e-evolution 09/02/2005 PostgreSQL
String selectSQL = null;
- if (DB.isOracle() == false || DB.isRemoteObjects())
+ if (DB.isOracle() == false)
{
selectSQL = "SELECT CurrentNext, CurrentNextSys, IncrementNo, AD_Sequence_ID "
+ "FROM AD_Sequence "
@@ -382,28 +358,6 @@ public class MSequence extends X_AD_Sequence
if (TableName == null || TableName.length() == 0)
throw new IllegalArgumentException("TableName missing");
- //get from server
- if (DB.isRemoteObjects())
- {
- Server server = CConnection.get().getServer();
- try
- {
- if (server != null)
- { // See ServerBean
- String dn = server.getDocumentNo (AD_Client_ID, TableName, trxName, po);
- s_log.finest("Server => " + dn);
- if (dn != null)
- return dn;
- }
- s_log.log(Level.SEVERE, "AppsServer not found - " + TableName);
- }
- catch (RemoteException ex)
- {
- s_log.log(Level.SEVERE, "AppsServer error", ex);
- }
- }
-
- //local
// Check AdempiereSys
boolean adempiereSys = Ini.isPropertyBool(Ini.P_ADEMPIERESYS);
if (adempiereSys && AD_Client_ID > 11)
@@ -445,7 +399,7 @@ public class MSequence extends X_AD_Sequence
String selectSQL = null;
- if (DB.isOracle() == false || DB.isRemoteObjects())
+ if (DB.isOracle() == false)
{
if (isStartNewYear) {
selectSQL = "SELECT y.CurrentNext, s.CurrentNextSys, s.IncrementNo, s.Prefix, s.Suffix, s.DecimalPattern, s.AD_Sequence_ID "
@@ -673,29 +627,6 @@ public class MSequence extends X_AD_Sequence
return null;
}
- //get from server
-
- if (DB.isRemoteObjects())
- {
- Server server = CConnection.get().getServer();
- try
- {
- if (server != null)
- { // See ServerBean
- String dn = server.getDocumentNo (C_DocType_ID, trxName, definite, po);
- s_log.finest("Server => " + dn);
- if (dn != null)
- return dn;
- }
- s_log.log(Level.SEVERE, "AppsServer not found - " + C_DocType_ID);
- }
- catch (RemoteException ex)
- {
- s_log.log(Level.SEVERE, "AppsServer error", ex);
- }
- }
-
- //local
MDocType dt = MDocType.get (Env.getCtx(), C_DocType_ID); // wrong for SERVER, but r/o
if (dt != null && !dt.isDocNoControlled())
{
diff --git a/base/src/org/compiere/model/MSystem.java b/base/src/org/compiere/model/MSystem.java
index 54927c13a4..a28c6ab51b 100644
--- a/base/src/org/compiere/model/MSystem.java
+++ b/base/src/org/compiere/model/MSystem.java
@@ -417,11 +417,8 @@ public class MSystem extends X_AD_System
*/
private void setDBInfo()
{
- if (!DB.isRemoteObjects())
- {
- String dbAddress = CConnection.get().getConnectionURL();
- setDBAddress(dbAddress.toLowerCase());
- }
+ String dbAddress = CConnection.get().getConnectionURL();
+ setDBAddress(dbAddress.toLowerCase());
//
if (!Ini.isClient())
{
diff --git a/base/src/org/compiere/model/MTable.java b/base/src/org/compiere/model/MTable.java
index 343de05db9..d51b3feabd 100644
--- a/base/src/org/compiere/model/MTable.java
+++ b/base/src/org/compiere/model/MTable.java
@@ -749,21 +749,13 @@ public class MTable extends X_AD_Table
String SQL = "SELECT AD_Table_ID FROM AD_Table WHERE tablename = ?";
try
{
- if (DB.isRemoteObjects())
- {
- Server server = CConnection.get().getServer();
- retValue = server.getTableID(tableName);
- }
- else
- {
- PreparedStatement pstmt = DB.prepareStatement(SQL, null);
- pstmt.setString(1, tableName);
- ResultSet rs = pstmt.executeQuery();
- if (rs.next())
- retValue = rs.getInt(1);
- rs.close();
- pstmt.close();
- }
+ PreparedStatement pstmt = DB.prepareStatement(SQL, null);
+ pstmt.setString(1, tableName);
+ ResultSet rs = pstmt.executeQuery();
+ if (rs.next())
+ retValue = rs.getInt(1);
+ rs.close();
+ pstmt.close();
}
catch (Exception e)
{
diff --git a/base/src/org/compiere/model/PO_LOB.java b/base/src/org/compiere/model/PO_LOB.java
index 1184fde8b8..7b817a3494 100644
--- a/base/src/org/compiere/model/PO_LOB.java
+++ b/base/src/org/compiere/model/PO_LOB.java
@@ -109,28 +109,6 @@ public class PO_LOB implements Serializable
.append(" SET ").append(m_columnName)
.append("=? WHERE ").append(m_whereClause);
//
- boolean success = true;
- if (DB.isRemoteObjects())
- {
- log.fine("[" + trxName + "] - Remote - " + m_value);
- Server server = CConnection.get().getServer();
- try
- {
- if (server != null)
- { // See ServerBean
- success = server.updateLOB (sql.toString(), m_displayType, m_value, trxName, SecurityToken.getInstance());
- if (CLogMgt.isLevelFinest())
- log.fine("server.updateLOB => " + success);
- return success;
- }
- log.log(Level.SEVERE, "AppsServer not found");
- }
- catch (RemoteException ex)
- {
- log.log(Level.SEVERE, "AppsServer error", ex);
- }
- return false;
- }
log.fine("[" + trxName + "] - Local - " + m_value);
// Connection
@@ -150,7 +128,7 @@ public class PO_LOB implements Serializable
}
PreparedStatement pstmt = null;
- success = true;
+ boolean success = true;
try
{
pstmt = con.prepareStatement(sql.toString());
diff --git a/base/src/org/compiere/util/CCallableStatement.java b/base/src/org/compiere/util/CCallableStatement.java
index 65a05ad1d0..29254b6f40 100644
--- a/base/src/org/compiere/util/CCallableStatement.java
+++ b/base/src/org/compiere/util/CCallableStatement.java
@@ -16,1846 +16,13 @@
*****************************************************************************/
package org.compiere.util;
-import java.io.InputStream;
-import java.io.Reader;
-import java.math.BigDecimal;
-import java.net.URL;
-import java.sql.Array;
-import java.sql.Blob;
import java.sql.CallableStatement;
-import java.sql.Clob;
-import java.sql.Connection;
-import java.sql.Date;
-import java.sql.Ref;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Map;
-import java.util.logging.Level;
-
-import org.adempiere.exceptions.DBException;
-import org.compiere.db.CConnection;
-import org.compiere.interfaces.Server;
-
/**
- * Adempiere Callable Statement
- *
- * @author Ashley Ramdass
- * @author Teo Sarca, SC ARHIPAC SERVICE SRL
- * BF [ 1806700 ] Compile error on JAVA 6
+ *
+ * Interface to wrap CallableStatement
+ * @author Low Heng Sin
*/
-public class CCallableStatement extends CPreparedStatement implements CallableStatement
+public interface CCallableStatement extends CPreparedStatement, CallableStatement
{
- /**
- * Callable Statement Constructor
- *
- * @param resultSetType - ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.TYPE_SCROLL_SENSITIVE
- * @param resultSetConcurrency - ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
- * @param sql unconverted sql statement
- * @param trxName transaction name or null
- */
- public CCallableStatement(int resultSetType, int resultSetConcurrency, String sql, String trxName)
- {
- super(resultSetType, resultSetConcurrency, sql, trxName);
- }
-
- public CCallableStatement(CStatementVO vo) {
- super(vo);
- }
-
- /**
- * Initialise the prepared statement wrapper object
- */
- protected void init()
- {
- //Local access
- if (!DB.isRemoteObjects())
- {
- try
- {
- Connection conn = null;
- Trx trx = p_vo.getTrxName() == null ? null : Trx.get(p_vo.getTrxName(), true);
- if (trx != null)
- {
- conn = trx.getConnection();
- }
- else
- {
- if (p_vo.getResultSetConcurrency() == ResultSet.CONCUR_UPDATABLE)
- m_conn = DB.getConnectionRW ();
- else
- m_conn = DB.getConnectionRO();
- conn = m_conn;
- }
- if (conn == null)
- throw new DBException("No Connection");
- p_stmt = conn.prepareCall(p_vo.getSql(), p_vo.getResultSetType(), p_vo.getResultSetConcurrency());
- return;
- }
- catch (Exception e)
- {
- log.log(Level.SEVERE, p_vo.getSql(), e);
- }
- }
- }
-
- /**
- * @param i
- * @return Array
- * @see java.sql.CallableStatement#getArray(int)
- */
- public Array getArray(int i) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getArray(i);
- }
- throw new java.lang.UnsupportedOperationException ("Method getArray() not yet implemented.");
- }
-
- /**
- * @param parameterName
- * @return Array
- * @see java.sql.CallableStatement#getArray(String)
- */
- public Array getArray(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getArray(parameterName);
- }
- throw new java.lang.UnsupportedOperationException ("Method getArray() not yet implemented.");
- }
-
- /**
- * @param parameterIndex
- * @return BigDecimal
- * @see java.sql.CallableStatement#getBigDecimal(int)
- */
- public BigDecimal getBigDecimal(int parameterIndex) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getBigDecimal(parameterIndex);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getOrdinalOutput().get(parameterIndex);
- }
- return o != null ? (BigDecimal)o.getValue() : null;
- }
-
- /**
- * @param parameterName
- * @return BigDecimal
- * @see java.sql.CallableStatement#getBigDecimal(String)
- */
- public BigDecimal getBigDecimal(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getBigDecimal(parameterName);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getNamedOutput().get(parameterName);
- }
- return o != null ? (BigDecimal)o.getValue() : null;
- }
-
- /**
- * @param parameterIndex
- * @param scale
- * @return BigDecimal
- * @see java.sql.CallableStatement#getBigDecimal(int, int)
- */
- public BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getBigDecimal(parameterIndex, scale);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getOrdinalOutput().get(parameterIndex);
- }
- return o != null ? (BigDecimal)o.getValue() : null;
- }
-
- /**
- * @param i
- * @return Blob
- * @see java.sql.CallableStatement#getBlob(int)
- */
- public Blob getBlob(int i) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getBlob(i);
- }
- throw new java.lang.UnsupportedOperationException ("Method getBlob() not yet implemented.");
- }
-
- /**
- * @param parameterName
- * @return Blob
- * @see java.sql.CallableStatement#getBlob(String)
- */
- public Blob getBlob(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getBlob(parameterName);
- }
- throw new java.lang.UnsupportedOperationException ("Method getBlob() not yet implemented.");
- }
-
- /**
- * @param parameterIndex
- * @return boolean
- * @see java.sql.CallableStatement#getBoolean(int)
- */
- public boolean getBoolean(int parameterIndex) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getBoolean(parameterIndex);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getOrdinalOutput().get(parameterIndex);
- }
- return o != null ? (Boolean)o.getValue() : null;
- }
-
- /**
- * @param parameterName
- * @return boolean
- * @see java.sql.CallableStatement#getBoolean(String)
- */
- public boolean getBoolean(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getBoolean(parameterName);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getNamedOutput().get(parameterName);
- }
- return o != null ? (Boolean)o.getValue() : null;
- }
-
- /**
- * @param parameterIndex
- * @see java.sql.CallableStatement#getByte(int)
- */
- public byte getByte(int parameterIndex) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getByte(parameterIndex);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getOrdinalOutput().get(parameterIndex);
- }
- return o != null ? (Byte)o.getValue() : null;
- }
-
- /**
- * @param parameterName
- * @return byte
- * @see java.sql.CallableStatement#getByte(String)
- */
- public byte getByte(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getByte(parameterName);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getNamedOutput().get(parameterName);
- }
- return o != null ? (Byte)o.getValue() : null;
- }
-
- /**
- * @param parameterIndex
- * @return byte[]
- * @see java.sql.CallableStatement#getBytes(int)
- */
- public byte[] getBytes(int parameterIndex) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getBytes(parameterIndex);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getOrdinalOutput().get(parameterIndex);
- }
- return o != null ? (byte[])o.getValue() : null;
- }
-
- /**
- * @param parameterName
- * @return byte[]
- * @see java.sql.CallableStatement#getBytes(String)
- */
- public byte[] getBytes(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getBytes(parameterName);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getNamedOutput().get(parameterName);
- }
- return o != null ? (byte[])o.getValue() : null;
- }
-
- /**
- * @param i
- * @return Clob
- * @see java.sql.CallableStatement#getClob(int)
- */
- public Clob getClob(int i) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getClob(i);
- }
- throw new java.lang.UnsupportedOperationException ("Method getClob() not yet implemented.");
- }
-
- /**
- * @param parameterName
- * @return @Clob
- * @see java.sql.CallableStatement#getClob(String)
- */
- public Clob getClob(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getClob(parameterName);
- }
- throw new java.lang.UnsupportedOperationException ("Method getClob() not yet implemented.");
- }
-
- /**
- * @param parameterIndex
- * @return Date
- * @see java.sql.CallableStatement#getDate(int)
- */
- public Date getDate(int parameterIndex) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getDate(parameterIndex);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getOrdinalOutput().get(parameterIndex);
- }
- return o != null ? (Date)o.getValue() : null;
- }
-
-
- public Date getDate(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getDate(parameterName);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getNamedOutput().get(parameterName);
- }
- return o != null ? (Date)o.getValue() : null;
- }
-
-
- public Date getDate(int parameterIndex, Calendar cal) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getDate(parameterIndex, cal);
- }
- throw new java.lang.UnsupportedOperationException ("Method getDate(parameterIndex, calendar) not yet implemented.");
- }
-
-
- public Date getDate(String parameterName, Calendar cal) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getDate(parameterName, cal);
- }
- throw new java.lang.UnsupportedOperationException ("Method getDate(parameterName, calendar) not yet implemented.");
- }
-
-
- public double getDouble(int parameterIndex) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getDouble(parameterIndex);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getOrdinalOutput().get(parameterIndex);
- }
- return o != null ? ((Number)o.getValue()).doubleValue() : 0;
- }
-
-
- public double getDouble(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getDouble(parameterName);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getNamedOutput().get(parameterName);
- }
- return o != null ? ((Number)o.getValue()).doubleValue() : 0;
- }
-
-
- public float getFloat(int parameterIndex) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getFloat(parameterIndex);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getOrdinalOutput().get(parameterIndex);
- }
- return o != null ? ((Number)o.getValue()).floatValue() : 0;
- }
-
-
- public float getFloat(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getFloat(parameterName);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getNamedOutput().get(parameterName);
- }
- return o != null ? ((Number)o.getValue()).floatValue() : 0;
- }
-
-
- public int getInt(int parameterIndex) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getInt(parameterIndex);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getOrdinalOutput().get(parameterIndex);
- }
- return o != null ? ((Number)o.getValue()).intValue() : 0;
- }
-
-
- public int getInt(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getInt(parameterName);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getNamedOutput().get(parameterName);
- }
- return o != null ? ((Number)o.getValue()).intValue() : 0;
- }
-
-
- public long getLong(int parameterIndex) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getLong(parameterIndex);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getOrdinalOutput().get(parameterIndex);
- }
- return o != null ? ((Number)o.getValue()).longValue() : 0;
- }
-
-
- public long getLong(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getLong(parameterName);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getNamedOutput().get(parameterName);
- }
- return o != null ? ((Number)o.getValue()).longValue() : 0;
- }
-
-
- public Object getObject(int parameterIndex) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getObject(parameterIndex);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getOrdinalOutput().get(parameterIndex);
- }
- return o != null ? o.getValue() : null;
- }
-
-
- public Object getObject(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getObject(parameterName);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getNamedOutput().get(parameterName);
- }
- return o != null ? o.getValue() : null;
- }
-
-
- public Object getObject(int i, Map> map) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getObject(i, map);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getOrdinalOutput().get(i);
- }
- return o != null ? o.getValue() : null;
- }
-
-
- public Object getObject(String parameterName, Map> map) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getObject(parameterName, map);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getNamedOutput().get(parameterName);
- }
- return o != null ? o.getValue() : null;
- }
-
-
- public Ref getRef(int i) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getRef(i);
- }
- throw new java.lang.UnsupportedOperationException ("Method getRef() not yet implemented.");
- }
-
-
- public Ref getRef(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getRef(parameterName);
- }
- throw new java.lang.UnsupportedOperationException ("Method getRef() not yet implemented.");
- }
-
-
- public short getShort(int parameterIndex) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getShort(parameterIndex);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getOrdinalOutput().get(parameterIndex);
- }
- return o != null ? ((Number)o.getValue()).shortValue() : 0;
- }
-
-
- public short getShort(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getShort(parameterName);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getNamedOutput().get(parameterName);
- }
- return o != null ? ((Number)o.getValue()).shortValue() : 0;
- }
-
-
- public String getString(int parameterIndex) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getString(parameterIndex);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getOrdinalOutput().get(parameterIndex);
- }
- return o != null ? (o.getValue() != null ? o.getValue().toString() : null) : null;
- }
-
-
- public String getString(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getString(parameterName);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getNamedOutput().get(parameterName);
- }
- return o != null ? (o.getValue() != null ? o.getValue().toString() : null) : null;
- }
-
-
- public Time getTime(int parameterIndex) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getTime(parameterIndex);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getOrdinalOutput().get(parameterIndex);
- }
- return o != null ? (Time)o.getValue() : null;
- }
-
-
- public Time getTime(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getTime(parameterName);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getNamedOutput().get(parameterName);
- }
- return o != null ? (Time)o.getValue() : null;
- }
-
-
- public Time getTime(int parameterIndex, Calendar cal) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getTime(parameterIndex, cal);
- }
- throw new java.lang.UnsupportedOperationException ("Method getTime() not yet implemented.");
- }
-
-
- public Time getTime(String parameterName, Calendar cal) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getTime(parameterName, cal);
- }
- throw new java.lang.UnsupportedOperationException ("Method getTime() not yet implemented.");
- }
-
-
- public Timestamp getTimestamp(int parameterIndex) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getTimestamp(parameterIndex);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getOrdinalOutput().get(parameterIndex);
- }
- return o != null ? (Timestamp)o.getValue() : null;
- }
-
-
- public Timestamp getTimestamp(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getTimestamp(parameterName);
- }
- OutputParameter o = null;
- if (executeResult != null)
- {
- CallableResult cr = (CallableResult)executeResult;
- o = cr.getNamedOutput().get(parameterName);
- }
- return o != null ? (Timestamp)o.getValue() : null;
- }
-
-
- public Timestamp getTimestamp(int parameterIndex, Calendar cal) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getTimestamp(parameterIndex, cal);
- }
- throw new java.lang.UnsupportedOperationException ("Method getTimestamp() not yet implemented.");
- }
-
-
- public Timestamp getTimestamp(String parameterName, Calendar cal) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getTimestamp(parameterName, cal);
- }
- throw new java.lang.UnsupportedOperationException ("Method getTimestamp() not yet implemented.");
- }
-
-
- public URL getURL(int parameterIndex) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getURL(parameterIndex);
- }
- throw new java.lang.UnsupportedOperationException ("Method getURL() not yet implemented.");
- }
-
-
- public URL getURL(String parameterName) throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getURL(parameterName);
- }
- throw new java.lang.UnsupportedOperationException ("Method getURL() not yet implemented.");
- }
-
-
- public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).registerOutParameter(parameterIndex, sqlType);
- }
- else
- {
- p_vo.registerOutParameter(parameterIndex, sqlType);
- }
- }
-
-
- public void registerOutParameter(String parameterName, int sqlType) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).registerOutParameter(parameterName, sqlType);
- }
- else
- {
- p_vo.registerOutParameter(parameterName, sqlType);
- }
-
- }
-
-
- public void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).registerOutParameter(parameterIndex, sqlType, scale);
- }
- else
- {
- p_vo.registerOutParameter(parameterIndex, sqlType, scale);
- }
- }
-
-
- public void registerOutParameter(int paramIndex, int sqlType, String typeName) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).registerOutParameter(paramIndex, sqlType, typeName);
- }
- else
- {
- p_vo.registerOutParameter(paramIndex, sqlType, typeName);
- }
- }
-
-
- public void registerOutParameter(String parameterName, int sqlType, int scale) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).registerOutParameter(parameterName, sqlType, scale);
- }
- else
- {
- p_vo.registerOutParameter(parameterName, sqlType, scale);
- }
- }
-
-
- public void registerOutParameter(String parameterName, int sqlType, String typeName) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).registerOutParameter(parameterName, sqlType, typeName);
- }
- else
- {
- p_vo.registerOutParameter(parameterName, sqlType, typeName);
- }
- }
-
- @Override
- protected boolean remote_execute() throws SQLException {
- // Client -> remote sever
- log.finest("server => " + p_vo + ", Remote=" + DB.isRemoteObjects());
- try
- {
- if (DB.isRemoteObjects() && CConnection.get().isAppsServerOK(false))
- {
- Server server = CConnection.get().getServer();
- if (server != null)
- {
- executeResult = server.callable_execute(p_vo, SecurityToken.getInstance());
- p_vo.clearParameters(); // re-use of result set
- return executeResult.isFirstResult();
- }
- log.log(Level.SEVERE, "AppsServer not found");
- }
- throw new IllegalStateException("Remote Connection - Application server not available");
- }
- 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);
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setAsciiStream(String, InputStream, int)
- */
- public void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setAsciiStream(parameterName, x, length);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method setAsciiStream() not yet implemented.");
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setBigDecimal(String, BigDecimal)
- */
- public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setBigDecimal(parameterName, x);
- }
- else
- {
- p_vo.setParameter(parameterName, x);
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setBinaryStream(String, InputStream, int)
- */
- public void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setBinaryStream(parameterName, x, length);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method setBinaryStream() not yet implemented.");
- }
-
- }
-
- /**
- * @see java.sql.CallableStatement#setBoolean(String, boolean)
- */
- public void setBoolean(String parameterName, boolean x) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setBoolean(parameterName, x);
- }
- else
- {
- p_vo.setParameter(parameterName, x);
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setByte(String, byte)
- */
- public void setByte(String parameterName, byte x) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setByte(parameterName, x);
- }
- else
- {
- p_vo.setParameter(parameterName, x);
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setBytes(String, byte[])
- */
- public void setBytes(String parameterName, byte[] x) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setBytes(parameterName, x);
- }
- else
- {
- p_vo.setParameter(parameterName, x);
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setCharacterStream(String, Reader, int)
- */
- public void setCharacterStream(String parameterName, Reader reader, int length) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setCharacterStream(parameterName, reader, length);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method setCharacterStream() not yet implemented.");
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setDate(String, Date)
- */
- public void setDate(String parameterName, Date x) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setDate(parameterName, x);
- }
- else
- {
- p_vo.setParameter(parameterName, x);
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setDate(String, Date, Calendar)
- */
- public void setDate(String parameterName, Date x, Calendar cal) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setDate(parameterName, x, cal);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method setDate() not yet implemented.");
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setDouble(String, double)
- */
- public void setDouble(String parameterName, double x) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setDouble(parameterName, x);
- }
- else
- {
- p_vo.setParameter(parameterName, x);
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setFloat(String, float)
- */
- public void setFloat(String parameterName, float x) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setFloat(parameterName, x);
- }
- else
- {
- p_vo.setParameter(parameterName, x);
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setLong(String, long)
- */
- public void setInt(String parameterName, int x) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setInt(parameterName, x);
- }
- else
- {
- p_vo.setParameter(parameterName, x);
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setLong(String, long)
- */
- public void setLong(String parameterName, long x) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setLong(parameterName, x);
- }
- else
- {
- p_vo.setParameter(parameterName, x);
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setNull(String, int)
- */
- public void setNull(String parameterName, int sqlType) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setNull(parameterName, sqlType);
- }
- else
- {
- p_vo.setParameter(parameterName, new NullParameter(sqlType));
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setNull(String, int, String)
- */
- public void setNull(String parameterName, int sqlType, String typeName) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setNull(parameterName, sqlType, typeName);
- }
- else
- {
- p_vo.setParameter(parameterName, new NullParameter(sqlType));
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setObject(String, Object)
- */
- public void setObject(String parameterName, Object x) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setObject(parameterName, x);
- }
- else
- {
- p_vo.setParameter(parameterName, x);
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setObject(String, Object, int)
- */
- public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setObject(parameterName, x, targetSqlType);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method setObject() not yet implemented.");
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setObject(String, Object, int, int)
- */
- public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setObject(parameterName, x, targetSqlType, scale);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method setObject() not yet implemented.");
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setShort(String, short)
- */
- public void setShort(String parameterName, short x) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setShort(parameterName, x);
- }
- else
- {
- p_vo.setParameter(parameterName, x);
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setString(String, String)
- */
- public void setString(String parameterName, String x) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setString(parameterName, x);
- }
- else
- {
- p_vo.setParameter(parameterName, x);
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setTime(String, Time)
- */
- public void setTime(String parameterName, Time x) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setTime(parameterName, x);
- }
- else
- {
- p_vo.setParameter(parameterName, x);
- }
- }
-
-
- /**
- * @see java.sql.CallableStatement#setTime(String, Time, Calendar)
- */
- public void setTime(String parameterName, Time x, Calendar cal) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setTime(parameterName, x, cal);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method setTime() not yet implemented.");
- }
- }
-
- /**
- * @see java.sql.CallableStatement#setTime(String, Time)
- */
- public void setTimestamp(String parameterName, Timestamp x) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setTimestamp(parameterName, x);
- }
- else
- {
- p_vo.setParameter(parameterName, x);
- }
- }
-
-
- public void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setTimestamp(parameterName, x, cal);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method setTimestamp() not yet implemented.");
- }
- }
-
-
- public void setURL(String parameterName, URL val) throws SQLException
- {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setURL(parameterName, val);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method setURL() not yet implemented.");
- }
- }
-
-
- public boolean wasNull() throws SQLException
- {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).wasNull();
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method wasNull() not yet implemented.");
- }
- }
-
- @Override
- public void fillParametersFromVO() {
- try
- {
- //ordinal input parameters
- ArrayList paramList = p_vo.getParameters();
- CallableStatement pstmt = (CallableStatement)p_stmt;
- for (int i = 0; i < paramList.size(); i++)
- {
- Object o = paramList.get(i);
- if (o == null)
- {
- throw new IllegalArgumentException ("Local - Null Parameter #" + i);
- }
- else if ( o instanceof OutputParameter)
- {
- OutputParameter op = (OutputParameter)o;
- if (op.getScale() != -1 )
- pstmt.registerOutParameter(i+1, op.getSqlType(), op.getScale());
- else if (op.getTypeName() != null)
- pstmt.registerOutParameter(i+1, op.getSqlType(), op.getTypeName());
- else
- pstmt.registerOutParameter(i+1, op.getSqlType());
- }
- else if (o instanceof NullParameter)
- {
- int type = ((NullParameter)o).getType();
- pstmt.setNull(i+1, type);
- log.finest("#" + (i+1) + " - Null");
- }
- else if (o instanceof Integer)
- {
- pstmt.setInt(i+1, ((Integer)o).intValue());
- log.finest("#" + (i+1) + " - int=" + o);
- }
- else if (o instanceof String)
- {
- pstmt.setString(i+1, (String)o);
- log.finest("#" + (i+1) + " - String=" + o);
- }
- else if (o instanceof Timestamp)
- {
- pstmt.setTimestamp(i+1, (Timestamp)o);
- log.finest("#" + (i+1) + " - Timestamp=" + o);
- }
- else if (o instanceof BigDecimal)
- {
- pstmt.setBigDecimal(i+1, (BigDecimal)o);
- log.finest("#" + (i+1) + " - BigDecimal=" + o);
- }
- else if (o instanceof java.sql.Date)
- {
- pstmt.setDate(i+1, (java.sql.Date)o);
- log.finest("#" + (i+1) + " - Date=" + o);
- }
- else if (o instanceof java.util.Date)
- {
- pstmt.setTimestamp(i+1, new Timestamp(((java.util.Date)o).getTime()));
- log.finest("#" + (i+1) + " - Date=" + o);
- }
- else if (o instanceof Double)
- {
- pstmt.setDouble(i+1, (Double)o);
- log.finest("#" + (i+1) + " - Double=" + o);
- }
- else if (o instanceof Float)
- {
- pstmt.setFloat(i+1, (Float)o);
- log.finest("#" + (i+1) + " - Double=" + o);
- }
- else
- throw new java.lang.UnsupportedOperationException ("Unknown Parameter Class=" + o.getClass());
- }
-
- //named input parameters
- Map parameters = p_vo.getNamedParameters();
- for (Map.Entry e : parameters.entrySet())
- {
- Object o = e.getValue();
- if (o == null)
- throw new IllegalArgumentException ("Local - Null Parameter for " + e.getKey());
- else if (o instanceof NullParameter)
- {
- int type = ((NullParameter)o).getType();
- pstmt.setNull(e.getKey(), type);
- log.finest("#" + e.getKey() + " - Null");
- }
- else if (o instanceof Integer)
- {
- pstmt.setInt(e.getKey(), ((Integer)o).intValue());
- log.finest("#" + e.getKey() + " - int=" + o);
- }
- else if (o instanceof String)
- {
- pstmt.setString(e.getKey(), (String)o);
- log.finest("#" + e.getKey() + " - String=" + o);
- }
- else if (o instanceof Timestamp)
- {
- pstmt.setTimestamp(e.getKey(), (Timestamp)o);
- log.finest("#" + e.getKey() + " - Timestamp=" + o);
- }
- else if (o instanceof BigDecimal)
- {
- pstmt.setBigDecimal(e.getKey(), (BigDecimal)o);
- log.finest("#" + e.getKey() + " - BigDecimal=" + o);
- }
- else if (o instanceof java.util.Date)
- {
- pstmt.setTimestamp(e.getKey(), new Timestamp(((java.util.Date)o).getTime()));
- log.finest("#" + e.getKey() + " - Date=" + o);
- }
- else if (o instanceof java.sql.Date)
- {
- pstmt.setTimestamp(e.getKey(), new Timestamp(((java.sql.Date)o).getTime()));
- log.finest("#" + e.getKey() + " - Date=" + o);
- }
- else
- throw new java.lang.UnsupportedOperationException ("Unknown Parameter Class=" + o.getClass());
- }
-
- //named output parameters
- Mapnamed = p_vo.getNamedOutput();
- for (Map.Entry e : named.entrySet())
- {
- String oi = e.getKey();
- OutputParameter op = e.getValue();
- if (op.getScale() != -1 )
- pstmt.registerOutParameter(oi, op.getSqlType(), op.getScale());
- else if (op.getTypeName() != null)
- pstmt.registerOutParameter(oi, op.getSqlType(), op.getTypeName());
- else
- pstmt.registerOutParameter(oi, op.getSqlType());
- }
- }
- catch (SQLException ex)
- {
- log.log(Level.SEVERE, "fillParametersFromVO", ex);
- }
- }
-
-
-
- /* Java 6 support - teo_sarca BF [ 1806700 ] */
- public Reader getCharacterStream(int parameterIndex) throws SQLException {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getCharacterStream(parameterIndex);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public Reader getCharacterStream(String parameterName) throws SQLException {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getCharacterStream(parameterName);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public Reader getNCharacterStream(int parameterIndex) throws SQLException {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getNCharacterStream(parameterIndex);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public Reader getNCharacterStream(String parameterName) throws SQLException {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getNCharacterStream(parameterName);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public java.sql.NClob getNClob(int parameterIndex) throws SQLException {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getNClob(parameterIndex);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public java.sql.NClob getNClob(String parameterName) throws SQLException {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getNClob(parameterName);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public String getNString(int parameterIndex) throws SQLException {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getNString(parameterIndex);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public String getNString(String parameterName) throws SQLException {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getNString(parameterName);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public java.sql.RowId getRowId(int parameterIndex) throws SQLException {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getRowId(parameterIndex);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public java.sql.RowId getRowId(String parameterName) throws SQLException {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getRowId(parameterName);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public java.sql.SQLXML getSQLXML(int parameterIndex) throws SQLException {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getSQLXML(parameterIndex);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public java.sql.SQLXML getSQLXML(String parameterName) throws SQLException {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).getSQLXML(parameterName);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setAsciiStream(String parameterName, InputStream x) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setAsciiStream(parameterName, x);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setAsciiStream(String parameterName, InputStream x, long length) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setAsciiStream(parameterName, x, length);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setBinaryStream(String parameterName, InputStream x) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setBinaryStream(parameterName, x);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setBinaryStream(String parameterName, InputStream x, long length) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setBinaryStream(parameterName, x, length);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setBlob(String parameterName, Blob x) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setBlob(parameterName, x);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setBlob(String parameterName, InputStream inputStream) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setBlob(parameterName, inputStream);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setBlob(String parameterName, InputStream inputStream, long length) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setBlob(parameterName, inputStream, length);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setCharacterStream(String parameterName, Reader reader) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setCharacterStream(parameterName, reader);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setCharacterStream(String parameterName, Reader reader, long length) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setCharacterStream(parameterName, reader, length);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setClob(String parameterName, Clob x) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setClob(parameterName, x);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setClob(String parameterName, Reader reader) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setClob(parameterName, reader);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setClob(String parameterName, Reader reader, long length) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setClob(parameterName, reader, length);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setNCharacterStream(String parameterName, Reader value) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setNCharacterStream(parameterName, value);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setNCharacterStream(String parameterName, Reader value, long length) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setNCharacterStream(parameterName, value, length);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setNClob(String parameterName, java.sql.NClob value) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setNClob(parameterName, value);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setNClob(String parameterName, Reader reader) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setNCharacterStream(parameterName, reader);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setNClob(String parameterName, Reader reader, long length) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setNClob(parameterName, reader, length);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setNString(String parameterName, String value) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setNString(parameterName, value);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setRowId(String parameterName, java.sql.RowId x) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setRowId(parameterName, x);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public void setSQLXML(String parameterName, java.sql.SQLXML xmlObject) throws SQLException {
- if (p_stmt != null)
- {
- ((CallableStatement)p_stmt).setSQLXML(parameterName, xmlObject);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
-
-
- public boolean isWrapperFor(Class iface) throws SQLException {
- if (p_stmt != null)
- {
- return ((CallableStatement)p_stmt).isWrapperFor(iface);
- }
- else
- {
- throw new java.lang.UnsupportedOperationException ("Method not yet implemented.");
- }
- }
- /* Java 6 support - teo_sarca BF [ 1806700 ] */
}
diff --git a/base/src/org/compiere/util/CLogMgt.java b/base/src/org/compiere/util/CLogMgt.java
index 04d00d5f34..f29b082b4f 100644
--- a/base/src/org/compiere/util/CLogMgt.java
+++ b/base/src/org/compiere/util/CLogMgt.java
@@ -591,18 +591,6 @@ public class CLogMgt
//
sb.append(")\n ");
//
- boolean remoteObjects = DB.isRemoteObjects();
- boolean remoteProcess = DB.isRemoteProcess();
- String realCP = CConnection.PROFILE_LAN;
- if (cc.isRMIoverHTTP())
- realCP = CConnection.PROFILE_WAN;
- else if (remoteObjects && remoteProcess)
- realCP = CConnection.PROFILE_VPN;
- sb.append(cc.getConnectionProfileText(realCP));
- sb.append(": Tunnel=").append(cc.isRMIoverHTTP())
- .append(", Objects=").append(remoteObjects)
- .append(", Process=").append(remoteProcess);
-
return sb.toString();
} // getServerInfo
diff --git a/base/src/org/compiere/util/CPreparedStatement.java b/base/src/org/compiere/util/CPreparedStatement.java
index 791585e87b..9bec9806df 100644
--- a/base/src/org/compiere/util/CPreparedStatement.java
+++ b/base/src/org/compiere/util/CPreparedStatement.java
@@ -16,972 +16,14 @@
*****************************************************************************/
package org.compiere.util;
-import java.io.*;
-import java.math.*;
-import java.net.*;
-import java.sql.*;
-import java.util.*;
-import java.util.logging.*;
-
-import javax.sql.*;
-
-import org.adempiere.exceptions.DBException;
-import org.compiere.db.*;
-import org.compiere.interfaces.*;
+import java.sql.PreparedStatement;
/**
- * Adempiere Prepared Statement
+ * Interface to wrap PreparedStatement
+ * @author Low Heng Sin
*
- * @author Jorg Janke
- * @version $Id: CPreparedStatement.java,v 1.3 2006/07/30 00:54:36 jjanke Exp $
- * ---
- * Modifications: Handle connections properly
- * Reason : Due to changes brought in the connection pooling whereby the system
- * no more relies upon abandoned connections.
- * @author Ashley Ramdass (Posterita)
*/
-public class CPreparedStatement extends CStatement implements PreparedStatement
+public interface CPreparedStatement extends CStatement, PreparedStatement
{
- /**
- * Prepared Statement Constructor
- *
- * @param resultSetType - ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.TYPE_SCROLL_SENSITIVE
- * @param resultSetConcurrency - ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
- * @param sql0 unconverted sql statement
- * @param trxName transaction name or null
- */
- public CPreparedStatement (int resultSetType, int resultSetConcurrency,
- String sql0, String trxName)
- {
- if (sql0 == null || sql0.length() == 0)
- throw new IllegalArgumentException ("sql required");
-
- p_vo = new CStatementVO (resultSetType, resultSetConcurrency,
- DB.getDatabase().convertStatement(sql0));
-
- p_vo.setTrxName(trxName);
-
- init();
- } // CPreparedStatement
-
- /**
- * Initialise the prepared statement wrapper object
- */
- protected void init()
- {
- //Local access
- if (!DB.isRemoteObjects())
- {
- try
- {
- Connection conn = null;
- Trx trx = p_vo.getTrxName() == null ? null : Trx.get(p_vo.getTrxName(), true);
- if (trx != null)
- {
- conn = trx.getConnection();
- }
- else
- {
- if (p_vo.getResultSetConcurrency() == ResultSet.CONCUR_UPDATABLE)
- m_conn = DB.getConnectionRW ();
- else
- m_conn = DB.getConnectionRO();
- conn = m_conn;
- }
- if (conn == null)
- throw new DBException("No Connection");
- p_stmt = conn.prepareStatement (p_vo.getSql(), p_vo.getResultSetType(), p_vo.getResultSetConcurrency());
- return;
- }
- catch (Exception e)
- {
- log.log(Level.SEVERE, p_vo.getSql(), e);
- }
- }
- }
-
- /**
- * Remote Constructor
- * @param vo value object
- */
- public CPreparedStatement (CStatementVO vo)
- {
- super(vo);
- } // CPreparedStatement
-
-
- /**
- * Execute Query
- * @return ResultSet or RowSet
- * @throws SQLException
- * @see java.sql.PreparedStatement#executeQuery()
- */
- public ResultSet executeQuery () throws SQLException
- {
- if (p_stmt != null) // local
- return ((PreparedStatement)p_stmt).executeQuery();
- //
- // Client -> remote sever
- log.finest("server => " + p_vo + ", Remote=" + DB.isRemoteObjects());
- try
- {
- boolean remote = DB.isRemoteObjects() && CConnection.get().isAppsServerOK(false);
- if (remote && p_remoteErrors > 1)
- remote = CConnection.get().isAppsServerOK(true);
- if (remote)
- {
- Server server = CConnection.get().getServer();
- if (server != null)
- {
- ResultSet rs = server.pstmt_getRowSet (p_vo, SecurityToken.getInstance());
- p_vo.clearParameters(); // re-use of result set
- if (rs == null)
- log.warning("ResultSet is null - " + p_vo);
- else
- p_remoteErrors = 0;
- return rs;
- }
- log.log(Level.SEVERE, "AppsServer not found");
- p_remoteErrors++;
- }
- }
- 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);
- }
- throw new IllegalStateException("Remote Connection - Application server not available");
- } // executeQuery
-
- /**
- * Execute Query
- * @param sql0 unconverted SQL to execute
- * @return ResultSet or RowSet
- * @throws SQLException
- * @see java.sql.Statement#executeQuery(String)
- */
- public ResultSet executeQuery (String sql0) throws SQLException
- {
- // Convert SQL
- p_vo.setSql(DB.getDatabase().convertStatement(sql0));
- if (p_stmt != null) // local
- return p_stmt.executeQuery(p_vo.getSql());
- //
- return executeQuery();
- } // executeQuery
-
-
- /**************************************************************************
- * Execute Update
- * @return no of updated rows
- * @throws SQLException
- * @see java.sql.PreparedStatement#executeUpdate()
- */
- public int executeUpdate () throws SQLException
- {
- if (p_stmt != null)
- return ((PreparedStatement)p_stmt).executeUpdate();
- //
- // Client -> remote sever
- log.finest("server => " + p_vo + ", Remote=" + DB.isRemoteObjects());
- try
- {
- if (DB.isRemoteObjects() && CConnection.get().isAppsServerOK(false))
- {
- Server server = CConnection.get().getServer();
- if (server != null)
- {
- int result = server.stmt_executeUpdate (p_vo, SecurityToken.getInstance());
- p_vo.clearParameters(); // re-use of result set
- return result;
- }
- log.log(Level.SEVERE, "AppsServer not found");
- }
- }
- 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);
- }
- throw new IllegalStateException("Remote Connection - Application server not available");
- } // executeUpdate
-
- /**
- * Execute Update
- * @param sql0 unconverted sql
- * @return no of updated rows
- * @throws SQLException
- * @see java.sql.Statement#executeUpdate(String)
- */
- public int executeUpdate (String sql0) throws SQLException
- {
- // Convert SQL
- p_vo.setSql(DB.getDatabase().convertStatement(sql0));
- if (p_stmt != null) // local
- return p_stmt.executeUpdate (p_vo.getSql());
- return executeUpdate();
- } // executeUpdate
-
-
- /**
- * Method execute
- * @return boolean
- * @throws SQLException
- * @see java.sql.PreparedStatement#execute()
- */
- public boolean execute () throws SQLException
- {
- if (p_stmt != null)
- return ((PreparedStatement)p_stmt).execute();
-
- return remote_execute();
- }
-
-
- /**
- * Method getMetaData
- * @return ResultSetMetaData
- * @throws SQLException
- * @see java.sql.PreparedStatement#getMetaData()
- */
- public ResultSetMetaData getMetaData () throws SQLException
- {
- if (p_stmt != null)
- return ((PreparedStatement)p_stmt).getMetaData ();
- else
- throw new java.lang.UnsupportedOperationException ("Method getMetaData() not yet implemented.");
- }
-
- /**
- * Method getParameterMetaData
- * @return ParameterMetaData
- * @throws SQLException
- * @see java.sql.PreparedStatement#getParameterMetaData()
- */
- public ParameterMetaData getParameterMetaData () throws SQLException
- {
- if (p_stmt != null)
- return ((PreparedStatement)p_stmt).getParameterMetaData();
- throw new java.lang.UnsupportedOperationException ("Method getParameterMetaData() not yet implemented.");
- }
-
- /**
- * Method addBatch
- * @throws SQLException
- * @see java.sql.PreparedStatement#addBatch()
- */
- public void addBatch () throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).addBatch ();
- else
- throw new java.lang.UnsupportedOperationException ("Method addBatch() not yet implemented.");
- }
-
- /**************************************************************************
- * Set Null
- * @param parameterIndex index
- * @param sqlType type
- * @throws SQLException
- */
- public void setNull (int parameterIndex, int sqlType) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setNull (parameterIndex, sqlType);
- else
- p_vo.setParameter(parameterIndex, new NullParameter(sqlType));
- } // setNull
-
- /**
- * Method setNull
- * @param parameterIndex int
- * @param sqlType int
- * @param typeName String
- * @throws SQLException
- * @see java.sql.PreparedStatement#setNull(int, int, String)
- */
- public void setNull (int parameterIndex, int sqlType, String typeName) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setNull (parameterIndex, sqlType);
- else
- p_vo.setParameter(parameterIndex, new NullParameter(sqlType));
- }
-
- /**
- * Method setBoolean
- * @param parameterIndex int
- * @param x boolean
- * @throws SQLException
- * @see java.sql.PreparedStatement#setBoolean(int, boolean)
- */
- public void setBoolean (int parameterIndex, boolean x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setBoolean (parameterIndex, x);
- else
- p_vo.setParameter(parameterIndex, new Boolean(x));
- }
-
- /**
- * Method setByte
- * @param parameterIndex int
- * @param x byte
- * @throws SQLException
- * @see java.sql.PreparedStatement#setByte(int, byte)
- */
- public void setByte (int parameterIndex, byte x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setByte (parameterIndex, x);
- else
- p_vo.setParameter(parameterIndex, new Byte(x));
- }
-
- /**
- * Method setShort
- * @param parameterIndex int
- * @param x short
- * @throws SQLException
- * @see java.sql.PreparedStatement#setShort(int, short)
- */
- public void setShort (int parameterIndex, short x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setShort (parameterIndex, x);
- else
- p_vo.setParameter(parameterIndex, new Short(x));
- }
-
- /**
- * Method setInt
- * @param parameterIndex int
- * @param x int
- * @throws SQLException
- * @see java.sql.PreparedStatement#setInt(int, int)
- */
- public void setInt (int parameterIndex, int x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setInt (parameterIndex, x);
- else
- p_vo.setParameter(parameterIndex, new Integer(x));
- }
-
- /**
- * Method setLong
- * @param parameterIndex int
- * @param x long
- * @throws SQLException
- * @see java.sql.PreparedStatement#setLong(int, long)
- */
- public void setLong (int parameterIndex, long x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setLong (parameterIndex, x);
- else
- p_vo.setParameter(parameterIndex, new Long(x));
- }
-
- /**
- * Method setFloat
- * @param parameterIndex int
- * @param x float
- * @throws SQLException
- * @see java.sql.PreparedStatement#setFloat(int, float)
- */
- public void setFloat (int parameterIndex, float x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setFloat (parameterIndex, x);
- else
- p_vo.setParameter(parameterIndex, new Float(x));
- }
-
- /**
- * Method setDouble
- * @param parameterIndex int
- * @param x double
- * @throws SQLException
- * @see java.sql.PreparedStatement#setDouble(int, double)
- */
- public void setDouble (int parameterIndex, double x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setDouble (parameterIndex, x);
- else
- p_vo.setParameter(parameterIndex, new Double(x));
- }
-
- /**
- * Method setBigDecimal
- * @param parameterIndex int
- * @param x BigDecimal
- * @throws SQLException
- * @see java.sql.PreparedStatement#setBigDecimal(int, BigDecimal)
- */
- public void setBigDecimal (int parameterIndex, BigDecimal x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setBigDecimal (parameterIndex, x);
- else
- p_vo.setParameter(parameterIndex, x);
- }
-
- /**
- * Method setString
- * @param parameterIndex int
- * @param x String
- * @throws SQLException
- * @see java.sql.PreparedStatement#setString(int, String)
- */
- public void setString (int parameterIndex, String x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setString (parameterIndex, x);
- else
- p_vo.setParameter(parameterIndex, x);
- }
-
- /**
- * Method setBytes
- * @param parameterIndex int
- * @param x byte[]
- * @throws SQLException
- * @see java.sql.PreparedStatement#setBytes(int, byte[])
- */
- public void setBytes (int parameterIndex, byte[] x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setBytes (parameterIndex, x);
- else
- p_vo.setParameter (parameterIndex, x);
- }
-
- /**
- * Method setDate
- * @param parameterIndex int
- * @param x java.sql.Date
- * @throws SQLException
- * @see java.sql.PreparedStatement#setDate(int, java.sql.Date)
- */
- public void setDate (int parameterIndex, java.sql.Date x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setDate (parameterIndex, x);
- else
- p_vo.setParameter(parameterIndex, x);
- }
-
- /**
- * Method setTime
- * @param parameterIndex int
- * @param x Time
- * @throws SQLException
- * @see java.sql.PreparedStatement#setTime(int, Time)
- */
- public void setTime (int parameterIndex, Time x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setTime (parameterIndex, x);
- else
- p_vo.setParameter(parameterIndex, x);
- }
-
- /**
- * Method setTimestamp
- * @param parameterIndex int
- * @param x Timestamp
- * @throws SQLException
- * @see java.sql.PreparedStatement#setTimestamp(int, Timestamp)
- */
- public void setTimestamp (int parameterIndex, Timestamp x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setTimestamp (parameterIndex, x);
- else
- p_vo.setParameter(parameterIndex, x);
- }
-
- /**
- * Method setAsciiStream
- * @param parameterIndex int
- * @param x InputStream
- * @param length int
- * @throws SQLException
- * @see java.sql.PreparedStatement#setAsciiStream(int, InputStream, int)
- */
- public void setAsciiStream (int parameterIndex, InputStream x, int length) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setAsciiStream (parameterIndex, x, length);
- else
- throw new java.lang.UnsupportedOperationException ("Method setAsciiStream() not yet implemented.");
- }
-
- /**
- * @param parameterIndex the first parameter is 1, the second is 2, ...
- * @param x a java.io.InputStream
object that contains the
- * Unicode parameter value as two-byte Unicode characters
- * @param length the number of bytes in the stream
- * @exception SQLException if a database access error occurs
- * see java.sql.PreparedStatement#setUnicodeStream(int, InputStream, int)
- * @deprecated
- */
- public void setUnicodeStream (int parameterIndex, InputStream x, int length) throws SQLException
- {
- throw new UnsupportedOperationException ("Method setUnicodeStream() not yet implemented.");
- }
-
- /**
- * Method setBinaryStream
- * @param parameterIndex int
- * @param x InputStream
- * @param length int
- * @throws SQLException
- * @see java.sql.PreparedStatement#setBinaryStream(int, InputStream, int)
- */
- public void setBinaryStream (int parameterIndex, InputStream x, int length) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setBinaryStream (parameterIndex, x, length);
- else
- throw new java.lang.UnsupportedOperationException ("Method setBinaryStream() not yet implemented.");
- }
-
- /**
- * Method clearParameters
- * @throws SQLException
- * @see java.sql.PreparedStatement#clearParameters()
- */
- public void clearParameters () throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).clearParameters ();
- else
- p_vo.clearParameters();
- }
-
- /**
- * Method setObject
- * @param parameterIndex int
- * @param x Object
- * @param targetSqlType int
- * @param scale int
- * @throws SQLException
- * @see java.sql.PreparedStatement#setObject(int, Object, int, int)
- */
- public void setObject (int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setObject (parameterIndex, x, targetSqlType, scale);
- else
- throw new java.lang.UnsupportedOperationException ("Method setObject() not yet implemented.");
- }
-
- /**
- * Method setObject
- * @param parameterIndex int
- * @param x Object
- * @param targetSqlType int
- * @throws SQLException
- * @see java.sql.PreparedStatement#setObject(int, Object, int)
- */
- public void setObject (int parameterIndex, Object x, int targetSqlType) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setObject (parameterIndex, x);
- else
- throw new java.lang.UnsupportedOperationException ("Method setObject() not yet implemented.");
- }
-
- /**
- * Method setObject
- * @param parameterIndex int
- * @param x Object
- * @throws SQLException
- * @see java.sql.PreparedStatement#setObject(int, Object)
- */
- public void setObject (int parameterIndex, Object x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setObject (parameterIndex, x);
- else
- p_vo.setParameter(parameterIndex, x);
- }
-
- /**
- * Method setCharacterStream
- * @param parameterIndex int
- * @param reader Reader
- * @param length int
- * @throws SQLException
- * @see java.sql.PreparedStatement#setCharacterStream(int, Reader, int)
- */
- public void setCharacterStream (int parameterIndex, Reader reader, int length) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setCharacterStream (parameterIndex, reader, length);
- else
- throw new java.lang.UnsupportedOperationException ("Method setCharacterStream() not yet implemented.");
- }
-
- /**
- * Method setRef
- * @param parameterIndex int
- * @param x Ref
- * @throws SQLException
- * @see java.sql.PreparedStatement#setRef(int, Ref)
- */
- public void setRef (int parameterIndex, Ref x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setRef (parameterIndex, x);
- else
- p_vo.setParameter(parameterIndex, x);
- }
-
- /**
- * Method setBlob
- * @param parameterIndex int
- * @param x Blob
- * @throws SQLException
- * @see java.sql.PreparedStatement#setBlob(int, Blob)
- */
- public void setBlob (int parameterIndex, Blob x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setObject (parameterIndex, x);
- else
- p_vo.setParameter(parameterIndex, x);
- }
-
- /**
- * Method setClob
- * @param parameterIndex int
- * @param x Clob
- * @throws SQLException
- * @see java.sql.PreparedStatement#setClob(int, Clob)
- */
- public void setClob (int parameterIndex, Clob x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setObject (parameterIndex, x);
- else
- p_vo.setParameter(parameterIndex, x);
- }
-
- /**
- * Method setArray
- * @param parameterIndex int
- * @param x Array
- * @throws SQLException
- * @see java.sql.PreparedStatement#setArray(int, Array)
- */
- public void setArray (int parameterIndex, Array x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setObject (parameterIndex, x);
- else
- p_vo.setParameter(parameterIndex, x);
- }
-
- /**
- * Method setDate
- * @param parameterIndex int
- * @param x java.sql.Date
- * @param cal Calendar
- * @throws SQLException
- * @see java.sql.PreparedStatement#setDate(int, java.sql.Date, Calendar)
- */
- public void setDate (int parameterIndex, java.sql.Date x, Calendar cal) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setDate (parameterIndex, x, cal);
- else
- throw new java.lang.UnsupportedOperationException ("Method setDate() not yet implemented.");
- }
-
- /**
- * Method setTime
- * @param parameterIndex int
- * @param x Time
- * @param cal Calendar
- * @throws SQLException
- * @see java.sql.PreparedStatement#setTime(int, Time, Calendar)
- */
- public void setTime (int parameterIndex, Time x, Calendar cal) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setTime (parameterIndex, x, cal);
- else
- throw new java.lang.UnsupportedOperationException ("Method setTime() not yet implemented.");
- }
-
- /**
- * Method setTimestamp
- * @param parameterIndex int
- * @param x Timestamp
- * @param cal Calendar
- * @throws SQLException
- * @see java.sql.PreparedStatement#setTimestamp(int, Timestamp, Calendar)
- */
- public void setTimestamp (int parameterIndex, Timestamp x, Calendar cal) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setTimestamp (parameterIndex, x, cal);
- else
- throw new java.lang.UnsupportedOperationException ("Method setTimestamp() not yet implemented.");
- }
-
- /**
- * Method setURL
- * @param parameterIndex int
- * @param x URL
- * @throws SQLException
- * @see java.sql.PreparedStatement#setURL(int, URL)
- */
- public void setURL (int parameterIndex, URL x) throws SQLException
- {
- if (p_stmt != null)
- ((PreparedStatement)p_stmt).setObject (parameterIndex, x);
- else
- p_vo.setParameter(parameterIndex, x);
- }
-
- /**
- * String representation
- * @return info
- */
- public String toString()
- {
- if (p_stmt != null)
- return "CPreparedStatement[Local=" + p_stmt + "]";
- return "CPreparedStatement[" + p_vo + "]";
- } // toString
-
- /**
- *
- */
- public void fillParametersFromVO()
- {
- log.finest(p_vo.getSql());
- try
- {
- // Set Parameters
- ArrayList parameters = p_vo.getParameters();
- PreparedStatement pstmt = (PreparedStatement)p_stmt;
- for (int i = 0; i < parameters.size(); i++)
- {
- Object o = parameters.get(i);
- if (o == null)
- throw new IllegalArgumentException ("Local - Null Parameter #" + i);
- else if (o instanceof NullParameter)
- {
- int type = ((NullParameter)o).getType();
- pstmt.setNull(i+1, type);
- log.finest("#" + (i+1) + " - Null");
- }
- else if (o instanceof Integer)
- {
- pstmt.setInt(i+1, ((Integer)o).intValue());
- log.finest("#" + (i+1) + " - int=" + o);
- }
- else if (o instanceof String)
- {
- pstmt.setString(i+1, (String)o);
- log.finest("#" + (i+1) + " - String=" + o);
- }
- else if (o instanceof Timestamp)
- {
- pstmt.setTimestamp(i+1, (Timestamp)o);
- log.finest("#" + (i+1) + " - Timestamp=" + o);
- }
- else if (o instanceof BigDecimal)
- {
- pstmt.setBigDecimal(i+1, (BigDecimal)o);
- log.finest("#" + (i+1) + " - BigDecimal=" + o);
- }
- else if (o instanceof java.sql.Date)
- {
- pstmt.setDate(i+1, (java.sql.Date)o);
- log.finest("#" + (i+1) + " - Date=" + o);
- }
- else if (o instanceof java.util.Date)
- {
- pstmt.setTimestamp(i+1, new Timestamp(((java.util.Date)o).getTime()));
- log.finest("#" + (i+1) + " - Date=" + o);
- }
- else if (o instanceof Double)
- {
- pstmt.setDouble(i+1, (Double)o);
- log.finest("#" + (i+1) + " - Double=" + o);
- }
- else if (o instanceof Float)
- {
- pstmt.setFloat(i+1, (Float)o);
- log.finest("#" + (i+1) + " - Double=" + o);
- }
- else
- throw new java.lang.UnsupportedOperationException ("Unknown Parameter Class=" + o.getClass());
- }
- }
- catch (SQLException ex)
- {
- log.log(Level.SEVERE, "fillParametersFromVO", ex);
- }
- } // local_getPreparedStatement
-
- /**
- * Get Result as RowSet for local system.
- * Note that connection is closed when closing Oracle CachedRowSet!
- * @return result as RowSet
- **/
- @Override
- protected RowSet local_getRowSet()
- {
- log.finest("local_getRowSet");
-
- RowSet rowSet = null;
- ResultSet rs = null;
- PreparedStatement pstmt = (PreparedStatement)p_stmt;
- try
- {
- fillParametersFromVO();
- //
- rs = pstmt.executeQuery();
- rowSet = CCachedRowSet.getRowSet(rs);
- }
- catch (Exception ex)
- {
- log.log(Level.SEVERE, p_vo.toString(), ex);
- throw new RuntimeException (ex);
- }
- finally
- {
- DB.close(rs);
- }
- return rowSet;
- } // local_getRowSet
-
-
- public void setAsciiStream(int parameterIndex, java.io.InputStream x, long length)
- throws SQLException
- {
-
- }
-
- //uncomment the following methods to compile using jdk 6
- //vpj-cd add support java 6
-
- public void setBinaryStream(int parameterIndex, java.io.InputStream x,
- long length) throws SQLException
- {
-
- }
-
- public void setCharacterStream(int parameterIndex,
- java.io.Reader reader,
- long length) throws SQLException
- {
-
- }
-
- public void setAsciiStream(int parameterIndex, java.io.InputStream x)
- throws SQLException
- {
-
- }
-
-
- public void setBinaryStream(int parameterIndex, java.io.InputStream x)
- throws SQLException
- {
-
- }
-
- public void setCharacterStream(int parameterIndex,
- java.io.Reader reader) throws SQLException
- {
-
- }
-
- public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException
- {
-
- }
-
- public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException
- {
-
- }
-
- public void setClob(int parameterIndex, Reader reader)
- throws SQLException
- {
-
- }
-
- public void setClob(int parameterIndex, Reader reader, long length)
- throws SQLException
- {
-
- }
-
- public void setNClob(int parameterIndex, Reader reader, long length)
- throws SQLException
- {
-
- }
-
- public void setNClob(int parameterIndex, Reader reader)
- throws SQLException
- {
-
- }
-
- public void setNClob(int i,java.sql.NClob c)
- throws SQLException
- {
-
- }
-
- public void setBlob(int parameterIndex, InputStream inputStream, long length)
- throws SQLException
- {
-
- }
-
-
- public void setBlob(int parameterIndex, InputStream inputStream)
- throws SQLException
- {
-
- }
-
- public void setNString(int parameterIndex, String value) throws SQLException
- {
-
- }
-
- public void setSQLXML(int parameterIndex, java.sql.SQLXML xmlObject) throws SQLException
- {
-
- }
-
- public void setRowId(int parameterIndex, java.sql.RowId x) throws SQLException{}
-
-
} // CPreparedStatement
diff --git a/base/src/org/compiere/util/CStatement.java b/base/src/org/compiere/util/CStatement.java
index e10db4ec2a..32c261e61e 100644
--- a/base/src/org/compiere/util/CStatement.java
+++ b/base/src/org/compiere/util/CStatement.java
@@ -17,878 +17,46 @@
package org.compiere.util;
import java.sql.*;
-import java.util.logging.*;
import javax.sql.*;
-import org.adempiere.exceptions.DBException;
-import org.compiere.db.*;
-import org.compiere.interfaces.*;
-
/**
- * Adempiere Statement
- *
- * @author Jorg Janke
- * @version $Id: CStatement.java,v 1.3 2006/07/30 00:54:36 jjanke Exp $
- * ---
- * Modifications: Handle connections properly
- * Close the associated connection when the statement is closed
- * Reason : Due to changes brought in the connection pooling whereby the system
- * no more relies upon abandoned connections.
- * @author Ashley Ramdass (Posterita)
+ * Interface to wrap and extend Statement
+ * @author Low Heng Sin
+ *
*/
-public class CStatement implements Statement
+public interface CStatement extends Statement
{
- protected Connection m_conn = null;
-
- private boolean close = false;
-
-
- /**
- * Prepared Statement Constructor
- *
- * @param resultSetType - ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.TYPE_SCROLL_SENSITIVE
- * @param resultSetConcurrency - ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
- * @param trxName transaction name or null
- */
- public CStatement (int resultSetType, int resultSetConcurrency,
- String trxName)
- {
- p_vo = new CStatementVO (resultSetType, resultSetConcurrency);
- p_vo.setTrxName(trxName);
-
- init();
- } // CPreparedStatement
-
- /**
- * Initialise the statement wrapper object
- */
- protected void init()
- {
- //Local access
- if (!DB.isRemoteObjects())
- {
- try
- {
- Connection conn = null;
- Trx trx = p_vo.getTrxName() == null ? null : Trx.get(p_vo.getTrxName(), true);
- if (trx != null)
- {
- conn = trx.getConnection();
- }
- else
- {
- if (p_vo.getResultSetConcurrency() == ResultSet.CONCUR_UPDATABLE)
- m_conn = DB.getConnectionRW ();
- else
- m_conn = DB.getConnectionRO();
- conn = m_conn;
- }
- if (conn == null)
- throw new DBException("No Connection");
- p_stmt = conn.createStatement(p_vo.getResultSetType(), p_vo.getResultSetConcurrency());
- return;
- }
- catch (SQLException e)
- {
- log.log(Level.SEVERE, "CStatement", e);
- }
- }
- }
-
- /**
- * Minimum Constructor for sub classes
- */
- protected CStatement()
- {
- super();
- } // CStatement
-
- /**
- * Remote Constructor
- * @param vo value object
- */
- public CStatement (CStatementVO vo)
- {
- p_vo = vo;
- init();
- } // CPreparedStatement
-
-
- /** Logger */
- protected transient CLogger log = CLogger.getCLogger (getClass());
- /** Used if local */
- protected transient Statement p_stmt = null;
- /** Value Object */
- protected CStatementVO p_vo = null;
- /** Remote Errors */
- protected int p_remoteErrors = 0;
- /** Object to hold remote execute result **/
- protected ExecuteResult executeResult;
-
-
- /**
- * Execute Query
- * @param sql0 unconverted SQL to execute
- * @return ResultSet or RowSet
- * @throws SQLException
- * @see java.sql.Statement#executeQuery(String)
- */
- public ResultSet executeQuery (String sql0) throws SQLException
- {
- // Convert SQL
- p_vo.setSql(DB.getDatabase().convertStatement(sql0));
- if (p_stmt != null) // local
- return p_stmt.executeQuery(p_vo.getSql());
-
- // Client -> remote sever
- log.finest("server => " + p_vo + ", Remote=" + DB.isRemoteObjects());
- try
- {
- boolean remote = DB.isRemoteObjects() && CConnection.get().isAppsServerOK(false);
- if (remote && p_remoteErrors > 1)
- remote = CConnection.get().isAppsServerOK(true);
- if (remote)
- {
- Server server = CConnection.get().getServer();
- if (server != null)
- {
- ResultSet rs = server.stmt_getRowSet (p_vo, SecurityToken.getInstance());
- if (rs == null)
- log.warning("ResultSet is null - " + p_vo);
- else
- p_remoteErrors = 0;
- return rs;
- }
- log.log(Level.SEVERE, "AppsServer not found");
- p_remoteErrors++;
- }
- }
- 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);
- }
- throw new IllegalStateException("Remote Connection - Application server not available");
- } // executeQuery
-
-
- /**
- * Execute Update
- * @param sql0 unconverted sql
- * @return no of updated rows
- * @throws SQLException
- * @see java.sql.Statement#executeUpdate(String)
- */
- public int executeUpdate (String sql0) throws SQLException
- {
- // Convert SQL
- p_vo.setSql(DB.getDatabase().convertStatement(sql0));
- if (p_stmt != null) // local
- return p_stmt.executeUpdate (p_vo.getSql());
-
- // Client -> remote sever
- log.finest("server => " + p_vo + ", Remote=" + DB.isRemoteObjects());
- try
- {
- boolean remote = DB.isRemoteObjects() && CConnection.get().isAppsServerOK(false);
- if (remote && p_remoteErrors > 1)
- remote = CConnection.get().isAppsServerOK(true);
- if (remote)
- {
- Server server = CConnection.get().getServer();
- if (server != null)
- {
- int result = server.stmt_executeUpdate(p_vo, SecurityToken.getInstance());
- p_vo.clearParameters(); // re-use of result set
- return result;
- }
- log.log(Level.SEVERE, "AppsServer not found");
- p_remoteErrors++;
- }
- }
- 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);
- }
- throw new IllegalStateException("Remote Connection - Application server not available");
- } // executeUpdate
-
/**
* Get Sql
* @return sql
*/
- public String getSql()
- {
- if (p_vo != null)
- return p_vo.getSql();
- return null;
- } // getSql
+ public String getSql();
- /**
- * Get Connection
- * @return connection for local - or null for remote
- * @throws SQLException
- * @see java.sql.Statement#getConnection()
- */
- public Connection getConnection () throws SQLException
- {
- if (p_stmt != null)
- return p_stmt.getConnection();
- return null;
- } // getConnection
-
- /**
- * Commit (if local)
- * @throws SQLException
- */
- public void commit() throws SQLException
- {
- Connection conn = getConnection();
- if (conn != null && !conn.getAutoCommit())
- {
- conn.commit();
- log.fine("commit");
- }
- } // commit
-
-
- /**
- * Method executeUpdate
- * @param sql0 String
- * @param autoGeneratedKeys int
- * @return int
- * @throws SQLException
- * @see java.sql.Statement#executeUpdate(String, int)
- */
- public int executeUpdate (String sql0, int autoGeneratedKeys) throws SQLException
- {
- p_vo.setSql(DB.getDatabase().convertStatement(sql0));
- if (p_stmt != null)
- return p_stmt.executeUpdate(p_vo.getSql(), autoGeneratedKeys);
- throw new java.lang.UnsupportedOperationException ("Method executeUpdate() not yet implemented.");
- }
-
- /**
- * Method executeUpdate
- * @param sql0 String
- * @param columnIndexes int[]
- * @return int
- * @throws SQLException
- * @see java.sql.Statement#executeUpdate(String, int[])
- */
- public int executeUpdate (String sql0, int[] columnIndexes) throws SQLException
- {
- p_vo.setSql(DB.getDatabase().convertStatement(sql0));
- if (p_stmt != null)
- return p_stmt.executeUpdate(p_vo.getSql(), columnIndexes);
- throw new java.lang.UnsupportedOperationException ("Method executeUpdate() not yet implemented.");
- }
-
- /**
- * Method executeUpdate
- * @param sql0 String
- * @param columnNames String[]
- * @return int
- * @throws SQLException
- * @see java.sql.Statement#executeUpdate(String, String[])
- */
- public int executeUpdate (String sql0, String[] columnNames) throws SQLException
- {
- p_vo.setSql(DB.getDatabase().convertStatement(sql0));
- if (p_stmt != null)
- return p_stmt.executeUpdate(p_vo.getSql(), columnNames);
- throw new java.lang.UnsupportedOperationException ("Method executeUpdate() not yet implemented.");
- }
-
-
- /**
- * Method execute
- * @param sql0 String
- * @return boolean
- * @throws SQLException
- * @see java.sql.Statement#execute(String)
- */
- public boolean execute (String sql0) throws SQLException
- {
- p_vo.setSql(DB.getDatabase().convertStatement(sql0));
- if (p_stmt != null)
- return p_stmt.execute(p_vo.getSql());
-
- return remote_execute();
- }
-
- /**
- * Method execute
- * @param sql0 String
- * @param autoGeneratedKeys int
- * @return boolean
- * @throws SQLException
- * @see java.sql.Statement#execute(String, int)
- */
- public boolean execute (String sql0, int autoGeneratedKeys) throws SQLException
- {
- p_vo.setSql(DB.getDatabase().convertStatement(sql0));
- if (p_stmt != null)
- return p_stmt.execute(p_vo.getSql(), autoGeneratedKeys);
-
- throw new java.lang.UnsupportedOperationException ("Method execute(sql, autoGeneratedKeys) not yet implemented.");
- }
-
- /**
- * Method execute
- * @param sql0 String
- * @param columnIndexes int[]
- * @return boolean
- * @throws SQLException
- * @see java.sql.Statement#execute(String, int[])
- */
- public boolean execute (String sql0, int[] columnIndexes) throws SQLException
- {
- p_vo.setSql(DB.getDatabase().convertStatement(sql0));
- if (p_stmt != null)
- return p_stmt.execute(p_vo.getSql(), columnIndexes);
- throw new java.lang.UnsupportedOperationException ("Method execute(sql, columnIndexes) not yet implemented.");
- }
-
- /**
- * Method execute
- * @param sql0 String
- * @param columnNames String[]
- * @return boolean
- * @throws SQLException
- * @see java.sql.Statement#execute(String, String[])
- */
- public boolean execute (String sql0, String[] columnNames) throws SQLException
- {
- p_vo.setSql(DB.getDatabase().convertStatement(sql0));
- if (p_stmt != null)
- return p_stmt.execute(p_vo.getSql(), columnNames);
- throw new java.lang.UnsupportedOperationException ("Method execute(sql, columnNames) not yet implemented.");
- }
-
-
-
- /**************************************************************************
- * Get Max Field Size
- * @return field size
- * @throws SQLException
- * @see java.sql.Statement#getMaxFieldSize()
- */
- public int getMaxFieldSize () throws SQLException
- {
- if (p_stmt != null)
- return p_stmt.getMaxFieldSize();
- throw new java.lang.UnsupportedOperationException ("Method getMaxFieldSize() not yet implemented.");
- }
-
- /**
- * Method setMaxFieldSize
- * @param max int
- * @throws SQLException
- * @see java.sql.Statement#setMaxFieldSize(int)
- */
- public void setMaxFieldSize (int max) throws SQLException
- {
- if (p_stmt != null)
- p_stmt.setMaxFieldSize(max);
- else
- throw new java.lang.UnsupportedOperationException ("Method setMaxFieldSize() not yet implemented.");
- }
-
- /**
- * Method getMaxRows
- * @return int
- * @throws SQLException
- * @see java.sql.Statement#getMaxRows()
- */
- public int getMaxRows () throws SQLException
- {
- if (p_stmt != null)
- return p_stmt.getMaxRows();
- throw new java.lang.UnsupportedOperationException ("Method getMaxRows() not yet implemented.");
- }
-
- /**
- * Method setMaxRows
- * @param max int
- * @throws SQLException
- * @see java.sql.Statement#setMaxRows(int)
- */
- public void setMaxRows (int max) throws SQLException
- {
- if (p_stmt != null)
- p_stmt.setMaxRows(max);
- else
- throw new java.lang.UnsupportedOperationException ("Method setMaxRows() not yet implemented.");
- }
-
- /*************************************************************************
- * Add Batch
- * @param sql sql
- * @throws SQLException
- * @see java.sql.Statement#addBatch(String)
- */
- public void addBatch (String sql) throws SQLException
- {
- if (p_stmt != null)
- p_stmt.addBatch(sql);
- else
- throw new java.lang.UnsupportedOperationException ("Method addBatch() not yet implemented.");
- }
-
- /**
- * Method clearBatch
- * @throws SQLException
- * @see java.sql.Statement#clearBatch()
- */
- public void clearBatch () throws SQLException
- {
- if (p_stmt != null)
- p_stmt.clearBatch();
- else
- throw new java.lang.UnsupportedOperationException ("Method clearBatch() not yet implemented.");
- }
-
- /**
- * Method executeBatch
- * @return int[]
- * @throws SQLException
- * @see java.sql.Statement#executeBatch()
- */
- public int[] executeBatch () throws SQLException
- {
- if (p_stmt != null)
- return p_stmt.executeBatch();
- throw new java.lang.UnsupportedOperationException ("Method executeBatch() not yet implemented.");
- }
-
-
- /**
- * Method getMoreResults
- * @param current int
- * @return boolean
- * @throws SQLException
- * @see java.sql.Statement#getMoreResults(int)
- */
- public boolean getMoreResults (int current) throws SQLException
- {
- if (p_stmt != null)
- return p_stmt.getMoreResults(current);
- throw new java.lang.UnsupportedOperationException ("Method getMoreResults() not yet implemented.");
- }
-
-
- /**
- * Method getGeneratedKeys
- * @return ResultSet
- * @throws SQLException
- * @see java.sql.Statement#getGeneratedKeys()
- */
- public ResultSet getGeneratedKeys () throws SQLException
- {
- if (p_stmt != null)
- return p_stmt.getGeneratedKeys();
- throw new java.lang.UnsupportedOperationException ("Method getGeneratedKeys() not yet implemented.");
- }
-
- /**
- * Method getResultSetHoldability
- * @return int
- * @throws SQLException
- * @see java.sql.Statement#getResultSetHoldability()
- */
- public int getResultSetHoldability () throws SQLException
- {
- if (p_stmt != null)
- return p_stmt.getResultSetHoldability();
- throw new java.lang.UnsupportedOperationException ("Method getResultSetHoldability() not yet implemented.");
- }
-
- /**
- * Method setEscapeProcessing
- * @param enable boolean
- * @throws SQLException
- * @see java.sql.Statement#setEscapeProcessing(boolean)
- */
- public void setEscapeProcessing (boolean enable) throws SQLException
- {
- if (p_stmt != null)
- p_stmt.setEscapeProcessing(enable);
- else
- throw new java.lang.UnsupportedOperationException ("Method setEscapeProcessing() not yet implemented.");
- }
-
- /**
- * Method getQueryTimeout
- * @return int
- * @throws SQLException
- * @see java.sql.Statement#getQueryTimeout()
- */
- public int getQueryTimeout () throws SQLException
- {
- if (p_stmt != null)
- return p_stmt.getQueryTimeout();
- throw new java.lang.UnsupportedOperationException ("Method getQueryTimeout() not yet implemented.");
- }
-
- /**
- * Method setQueryTimeout
- * @param seconds int
- * @throws SQLException
- * @see java.sql.Statement#setQueryTimeout(int)
- */
- public void setQueryTimeout (int seconds) throws SQLException
- {
- if (p_stmt != null)
- p_stmt.setQueryTimeout (seconds);
- else
- throw new java.lang.UnsupportedOperationException ("Method setQueryTimeout() not yet implemented.");
- }
-
- /**
- * Method cancel
- * @throws SQLException
- * @see java.sql.Statement#cancel()
- */
- public void cancel () throws SQLException
- {
- if (p_stmt != null)
- p_stmt.cancel();
- else
- throw new java.lang.UnsupportedOperationException ("Method cancel() not yet implemented.");
- }
-
- /**
- * Method getWarnings
- * @return SQLWarning
- * @throws SQLException
- * @see java.sql.Statement#getWarnings()
- */
- public SQLWarning getWarnings () throws SQLException
- {
- if (p_stmt != null)
- return p_stmt.getWarnings();
- throw new java.lang.UnsupportedOperationException ("Method getWarnings() not yet implemented.");
- }
-
- /**
- * Method clearWarnings
- * @throws SQLException
- * @see java.sql.Statement#clearWarnings()
- */
- public void clearWarnings () throws SQLException
- {
- if (p_stmt != null)
- p_stmt.clearWarnings();
- else
- throw new java.lang.UnsupportedOperationException ("Method clearWarnings() not yet implemented.");
- }
-
- /**
- * Method setCursorName
- * @param name String
- * @throws SQLException
- * @see java.sql.Statement#setCursorName(String)
- */
- public void setCursorName (String name) throws SQLException
- {
- if (p_stmt != null)
- p_stmt.setCursorName(name);
- else
- throw new java.lang.UnsupportedOperationException ("Method setCursorName() not yet implemented.");
- }
-
-
- /**
- * Method getResultSet
- * @return ResultSet
- * @throws SQLException
- * @see java.sql.Statement#getResultSet()
- */
- public ResultSet getResultSet () throws SQLException
- {
- if (p_stmt != null)
- return p_stmt.getResultSet();
- throw new java.lang.UnsupportedOperationException ("Method getResultSet() not yet implemented.");
- }
-
- /**
- * Method getUpdateCount
- * @return int
- * @throws SQLException
- * @see java.sql.Statement#getUpdateCount()
- */
- public int getUpdateCount () throws SQLException
- {
- if (p_stmt != null)
- return p_stmt.getUpdateCount();
- throw new java.lang.UnsupportedOperationException ("Method getUpdateCount() not yet implemented.");
- }
-
- /**
- * Method getMoreResults
- * @return boolean
- * @throws SQLException
- * @see java.sql.Statement#getMoreResults()
- */
- public boolean getMoreResults () throws SQLException
- {
- if (p_stmt != null)
- return p_stmt.getMoreResults();
- throw new java.lang.UnsupportedOperationException ("Method getMoreResults() not yet implemented.");
- }
-
- /**
- * Method setFetchDirection
- * @param direction int
- * @throws SQLException
- * @see java.sql.Statement#setFetchDirection(int)
- */
- public void setFetchDirection (int direction) throws SQLException
- {
- if (p_stmt != null)
- p_stmt.setFetchDirection(direction);
- else
- throw new java.lang.UnsupportedOperationException ("Method setFetchDirection() not yet implemented.");
- }
-
- /**
- * Method getFetchDirection
- * @return int
- * @throws SQLException
- * @see java.sql.Statement#getFetchDirection()
- */
- public int getFetchDirection () throws SQLException
- {
- if (p_stmt != null)
- return p_stmt.getFetchDirection();
- throw new java.lang.UnsupportedOperationException ("Method getFetchDirection() not yet implemented.");
- }
-
- /**
- * Method setFetchSize
- * @param rows int
- * @throws SQLException
- * @see java.sql.Statement#setFetchSize(int)
- */
- public void setFetchSize (int rows) throws SQLException
- {
- if (p_stmt != null)
- p_stmt.setFetchSize(rows);
- else
- throw new java.lang.UnsupportedOperationException ("Method setFetchSize() not yet implemented.");
- }
-
- /**
- * Method getFetchSize
- * @return int
- * @throws SQLException
- * @see java.sql.Statement#getFetchSize()
- */
- public int getFetchSize () throws SQLException
- {
- if (p_stmt != null)
- return p_stmt.getFetchSize();
- throw new java.lang.UnsupportedOperationException ("Method getFetchSize() not yet implemented.");
- }
-
- /**
- * Method getResultSetConcurrency
- * @return int
- * @throws SQLException
- * @see java.sql.Statement#getResultSetConcurrency()
- */
- public int getResultSetConcurrency () throws SQLException
- {
- if (p_stmt != null)
- return p_stmt.getResultSetConcurrency();
- throw new java.lang.UnsupportedOperationException ("Method getResultSetConcurrency() not yet implemented.");
- }
-
- /**
- * Method getResultSetType
- * @return int
- * @throws SQLException
- * @see java.sql.Statement#getResultSetType()
- */
- public int getResultSetType () throws SQLException
- {
- if (p_stmt != null)
- return p_stmt.getResultSetType();
- throw new java.lang.UnsupportedOperationException ("Method getResultSetType() not yet implemented.");
- }
-
- /**
- * Close
- * @throws SQLException
- * @see java.sql.Statement#close()
- */
- public void close () throws SQLException
- {
- if (close) return;
-
- try {
- if (p_stmt != null)
- {
- p_stmt.close();
- }
- } finally {
- if (m_conn != null)
- {
- try
- {
- m_conn.close();
- }
- catch (Exception e)
- {}
- }
- m_conn = null;
- close = true;
- }
- } // close
-
- /**
- *
- * @return boolean
- * @throws SQLException
- */
- protected boolean remote_execute() throws SQLException {
- // Client -> remote sever
- log.finest("server => " + p_vo + ", Remote=" + DB.isRemoteObjects());
- try
- {
- if (DB.isRemoteObjects() && CConnection.get().isAppsServerOK(false))
- {
- Server server = CConnection.get().getServer();
- if (server != null)
- {
- executeResult = server.stmt_execute(p_vo, SecurityToken.getInstance());
- p_vo.clearParameters(); // re-use of result set
- return executeResult.isFirstResult();
- }
- log.log(Level.SEVERE, "AppsServer not found");
- }
- throw new IllegalStateException("Remote Connection - Application server not available");
- }
- 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);
- }
- }
-
/**
* Execute Query
* @return ResultSet or RowSet
* @throws SQLException
* @see java.sql.PreparedStatement#executeQuery()
*/
- public RowSet getRowSet()
- {
- if (p_stmt != null) // local
- return local_getRowSet();
- //
- // Client -> remote sever
- log.finest("server => " + p_vo + ", Remote=" + DB.isRemoteObjects());
- try
- {
- boolean remote = DB.isRemoteObjects() && CConnection.get().isAppsServerOK(false);
- if (remote && p_remoteErrors > 1)
- remote = CConnection.get().isAppsServerOK(true);
- if (remote)
- {
- Server server = CConnection.get().getServer();
- if (server != null)
- {
- RowSet rs = server.stmt_getRowSet (p_vo, SecurityToken.getInstance());
- p_vo.clearParameters(); // re-use of result set
- if (rs == null)
- log.warning("RowSet is null - " + p_vo);
- else
- p_remoteErrors = 0;
- return rs;
- }
- log.log(Level.SEVERE, "AppsServer not found");
- p_remoteErrors++;
- }
- }
- catch (Exception ex)
- {
- log.log(Level.SEVERE, "AppsServer error", ex);
- p_remoteErrors++;
- if (ex instanceof RuntimeException)
- throw (RuntimeException)ex;
- else
- throw new RuntimeException(ex);
- }
- throw new IllegalStateException("Remote Connection - Application server not available");
- }
+ public RowSet getRowSet();
- /*************************************************************************
- * Get Result as RowSet for Remote.
- * Note that close the oracle OracleCachedRowSet also close connection!
- * @return result as RowSet
+ /**
+ * @return boolean
+ * @throws SQLException
*/
- protected RowSet local_getRowSet()
- {
- log.finest("local_getRowSet");
- RowSet rowSet = null;
- ResultSet rs = null;
- try
- {
- rs = p_stmt.executeQuery(p_vo.getSql());
- rowSet = CCachedRowSet.getRowSet(rs);
- }
- catch (Exception ex)
- {
- log.log(Level.SEVERE, p_vo.toString(), ex);
- throw new RuntimeException (ex);
- }
- finally
- {
- DB.close(rs);
- }
- return rowSet;
- } // local_getRowSet
-
- public boolean isPoolable() throws SQLException{ return false;}
-
- public void setPoolable(boolean a) throws SQLException{};
-
- public boolean isClosed() throws SQLException{ return close;}
-
- public boolean isWrapperFor(java.lang.Class c) throws SQLException{ return false;}
-
- public T unwrap(java.lang.Class iface) throws java.sql.SQLException{return null;}
-
- @Override
- protected void finalize() throws Throwable
- {
- //hengsin: not the best way but it help to reduce connection and statement leakage.
- if (p_stmt != null && !close)
- {
- this.close();
- }
- }
+ public boolean isClosed() throws SQLException;
+
+ /**
+ *
+ * @throws SQLException
+ */
+ public void commit() throws SQLException;
+ /**
+ * don't call this directly, invoke by finalizer thread
+ * @throws Throwable
+ */
+ public void finalize() throws Throwable;
} // CStatement
diff --git a/base/src/org/compiere/util/CStatementVO.java b/base/src/org/compiere/util/CStatementVO.java
index 0cf8a6edb2..45c36b1f65 100644
--- a/base/src/org/compiere/util/CStatementVO.java
+++ b/base/src/org/compiere/util/CStatementVO.java
@@ -17,9 +17,6 @@
package org.compiere.util;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
/**
* Adempiere Statement Value Object
@@ -61,15 +58,8 @@ public class CStatementVO implements Serializable
private int m_resultSetConcurrency;
/** SQL Statement */
private String m_sql;
- /** Parameters */
- private ArrayList