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 m_parameters = new ArrayList(); /** Transaction Name **/ - private String m_trxName = null; - - private Map m_namedOutput = new HashMap(); - - private Mapm_namedParameters = new HashMap(); - + private String m_trxName = null; /** * String representation * @return info @@ -77,86 +67,13 @@ public class CStatementVO implements Serializable public String toString() { StringBuffer sb = new StringBuffer("CStatementVO["); - sb.append(getSql()); - for (int i = 0; i < m_parameters.size(); i++) - sb.append("; #").append(i+1).append("=").append(m_parameters.get(i)); + sb.append("SQL="+getSql()); + if (m_trxName != null) + sb.append(" TrxName=" + m_trxName); sb.append("]"); return sb.toString(); } // toString - /** - * Set Parameter - * @param index1 1 based index - * @param element element - */ - public void setParameter (int index1, Object element) - { - if (element != null && !(element instanceof Serializable)) - throw new java.lang.RuntimeException("setParameter not Serializable - " + element.getClass().toString()); - int zeroIndex = index1 - 1; - if (m_parameters.size() == zeroIndex) - { - m_parameters.add(element); - } - else if (m_parameters.size() < zeroIndex) - { - while (m_parameters.size() < zeroIndex) - m_parameters.add (null); // fill with nulls - m_parameters.add(element); - } - else - m_parameters.set(zeroIndex, element); - } // setParameter - - /** - * Set Parameter - * @param index1 1 based index - * @param element element - */ - public void setParameter (String name, Object element) - { - if (element != null && !(element instanceof Serializable)) - throw new java.lang.RuntimeException("setParameter not Serializable - " + element.getClass().toString()); - m_namedParameters.put(name, element); - } // setParametsr - - /** - * Clear Parameters - */ - public void clearParameters() - { - m_parameters = new ArrayList(); - m_namedParameters = new HashMap(); - } // clearParameters - - /** - * Get Parameters - * @return arraylist - */ - public ArrayList getParameters() - { - return m_parameters; - } // getParameters - - /*** - * get named parameters for callable statement - * @return map - */ - public Map getNamedParameters() - { - return m_namedParameters; - } - - /** - * Get Parameter Count - * @return arraylist - */ - public int getParameterCount() - { - return m_parameters.size(); - } // getParameterCount - - /** * Get SQL * @return sql @@ -174,19 +91,7 @@ public class CStatementVO implements Serializable */ public void setSql(String sql) { - if (sql != null && DB.isRemoteObjects()) - { - // Handle RowID in the select part (not where clause) - int pos = sql.indexOf("ROWID"); - int posTrim = sql.indexOf("TRIM(ROWID)"); - int posWhere = sql.indexOf("WHERE"); - if (pos != -1 && posTrim == -1 && (posWhere == -1 || pos < posWhere)) - m_sql = sql.substring(0, pos) + "TRIM(ROWID)" + sql.substring(pos+5); - else - m_sql = sql; - } - else - m_sql = sql; + m_sql = sql; } // setSql /** @@ -238,54 +143,4 @@ public class CStatementVO implements Serializable { m_trxName = trxName; } - - public void registerOutParameter(String parameterName, int sqlType, - int scale) - { - OutputParameter o = new OutputParameter(sqlType, scale, null); - m_namedOutput.put(parameterName, o); - } - - public void registerOutParameter(int paramIndex, int sqlType, - String typeName) - { - OutputParameter o = new OutputParameter(sqlType, -1, typeName); - this.setParameter(paramIndex, o); - } - - public void registerOutParameter(int parameterIndex, int sqlType, int scale) - { - OutputParameter o = new OutputParameter(sqlType, scale, null); - this.setParameter(parameterIndex, o); - - } - - public void registerOutParameter(String parameterName, int sqlType) - { - OutputParameter o = new OutputParameter(sqlType, -1, null); - m_namedOutput.put(parameterName, o); - } - - public void registerOutParameter(int parameterIndex, int sqlType) - { - OutputParameter o = new OutputParameter(sqlType, -1, null); - this.setParameter(parameterIndex, o); - } - - public void registerOutParameter(String parameterName, int sqlType, - String typeName) - { - OutputParameter o = new OutputParameter(sqlType, -1, typeName); - m_namedOutput.put(parameterName, o); - } - - public Map getNamedOutput() - { - return m_namedOutput; - } - - /* - public boolean hasOutputParameters() { - return m_ordinalOutput.size() > 0 || m_namedOutput.size() > 0; - }*/ } // CStatementVO diff --git a/base/src/org/compiere/util/CacheMgt.java b/base/src/org/compiere/util/CacheMgt.java index a6c7e03192..5bfb3a8fd3 100644 --- a/base/src/org/compiere/util/CacheMgt.java +++ b/base/src/org/compiere/util/CacheMgt.java @@ -168,24 +168,7 @@ public class CacheMgt } } log.info(tableName + ": #" + counter + " (" + total + ")"); - // Update Server - if (DB.isRemoteObjects()) - { - Server server = CConnection.get().getServer(); - try - { - if (server != null) - { // See ServerBean - int serverTotal = server.cacheReset(tableName, 0); - if (CLogMgt.isLevelFinest()) - log.fine("Server => " + serverTotal); - } - } - catch (RemoteException ex) - { - log.log(Level.SEVERE, "AppsServer error", ex); - } - } + return total; } // reset diff --git a/base/src/org/compiere/util/DB.java b/base/src/org/compiere/util/DB.java index 74e2d9602b..35b99e78da 100644 --- a/base/src/org/compiere/util/DB.java +++ b/base/src/org/compiere/util/DB.java @@ -44,7 +44,7 @@ import org.compiere.Adempiere; import org.compiere.db.AdempiereDatabase; import org.compiere.db.CConnection; import org.compiere.db.Database; -import org.compiere.db.ServerConnection; +import org.compiere.db.ProxyFactory; import org.compiere.model.MAcctSchema; import org.compiere.model.MLanguage; import org.compiere.model.MRole; @@ -80,16 +80,6 @@ public final class DB { /** Connection Descriptor */ private static CConnection s_cc = null; -// /** Connection Cache r/o */ -// private static Connection[] s_connections = null; -// /** Connection Cache Size */ -// private static int s_conCacheSize = Ini.isClient() ? 1 : 3; -// /** Connection counter */ -// private static int s_conCount = 0; -// /** Connection r/w */ -// private static Connection s_connectionRW = null; -// /** Connection r/w for ID */ -// private static Connection s_connectionID = null; /** Logger */ private static CLogger log = CLogger.getCLogger (DB.class); @@ -262,8 +252,8 @@ public final class DB { s_cc = cc; } - if ( isRemoteObjects() == false) - s_cc.setDataSource(); + + s_cc.setDataSource(); log.config(s_cc + " - DS=" + s_cc.isDataSource()); // Trace.printStack(); @@ -274,10 +264,6 @@ public final class DB * @return True if success, false otherwise */ public static boolean connect() { - //wan and vpn profile ( remote connection ) - if (isRemoteObjects()) - return CConnection.get().isAppsServerOK(true); - //direct connection boolean success =false; try @@ -331,10 +317,6 @@ public final class DB //bug [1637432] if (s_cc == null) return false; - //wan/vpn profile ( remote connection ) - if (CConnection.get().isServerObjects()) - return s_cc.isAppsServerOK(createNew); - //direct connection boolean success = false; CLogErrorBuffer eb = CLogErrorBuffer.get(false); @@ -408,10 +390,6 @@ public final class DB */ public static Connection createConnection (boolean autoCommit, int trxLevel) { - //wan/vpn profile ( remote connection ) - if (CConnection.get().isServerObjects()) - return new ServerConnection(); - Connection conn = s_cc.getConnection (autoCommit, trxLevel); if (CLogMgt.isLevelFinest()) { @@ -450,10 +428,6 @@ public final class DB */ public static Connection createConnection (boolean autoCommit, boolean readOnly, int trxLevel) { - //wan/vpn profile ( remote connection ) - if (CConnection.get().isServerObjects()) - return new ServerConnection(); - Connection conn = s_cc.getConnection (autoCommit, trxLevel); //hengsin: this could be problematic as it can be reuse for readwrite activites after return to pool @@ -703,7 +677,8 @@ public final class DB { if (SQL == null || SQL.length() == 0) throw new IllegalArgumentException("Required parameter missing - " + SQL); - return new CCallableStatement(ResultSet.TYPE_FORWARD_ONLY, resultSetConcurrency, SQL, trxName); + return ProxyFactory.newCCallableStatement(ResultSet.TYPE_FORWARD_ONLY, resultSetConcurrency, SQL, + trxName); } // prepareCall @@ -765,7 +740,7 @@ public final class DB if (sql == null || sql.length() == 0) throw new IllegalArgumentException("No SQL"); // - return new CPreparedStatement(resultSetType, resultSetConcurrency, sql, trxName); + return ProxyFactory.newCPreparedStatement(resultSetType, resultSetConcurrency, sql, trxName); } // prepareStatement /** @@ -786,7 +761,7 @@ public final class DB */ public static Statement createStatement(int resultSetType, int resultSetConcurrency, String trxName) { - return new CStatement(resultSetType, resultSetConcurrency, trxName); + return ProxyFactory.newCStatement(resultSetType, resultSetConcurrency, trxName); } // createStatement /** @@ -943,7 +918,7 @@ public final class DB throw new IllegalArgumentException("Required parameter missing - " + sql); // int no = -1; - CPreparedStatement cs = new CPreparedStatement(ResultSet.TYPE_FORWARD_ONLY, + CPreparedStatement cs = ProxyFactory.newCPreparedStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE, sql, trxName); // converted in call try @@ -999,7 +974,7 @@ public final class DB throw new IllegalArgumentException("Required parameter missing - " + sql); // int no = -1; - CPreparedStatement cs = new CPreparedStatement(ResultSet.TYPE_FORWARD_ONLY, + CPreparedStatement cs = ProxyFactory.newCPreparedStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE, sql, trxName); // converted in call try @@ -1147,7 +1122,7 @@ public final class DB // RowSet.TYPE_SCROLL_INSENSITIVE, RowSet.CONCUR_READ_ONLY, sql); CStatementVO info = new CStatementVO (RowSet.TYPE_SCROLL_INSENSITIVE, RowSet.CONCUR_READ_ONLY, DB.getDatabase().convertStatement(sql)); // End add vpj-cd e-evolution - CPreparedStatement stmt = new CPreparedStatement(info); + CPreparedStatement stmt = ProxyFactory.newCPreparedStatement(info); retValue = stmt.getRowSet(); try { stmt.close(); @@ -1622,25 +1597,27 @@ public final class DB } // getDocumentNo /** - * Is this a remote client connection + * Is this a remote client connection. + * + * Deprecated, always return false. * @return true if client and RMI or Objects on Server + * @deprecated */ public static boolean isRemoteObjects() { - //avoid infinite loop - if (s_cc == null) return false; - - return CConnection.get().isServerObjects(); + return false; } // isRemoteObjects /** * Is this a remote client connection + * + * Deprecated, always return false. * @return true if client and RMI or Process on Server + * @deprecated */ public static boolean isRemoteProcess() { - return CConnection.get().isServerProcess() - && CConnection.get().isAppsServerOK(false); + return false; } // isRemoteProcess diff --git a/base/src/org/compiere/util/SecurityToken.java b/base/src/org/compiere/util/SecurityToken.java deleted file mode 100644 index c0771c81af..0000000000 --- a/base/src/org/compiere/util/SecurityToken.java +++ /dev/null @@ -1,87 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 2007 Adempiere, Inc. All Rights Reserved. * - * 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. * - * - * Copyright (C) 2007 Low Heng Sin hengsin@avantz.com - * _____________________________________________ - *****************************************************************************/ -package org.compiere.util; - -import java.io.Serializable; -import java.security.CodeSource; -import java.security.cert.Certificate; - -import org.compiere.Adempiere; - -/** - * Security token, send from client to server for security validation. - * @author Low Heng Sin - */ -public class SecurityToken implements Serializable { - - private Certificate codeCertificate; - private String codeBaseHost; - private final static SecurityToken TOKEN = SecurityToken.getSecurityToken(); - - private SecurityToken(Certificate cert, String host) - { - codeCertificate = cert; - codeBaseHost = host; - } - - /** - * Get the certificate that is use to sign the jar library. - * @return Certificate - */ - public final Certificate getCodeCertificate() - { - return codeCertificate; - } - - /** - * Get the host that the code is loaded from. - * @return String - */ - public final String getCodeBaseHost() - { - return codeBaseHost; - } - - /** - * Construct the application wide security token. - * @return SecurityToken - */ - private static SecurityToken getSecurityToken() - { - Certificate cert = null; - String host = null; - CodeSource cs - = SecurityToken.class.getProtectionDomain().getCodeSource(); - if (cs != null) - { - Certificate[] certs = cs.getCertificates(); - if (certs != null && certs.length > 0) - cert = certs[0]; - } - host = Adempiere.getCodeBaseHost(); - return new SecurityToken(cert, host); - } - - /** - * Get the application wide security token. - * @return SecurityToken - */ - public static SecurityToken getInstance() - { - return TOKEN; - } -} diff --git a/base/src/org/compiere/util/Trx.java b/base/src/org/compiere/util/Trx.java index 2203c4eda6..fc0dac4939 100644 --- a/base/src/org/compiere/util/Trx.java +++ b/base/src/org/compiere/util/Trx.java @@ -19,7 +19,6 @@ package org.compiere.util; import java.beans.PropertyChangeEvent; import java.beans.PropertyVetoException; import java.beans.VetoableChangeListener; -import java.rmi.RemoteException; import java.sql.Connection; import java.sql.SQLException; import java.sql.Savepoint; @@ -29,9 +28,6 @@ import java.util.UUID; import java.util.logging.Level; import org.adempiere.exceptions.AdempiereException; -import org.compiere.db.CConnection; -import org.compiere.db.ServerConnection; -import org.compiere.interfaces.Server; /** * Transaction Management. @@ -125,9 +121,6 @@ public class Trx implements VetoableChangeListener // log.info (trxName); setTrxName (trxName); setConnection (con); - //create remote transaction immediately - if (DB.isRemoteObjects()) - this.start(); } // Trx /** Logger */ @@ -146,9 +139,6 @@ public class Trx implements VetoableChangeListener public Connection getConnection() { log.log(Level.ALL, "Active=" + isActive() + ", Connection=" + m_connection); - //wan profile - if (DB.isRemoteObjects()) - return new ServerConnection(getTrxName()); if (m_connection == null) // get new Connection setConnection(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED)); @@ -208,9 +198,6 @@ public class Trx implements VetoableChangeListener log.warning("Trx in progress " + m_trxName); return false; } - if (DB.isRemoteObjects()) { - startRemoteTransaction(); - } m_active = true; m_startTime = System.currentTimeMillis(); return true; @@ -224,26 +211,6 @@ public class Trx implements VetoableChangeListener return new Date(m_startTime); } - private void startRemoteTransaction() { - Server server = CConnection.get().getServer(); - try - { - if (server != null) - { // See ServerBean - server.startTransaction(getTrxName()); - } - else - { - log.log(Level.WARNING, "AppsServer not found"); - } - } - catch (RemoteException ex) - { - log.log(Level.SEVERE, "AppsServer error", ex); - } - - } - /** * Transaction is Active * @return true if transaction active @@ -260,12 +227,6 @@ public class Trx implements VetoableChangeListener */ public boolean rollback(boolean throwException) throws SQLException { - //remote - if (DB.isRemoteObjects()) - { - return remote_rollback(throwException); - } - //local try { @@ -310,12 +271,6 @@ public class Trx implements VetoableChangeListener */ public boolean rollback(Savepoint savepoint) throws SQLException { - //remote - if (DB.isRemoteObjects()) - { - return remote_rollback(savepoint); - } - //local try { @@ -334,97 +289,6 @@ public class Trx implements VetoableChangeListener return false; } // rollback - /** - * Rollback a remote transaction - * @param throwException - * @return true if success, false otherwise - * @throws SQLException - */ - private boolean remote_rollback(boolean throwException) throws SQLException - { - Server server = CConnection.get().getServer(); - try - { - if (server != null) - { // See ServerBean - return server.rollback(m_trxName); - } - else - { - log.log(Level.SEVERE, "AppsServer not found"); - if (throwException) - throw new SQLException("AppsServer not found"); - return false; - } - } - catch (RemoteException ex) - { - log.log(Level.SEVERE, "AppsServer error", ex); - if (throwException) - { - if (ex.getCause() instanceof RuntimeException) - { - RuntimeException r = (RuntimeException)ex.getCause(); - if (r.getCause() instanceof SQLException) - throw (SQLException)r.getCause(); - else if ( r.getCause() != null ) - throw new SQLException("Application server exception - " + r.getCause().getMessage()); - else - throw new SQLException("Application server exception - " + r.getMessage()); - } - else - throw new SQLException("Application server exception - " + ex.getMessage()); - } - - return false; - } - } - - /** - * Rollback a remote transaction - * @param throwException - * @return true if success, false otherwise - * @throws SQLException - */ - private boolean remote_rollback(Savepoint savepoint) throws SQLException - { - Server server = CConnection.get().getServer(); - try - { - if (server != null) - { - SavepointVO sp = null; - if (savepoint instanceof SavepointVO) - sp = (SavepointVO)savepoint; - else - sp = new SavepointVO(savepoint); - return server.rollback(m_trxName, sp); - } - else - { - log.log(Level.SEVERE, "AppsServer not found"); - throw new SQLException("AppsServer not found"); - } - } - catch (RemoteException ex) - { - log.log(Level.SEVERE, "AppsServer error", ex); - if (ex.getCause() instanceof RuntimeException) - { - RuntimeException r = (RuntimeException)ex.getCause(); - if (r.getCause() instanceof SQLException) - throw (SQLException)r.getCause(); - else if ( r.getCause() != null ) - throw new SQLException("Application server exception - " + r.getCause().getMessage()); - else - throw new SQLException("Application server exception - " + r.getMessage()); - } - else - { - throw new SQLException("Application server exception - " + ex.getMessage()); - } - } - } /** * Commit * @param throwException if true, re-throws exception @@ -432,12 +296,6 @@ public class Trx implements VetoableChangeListener **/ public boolean commit(boolean throwException) throws SQLException { - //remote - if (DB.isRemoteObjects()) - { - return remote_commit(throwException); - } - //local try { @@ -462,52 +320,6 @@ public class Trx implements VetoableChangeListener return false; } // commit - /** - * Commit a remote transaction - * @param throwException - * @return true if success, false otherwise - * @throws SQLException - */ - private boolean remote_commit(boolean throwException) throws SQLException - { - Server server = CConnection.get().getServer(); - try - { - if (server != null) - { // See ServerBean - return server.commit(m_trxName); - } - else - { - log.log(Level.SEVERE, "AppsServer not found"); - if (throwException) - throw new SQLException("AppsServer not found"); - return false; - } - } - catch (RemoteException ex) - { - log.log(Level.SEVERE, "AppsServer error", ex); - if (throwException) - { - if (ex.getCause() instanceof RuntimeException) - { - RuntimeException r = (RuntimeException)ex.getCause(); - if (r.getCause() instanceof SQLException) - throw (SQLException)r.getCause(); - else if ( r.getCause() != null ) - throw new SQLException("Application server exception - " + r.getCause().getMessage()); - else - throw new SQLException("Application server exception - " + r.getMessage()); - } - else - throw new SQLException("Application server exception - " + ex.getMessage()); - } - - return false; - } - } - /** * Commit * @return true if success @@ -534,13 +346,6 @@ public class Trx implements VetoableChangeListener if (s_cache != null) s_cache.remove(getTrxName()); - //remote - if (DB.isRemoteObjects()) { - closeRemoteTransaction(); - m_active = false; - return true; - } - //local if (m_connection == null) return true; @@ -563,26 +368,6 @@ public class Trx implements VetoableChangeListener return true; } // close - private void closeRemoteTransaction() { - Server server = CConnection.get().getServer(); - try - { - if (server != null) - { // See ServerBean - server.closeTransaction(getTrxName()); - } - else - { - log.log(Level.WARNING, "AppsServer not found"); - } - } - catch (RemoteException ex) - { - log.log(Level.SEVERE, "AppsServer error", ex); - } - - } - /** * * @param name @@ -590,12 +375,6 @@ public class Trx implements VetoableChangeListener * @throws SQLException */ public Savepoint setSavepoint(String name) throws SQLException { - //remote - if (DB.isRemoteObjects()) - { - return setRemoteSavepoint(name); - } - if (m_connection == null) getConnection(); @@ -609,38 +388,6 @@ public class Trx implements VetoableChangeListener } } - private Savepoint setRemoteSavepoint(String name) throws SQLException { - Server server = CConnection.get().getServer(); - try - { - if (server != null) - { // See ServerBean - return server.setSavepoint(m_trxName, name); - } - else - { - log.log(Level.SEVERE, "AppsServer not found"); - throw new SQLException("AppsServer not found"); - } - } - catch (RemoteException ex) - { - log.log(Level.SEVERE, "AppsServer error", ex); - if (ex.getCause() instanceof RuntimeException) - { - RuntimeException r = (RuntimeException)ex.getCause(); - if (r.getCause() instanceof SQLException) - throw (SQLException)r.getCause(); - else if ( r.getCause() != null ) - throw new SQLException("Application server exception - " + r.getCause().getMessage()); - else - throw new SQLException("Application server exception - " + r.getMessage()); - } - else - throw new SQLException("Application server exception - " + ex.getMessage()); - } - } - /** * String Representation * @return info diff --git a/client/src/org/compiere/apps/AEnv.java b/client/src/org/compiere/apps/AEnv.java index 7b6a61b02e..23f5221a2d 100644 --- a/client/src/org/compiere/apps/AEnv.java +++ b/client/src/org/compiere/apps/AEnv.java @@ -873,47 +873,7 @@ public final class AEnv log.info("Cached=" + mWindowVO); } } - // try to get from Server when enabled - if (mWindowVO == null && DB.isRemoteObjects() && isServerActive()) - { - log.config("trying server"); - try - { - s_server = CConnection.get().getServer(); - if (s_server != null) - { - mWindowVO = s_server.getWindowVO(Env.getCtx(), WindowNo, AD_Window_ID, AD_Menu_ID); - log.config("from Server: success"); - } - } - catch (RemoteException e) - { - log.log(Level.SEVERE, "(RE)", e); - mWindowVO = null; - s_server = null; - } - catch (Exception e) - { - Throwable tt = e.getCause(); - if (tt != null && tt instanceof InvalidClassException) - log.log(Level.SEVERE, "(Server<>Client class) " + tt); - else if (tt != null && tt instanceof NotSerializableException) - log.log(Level.SEVERE, "Serialization: " + tt.getMessage(), e); - else - log.log(Level.SEVERE, "ex", e); - mWindowVO = null; - s_server = null; - } - catch (Throwable t) - { - log.log(Level.SEVERE, t.toString()); - mWindowVO = null; - s_server = null; - } - if (mWindowVO != null) - s_windows.put(AD_Window_ID, mWindowVO); - } // from Server - + // Create Window Model on Client if (mWindowVO == null) { diff --git a/client/src/org/compiere/apps/ALogin.java b/client/src/org/compiere/apps/ALogin.java index c2fc8c54fb..4d0da1943c 100644 --- a/client/src/org/compiere/apps/ALogin.java +++ b/client/src/org/compiere/apps/ALogin.java @@ -363,25 +363,12 @@ public final class ALogin extends CDialog private void validateAppServer() { m_cc.testAppsServer(); - if (m_cc.getAppsServerException() != null) - { - if (m_cc.isServerObjects()) - { - m_cc.getAppsServerException().printStackTrace(); - JOptionPane.showMessageDialog(null, - m_cc.getAppsServerException().getLocalizedMessage(), - "Error", JOptionPane.ERROR_MESSAGE); - } - } } private void connectToDatabase() { //Check connection DB.setDBTarget(m_cc); - //wan or vpn ( remote connection ) - if (m_cc.isServerObjects()) return; - //direct DB.connect(); } diff --git a/client/src/org/compiere/apps/ProcessCtl.java b/client/src/org/compiere/apps/ProcessCtl.java index 9161e01191..203e333f03 100644 --- a/client/src/org/compiere/apps/ProcessCtl.java +++ b/client/src/org/compiere/apps/ProcessCtl.java @@ -42,7 +42,6 @@ import org.compiere.util.DB; import org.compiere.util.Env; import org.compiere.util.Ini; import org.compiere.util.Msg; -import org.compiere.util.SecurityToken; import org.compiere.util.Trx; import org.compiere.wf.MWFProcess; @@ -551,7 +550,7 @@ public class ProcessCtl implements Runnable { log.fine(AD_Workflow_ID + " - " + m_pi); boolean started = false; - if (DB.isRemoteProcess() || m_IsServerProcess) + if (m_IsServerProcess) { Server server = CConnection.get().getServer(); try @@ -604,15 +603,13 @@ public class ProcessCtl implements Runnable } catch (Exception e) {} } - if ((DB.isRemoteProcess() || m_IsServerProcess) && !clientOnly) + if (m_IsServerProcess && !clientOnly) { Server server = CConnection.get().getServer(); try { if (server != null) { - if (m_trx != null) - m_pi.setTransactionName(m_trx.getTrxName()); // See ServerBean m_pi = server.process (Env.getCtx(), m_pi); log.finest("server => " + m_pi); @@ -669,14 +666,14 @@ public class ProcessCtl implements Runnable log.fine(ProcedureName + "(" + m_pi.getAD_PInstance_ID() + ")"); boolean started = false; String trxName = m_trx != null ? m_trx.getTrxName() : null; - if (DB.isRemoteProcess() || m_IsServerProcess) + if (m_IsServerProcess) { Server server = CConnection.get().getServer(); try { if (server != null) { // See ServerBean - m_pi = server.dbProcess(m_pi, ProcedureName, trxName, SecurityToken.getInstance()); + m_pi = server.dbProcess(m_pi, ProcedureName); log.finest("server => " + m_pi); started = true; } diff --git a/install/Adempiere/RUN_setup.sh b/install/Adempiere/RUN_setup.sh index 11e20009d2..1e106cac42 100644 --- a/install/Adempiere/RUN_setup.sh +++ b/install/Adempiere/RUN_setup.sh @@ -51,4 +51,4 @@ cd utils #%JAVA% -classpath lib/Adempiere.jar:lib/AdempiereCLib.jar org.compiere.install.ConnectTest localhost echo . -echo For problems, check log file in base directory \ No newline at end of file +echo For problems, check log file in base directory diff --git a/install/Adempiere/RUN_silentsetup.sh b/install/Adempiere/RUN_silentsetup.sh index 2aa8e7e989..f045c6e6f7 100644 --- a/install/Adempiere/RUN_silentsetup.sh +++ b/install/Adempiere/RUN_silentsetup.sh @@ -38,4 +38,4 @@ cd utils . RUN_UnixEnv.sh echo . -echo For problems, check log file in base directory \ No newline at end of file +echo For problems, check log file in base directory diff --git a/serverRoot/build.xml b/serverRoot/build.xml index c176340a84..09d5445722 100644 --- a/serverRoot/build.xml +++ b/serverRoot/build.xml @@ -107,35 +107,7 @@ securityDomain="java:/jaas/adempiere" destdir="${build.dir}/META-INF"/> - - - - adempiere/ServerLocal]]> - adempiere/ServerLocal - - - - stateless-http-invoker - - - - ]]> - - - - adempiere/StatusLocal]]> - adempiere/StatusLocal - - - - stateless-http-invoker - - - - ]]> - + diff --git a/serverRoot/src/main/ejb/org/compiere/session/ServerBean.java b/serverRoot/src/main/ejb/org/compiere/session/ServerBean.java index 63cf69c5b7..9f22023cba 100644 --- a/serverRoot/src/main/ejb/org/compiere/session/ServerBean.java +++ b/serverRoot/src/main/ejb/org/compiere/session/ServerBean.java @@ -16,16 +16,10 @@ *****************************************************************************/ package org.compiere.session; -import java.io.*; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.security.cert.Certificate; -import java.sql.*; import java.util.*; import java.util.logging.*; import javax.ejb.*; -import javax.sql.*; import org.adempiere.util.ProcessUtil; import org.compiere.*; @@ -83,26 +77,6 @@ public class ServerBean implements SessionBean private int m_cacheResetCount = 0; private int m_updateLOBCount = 0; - /** - * Get and create Window Model Value Object - * @ejb.interface-method view-type="both" - * - * @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 GridWindowVO getWindowVO (Properties ctx, int WindowNo, int AD_Window_ID, int AD_Menu_ID) - { - log.info ("getWindowVO[" + m_no + "] Window=" + AD_Window_ID); - // log.fine(ctx); - GridWindowVO vo = GridWindowVO.create(ctx, WindowNo, AD_Window_ID, AD_Menu_ID); - m_windowCount++; - return vo; - } // getWindowVO - - /** * Post Immediate * @ejb.interface-method view-type="both" @@ -129,440 +103,6 @@ public class ServerBean implements SessionBean return Doc.postImmediate(ass, AD_Table_ID, Record_ID, force, trxName); } // postImmediate - /************************************************************************* - * Get Prepared Statement ResultSet - * @ejb.interface-method view-type="both" - * - * @param info Result info - * @param token Security Token - * @return RowSet - * @throws NotSerializableException - */ - public RowSet pstmt_getRowSet (CStatementVO info, SecurityToken token) - throws NotSerializableException - { - - validateSecurityToken(token); - - if (info.getTrxName() != null) { - if (Trx.get(info.getTrxName(), false) == null) - throw new RuntimeException("Transaction lost - " + info.getTrxName()); - } - - m_stmt_rowSetCount++; - CPreparedStatement pstmt = new CPreparedStatement(info); - RowSet rowset = null; - try - { - rowset = pstmt.getRowSet(); - } - finally - { - try - { - pstmt.close(); - } - catch (Exception ex) - { - log.log(Level.SEVERE, "Could not close prepared statement", ex); - } - } - return rowset; - } // pstmt_getRowSet - - /** - * Get Statement ResultSet - * @ejb.interface-method view-type="both" - * - * @param info Result info - * @param token Security Token - * @return RowSet - */ - public RowSet stmt_getRowSet (CStatementVO info, SecurityToken token) - { - validateSecurityToken(token); - - if (info.getTrxName() != null) { - if (Trx.get(info.getTrxName(), false) == null) - throw new RuntimeException("Transaction lost - " + info.getTrxName()); - } - m_stmt_rowSetCount++; - CPreparedStatement stmt = new CPreparedStatement(info); - RowSet rowset = null; - try - { - rowset = stmt.getRowSet(); - } - finally - { - DB.close(stmt); - } - return rowset; - } // stmt_getRowSet - - /** - * Execute Update - * @ejb.interface-method view-type="both" - * - * @param info Result info - * @param token Security Token - * @return row count - */ - public int stmt_executeUpdate (CStatementVO info, SecurityToken token) - { - validateSecurityToken(token); - - if (info.getTrxName() != null) { - if (Trx.get(info.getTrxName(), false) == null) - throw new RuntimeException("Transaction lost - " + info.getTrxName()); - } - - m_stmt_updateCount++; - CPreparedStatement stmt = null; - int retVal = -1; - try - { - stmt = new CPreparedStatement(info); - if (info.getParameterCount() > 0) - stmt.fillParametersFromVO(); - retVal = stmt.executeUpdate(); - } - catch (SQLException e) - { - log.log(Level.SEVERE, info.toString(), e); - throw new RuntimeException (e); - } - finally - { - DB.close(stmt); - } - return retVal; - } // stmt_executeUpdate - - /** - * @ejb.interface-method view-type="both" - * - * @param info - * @param token - * @return ExecuteResult - */ - public ExecuteResult stmt_execute( org.compiere.util.CStatementVO info,org.compiere.util.SecurityToken token ) - { - ExecuteResult result = new ExecuteResult(); - if (info.getTrxName() != null) - { - if (Trx.get(info.getTrxName(), false) == null) - throw new RuntimeException("Transaction lost - " + info.getTrxName()); - } - - CPreparedStatement stmt = null; - try - { - stmt = new CPreparedStatement(info); - stmt.fillParametersFromVO(); - boolean b = stmt.execute(); - result.setFirstResult(b); - while (b) - { - ResultSet rs = stmt.getResultSet(); - result.addResultSet(CCachedRowSet.getRowSet(rs)); - rs.close(); - b = stmt.getMoreResults(); - } - result.setUpdateCount(stmt.getUpdateCount()); - } - catch (SQLException e) - { - log.log(Level.SEVERE, info.toString(), e); - throw new RuntimeException (e); - } - finally - { - DB.close(stmt); - } - - return result; - } - - /*** - * @ejb.interface-method view-type="both" - * - * @param info - * @param token - * @return CallableResult - */ - public CallableResult callable_execute( org.compiere.util.CStatementVO info,org.compiere.util.SecurityToken token ) - { - CallableResult result = new CallableResult(); - - if (info.getTrxName() != null) { - if (Trx.get(info.getTrxName(), false) == null) - throw new RuntimeException("Transaction lost - " + info.getTrxName()); - } - - CCallableStatement stmt = null; - try - { - stmt = new CCallableStatement(info); - stmt.fillParametersFromVO(); - boolean b = stmt.execute(); - result.setFirstResult(b); - - //retrieve result set and update count - while (b) { - ResultSet rs = stmt.getResultSet(); - result.addResultSet(CCachedRowSet.getRowSet(rs)); - rs.close(); - b = stmt.getMoreResults(); - } - result.setUpdateCount(stmt.getUpdateCount()); - - //get ordinal outputparameter value - ArrayList ordinal = info.getParameters(); - Map ordinalOutput = new HashMap(); - for (int i = 0; i < ordinal.size(); i++) - { - Object o = ordinal.get(i); - if (o instanceof OutputParameter) - { - OutputParameter output = (OutputParameter)o; - retrieveOutputParameter(stmt, output, i+1, null); - ordinalOutput.put((i+1), o); - } - } - result.setOrdinalOutput(ordinalOutput); - - //get named output parameter value - Map named = info.getNamedOutput(); - for (Iterator iter = named.entrySet().iterator(); iter.hasNext(); ) - { - Map.Entry e = (Map.Entry)iter.next(); - String s = (String)e.getKey(); - OutputParameter output = (OutputParameter)e.getValue(); - retrieveOutputParameter(stmt, output, -1, s); - } - result.setNamedOutput(named); - } catch (SQLException e) { - log.log(Level.SEVERE, info.toString(), e); - throw new RuntimeException (e); - } - finally - { - DB.close(stmt); - } - - return result; - } - - private void retrieveOutputParameter(CallableStatement stmt, OutputParameter o, int i, String s) throws SQLException - { - switch (o.getSqlType()) { - case Types.BIGINT: - if (i > 0) - o.setValue(stmt.getLong(i)); - else - o.setValue(stmt.getLong(s)); - break; - case Types.BINARY: - case Types.LONGVARBINARY: - case Types.VARBINARY: - if (i > 0) - o.setValue(stmt.getBytes(i)); - else - o.setValue(stmt.getBytes(s)); - break; - case Types.BOOLEAN: - if (i > 0) - o.setValue(stmt.getBoolean(i)); - else - o.setValue(stmt.getBoolean(s)); - break; - case Types.CHAR: - case Types.LONGVARCHAR: - case Types.VARCHAR: - if (i > 0) - o.setValue(stmt.getString(i)); - else - o.setValue(stmt.getString(s)); - break; - case Types.DATE: - if (i > 0) - o.setValue(stmt.getDate(i)); - else - o.setValue(stmt.getDate(s)); - break; - case Types.DECIMAL: - case Types.NUMERIC: - if (i > 0) - o.setValue(stmt.getBigDecimal(i)); - else - o.setValue(stmt.getBigDecimal(s)); - break; - case Types.DOUBLE: - if (i > 0) - o.setValue(stmt.getDouble(i)); - else - o.setValue(stmt.getDouble(s)); - break; - case Types.FLOAT: - case Types.REAL: - if (i > 0) - o.setValue(stmt.getFloat(i)); - else - o.setValue(stmt.getFloat(s)); - break; - case Types.INTEGER: - case Types.BIT: - if (i > 0) - o.setValue(stmt.getInt(i)); - else - o.setValue(stmt.getInt(s)); - break; - case Types.SMALLINT: - case Types.TINYINT: - if (i > 0) - o.setValue(stmt.getShort(i)); - else - o.setValue(stmt.getShort(s)); - break; - case Types.TIME: - if (i > 0) - o.setValue(stmt.getTime(i)); - else - o.setValue(stmt.getTime(s)); - break; - case Types.TIMESTAMP: - if (i > 0) - o.setValue(stmt.getTimestamp(i)); - else - o.setValue(stmt.getTimestamp(s)); - break; - default: - try { - if (i > 0) - o.setValue((Serializable)stmt.getObject(i)); - else - o.setValue((Serializable)stmt.getObject(s)); - } catch (Throwable t) {} - break; - } - } - - /************************************************************************* - * Get next number for Key column = 0 is Error. - * @ejb.interface-method view-type="both" - * - * @param AD_Client_ID client - * @param TableName table name - * @param trxName optional Transaction Name - * @return next no - */ - public int getNextID (int AD_Client_ID, String TableName, String trxName) - { - if (trxName != null) { - if (Trx.get(trxName, false) == null) { - throw new RuntimeException("Transaction lost - " + trxName); - } - } - int retValue = DB.getNextID (AD_Client_ID, TableName, trxName); - log.finer("[" + m_no + "] " + TableName + " = " + retValue); - m_nextSeqCount++; - return retValue; - } // getNextID - - /** - * Get Document No from table - * @ejb.interface-method view-type="both" - * - * @param AD_Client_ID client - * @param TableName table name - * @param trxName optional Transaction Name - * @return document no or null - */ - public String getDocumentNo (int AD_Client_ID, String TableName, String trxName) - { - if (trxName != null) { - if (Trx.get(trxName, false) == null) { - throw new RuntimeException("Transaction lost - " + trxName); - } - } - m_nextSeqCount++; - String dn = MSequence.getDocumentNo (AD_Client_ID, TableName, trxName); - if (dn == null) // try again - dn = MSequence.getDocumentNo (AD_Client_ID, TableName, trxName); - return dn; - } // GetDocumentNo - - /** - * Get Document No from table - * @ejb.interface-method view-type="both" - * - * @param AD_Client_ID client - * @param TableName table name - * @param trxName optional Transaction Name - * @param po - * @return document no or null - */ - public String getDocumentNo (int AD_Client_ID, String TableName, String trxName, PO po) - { - if (trxName != null) { - if (Trx.get(trxName, false) == null) { - throw new RuntimeException("Transaction lost - " + trxName); - } - } - m_nextSeqCount++; - String dn = MSequence.getDocumentNo (AD_Client_ID, TableName, trxName, po); - if (dn == null) // try again - dn = MSequence.getDocumentNo (AD_Client_ID, TableName, trxName, po); - return dn; - } // GetDocumentNo - - /** - * Get Document No based on Document Type - * @ejb.interface-method view-type="both" - * - * @param C_DocType_ID document type - * @param trxName optional Transaction Name - * @return document no or null - */ - public String getDocumentNo (int C_DocType_ID, String trxName, boolean definite) - { - if (trxName != null) { - if (Trx.get(trxName, false) == null) { - throw new RuntimeException("Transaction lost - " + trxName); - } - } - m_nextSeqCount++; - String dn = MSequence.getDocumentNo (C_DocType_ID, trxName, definite); - if (dn == null) // try again - dn = MSequence.getDocumentNo (C_DocType_ID, trxName, definite); - return dn; - } // getDocumentNo - - /** - * Get Document No based on Document Type - * @ejb.interface-method view-type="both" - * - * @param C_DocType_ID document type - * @param trxName optional Transaction Name - * @param po - * @return document no or null - */ - public String getDocumentNo (int C_DocType_ID, String trxName, boolean definite, PO po) - { - if (trxName != null) { - if (Trx.get(trxName, false) == null) { - throw new RuntimeException("Transaction lost - " + trxName); - } - } - m_nextSeqCount++; - String dn = MSequence.getDocumentNo (C_DocType_ID, trxName, definite, po); - if (dn == null) // try again - dn = MSequence.getDocumentNo (C_DocType_ID, trxName, definite, po); - return dn; - } // getDocumentNo - - /************************************************************************* * Process Remote * @ejb.interface-method view-type="both" @@ -577,13 +117,7 @@ public class ServerBean implements SessionBean m_processCount++; // Start Process - String trxName = pi.getTransactionName(); - if (trxName != null) { - if (Trx.get(trxName, false) == null) { - throw new RuntimeException("Transaction lost - " + trxName); - } - } - if (trxName == null) trxName = Trx.createTrxName("ServerPrc"); + String trxName = Trx.createTrxName("ServerPrc"); Trx trx = Trx.get(trxName, true); ProcessUtil.startJavaProcess(ctx, pi, trx); return pi; @@ -607,53 +141,6 @@ public class ServerBean implements SessionBean return pi; } // workflow - /** - * Online Payment from Server - * @ejb.interface-method view-type="both" - * Called from MPayment processOnline - * @param ctx Context - * @param C_Payment_ID payment - * @param C_PaymentProcessor_ID processor - * @param trxName transaction - * @return true if approved - */ - public boolean paymentOnline (Properties ctx, - int C_Payment_ID, int C_PaymentProcessor_ID, String trxName) - { - if (trxName != null) { - if (Trx.get(trxName, false) == null) { - throw new RuntimeException("Transaction lost - " + trxName); - } - } - MPayment payment = new MPayment (ctx, C_Payment_ID, trxName); - MPaymentProcessor mpp = new MPaymentProcessor (ctx, C_PaymentProcessor_ID, null); - log.info ("[" + m_no + "] " + payment + " - " + mpp); - m_paymentCount++; - boolean approved = false; - try - { - PaymentProcessor pp = PaymentProcessor.create(mpp, payment); - if (pp == null) - payment.setErrorMessage("No Payment Processor"); - else - { - approved = pp.processCC (); - if (approved) - payment.setErrorMessage(null); - else - payment.setErrorMessage("From " + payment.getCreditCardName() - + ": " + payment.getR_RespMsg()); - } - } - catch (Exception e) - { - log.log(Level.SEVERE, "", e); - payment.setErrorMessage("Payment Processor Error"); - } - payment.save(); - return approved; - } // paymentOnline - /** * Create EMail from Server (Request User) * @ejb.interface-method view-type="both" @@ -705,7 +192,7 @@ public class ServerBean implements SessionBean /** - * Create EMail from Server (Request User) + * Execute task on server * @ejb.interface-method view-type="both" * @param AD_Task_ID task * @return execution trace @@ -732,113 +219,6 @@ public class ServerBean implements SessionBean return CacheMgt.get().reset(tableName, Record_ID); } // cacheReset - /** - * LOB update - * @ejb.interface-method view-type="both" - * - * @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 (String sql, int displayType, Object value, String trxName, SecurityToken token) - { - validateSecurityToken(token); - - if (sql == null || value == null) - { - log.fine("No sql or data"); - return false; - } - log.fine(sql); - - Trx trx = null; - if (trxName != null && trxName.trim().length() > 0) { - trx = Trx.get(trxName, false); - if ( trx == null) - throw new RuntimeException("Transaction lost - " + trxName); - } - - m_updateLOBCount++; - boolean success = true; - Connection con = trx != null ? trx.getConnection() : DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED); - PreparedStatement pstmt = null; - try - { - pstmt = con.prepareStatement(sql); - if (displayType == DisplayType.TextLong) - pstmt.setString(1, (String)value); - else - pstmt.setBytes(1, (byte[])value); - int no = pstmt.executeUpdate(); - // - } - catch (Exception e) - { - log.log(Level.FINE, sql, e); - success = false; - } - finally - { - DB.close(pstmt); - pstmt = null; - } - - // Success - commit local trx - if (success && trx == null) - { - try - { - con.commit(); - } - catch (Exception e) - { - log.log(Level.SEVERE, "commit" , e); - success = false; - } - finally - { - try { - con.close(); - } catch (SQLException e) { - } - con = null; - } - } - // Error - roll back - if (!success) - { - log.severe ("rollback"); - if ( trx == null) - { - try - { - con.rollback(); - } - catch (Exception ee) - { - log.log(Level.SEVERE, "rollback" , ee); - } - finally - { - try { - con.close(); - } catch (SQLException e) { - } - con = null; - } - } - else - { - trx.rollback(); - } - } - return success; - } // updateLOB - - /************************************************************************** * Describes the instance and its content for debugging purpose * @ejb.interface-method view-type="both" @@ -863,177 +243,21 @@ public class ServerBean implements SessionBean return sb.toString(); } // getStatus - - /** - * Set savepoint - * @ejb.interface-method view-type="both" - * @param trxName - * @param savePointName - * @return true if success, false otherwise - */ - public SavepointVO setSavepoint(String trxName, String savePointName) - { - Trx trx = Trx.get(trxName, false); - if (trx != null) - { - try - { - Savepoint sp = null; - if (savePointName != null) - sp = trx.getConnection().setSavepoint(savePointName); - else - sp = trx.getConnection().setSavepoint(); - return new SavepointVO(sp); - } - catch (SQLException e) - { - throw new RuntimeException(e); - } - } - return null; - } - - /** - * Start remote transaction - * @ejb.interface-method view-type="both" - * @param trxName - */ - public void startTransaction(String trxName) { - Trx trx = Trx.get(trxName, true); - trx.start(); - } - - /** - * Close remote transaction - * @ejb.interface-method view-type="both" - * @param trxName - */ - public void closeTransaction(String trxName) { - Trx trx = Trx.get(trxName, false); - if (trx != null) - trx.close(); - } - - /** - * Commit the named transaction on server - * @ejb.interface-method view-type="both" - * @param trxName - * @return true if success, false otherwise - */ - public boolean commit(String trxName) - { - boolean success = false; - Trx trx = Trx.get(trxName, false); - if (trx != null) - { - try - { - success = trx.commit(true); - } - catch (SQLException e) - { - throw new RuntimeException(e); - } - } - return success; - } - - /** - * Rollback the named transaction on server - * @ejb.interface-method view-type="both" - * @param trxName - * @return true if success, false otherwise - */ - public boolean rollback(String trxName) - { - boolean success = false; - Trx trx = Trx.get(trxName, false); - if (trx != null) - { - try - { - success = trx.rollback(true); - } - catch (SQLException e) - { - throw new RuntimeException(e); - } - } - return success; - } - - /** - * Rollback the named transaction on server - * @ejb.interface-method view-type="both" - * @param trxName - * @return true if success, false otherwise - */ - public boolean rollback(String trxName, SavepointVO savePoint) - { - boolean success = false; - Trx trx = Trx.get(trxName, false); - if (trx != null) - { - try - { - trx.getConnection().rollback(savePoint); - success = true; - } - catch (SQLException e) - { - throw new RuntimeException(e); - } - } - return success; - } - /** * Execute db proces on server * @ejb.interface-method view-type="both" * @param processInfo * @param procedureName - * @param trxName * @return ProcessInfo */ - public ProcessInfo dbProcess(ProcessInfo processInfo, String procedureName, String trxName, SecurityToken token) + public ProcessInfo dbProcess(ProcessInfo processInfo, String procedureName) { - validateSecurityToken(token); - - Trx trx = null; - if (trxName != null) { - trx = Trx.get(trxName, false); - if (trx == null) { - throw new RuntimeException("Transaction lost - " + trxName); - } - } + String trxName = Trx.createTrxName("ServerDBPrc"); + Trx trx = Trx.get(trxName, true); ProcessUtil.startDatabaseProcedure(processInfo, procedureName, trx); return processInfo; } - /** - * Load fields meta data from database - * @ejb.interface-method view-type="both" - * @param gridTabVO - * @return ArrayList - */ - public ArrayList getFields(GridTabVO gridTabVO) - { - //this will load all fields meta data from database - return gridTabVO.getFields(); - } - - /** - * Get table id from ad_table by table name - * @ejb.interface-method view-type="both" - * @ejb.permission unchecked="true" - * @param tableName - * @return tableName - */ - public int getTableID(String tableName) - { - return MTable.getTable_ID(tableName); - } - /** * String Representation * @return info @@ -1129,109 +353,13 @@ public class ServerBean implements SessionBean System.out.println (s); } // dumpSVUID - /** - * Validate security token from client - * @param token - */ - private void validateSecurityToken(SecurityToken token) - { - if (Ini.isServerValidateSecurityToken()) - { - checkCertificate(token); - checkCodeBaseHost(token); - } - } - - /** - * Verify client code is sign with the same certificate as server - * @param token - */ - private void checkCertificate(SecurityToken token) - { - Certificate certs[] = - this.getClass().getProtectionDomain().getCodeSource().getCertificates(); - if (certs != null && certs.length > 0) - { - if (!certs[0].equals(token.getCodeCertificate())) - throw new RuntimeException("Client not signed or not signed with the same certificate"); - } - } - - /** - * Verify client code is loaded from trusted server - * @param token - */ - private void checkCodeBaseHost(SecurityToken token) - { - InetAddress host = null; - try { - host = InetAddress.getLocalHost(); - } catch (UnknownHostException e) { - } - String hostName = null; - String hostAddress = null; - if (host != null) - { - hostName = host.getHostName(); - hostAddress = host.getHostAddress(); - } - else - { - hostName = "localhost"; - hostAddress = "127.0.0.1"; - } - if (!hostName.equals(token.getCodeBaseHost()) && - !hostAddress.equals(token.getCodeBaseHost())) - { - throw new RuntimeException("Client code not originated from server."); - } - } - /** * Print UID of used classes. - * R2.5.1h - -org.compiere.process.ProcessInfo == -static final long serialVersionUID = -1993220053515488725L; - -org.compiere.util.CStatementVO == -static final long serialVersionUID = -3393389471515956399L; - -org.compiere.model.MQuery == -static final long serialVersionUID = 1511402030597166113L; - -org.compiere.model.POInfo == -static final long serialVersionUID = -5976719579744948419L; - -org.compiere.model.POInfoColumn == -static final long serialVersionUID = -3983585608504631958L; - -org.compiere.model.MWindowVO == -static final long serialVersionUID = 3802628212531678981L; - -org.compiere.model.MTabVO == -static final long serialVersionUID = 9160212869277319305L; - -org.compiere.model.MFieldVO == -static final long serialVersionUID = 4385061125114436797L; - -org.compiere.model.MLookupInfo == -static final long serialVersionUID = -7958664359250070233L; - - * - * * @param args ignored + * @param args ignored */ public static void main (String[] args) { dumpSVUID(ProcessInfo.class); - dumpSVUID(CStatementVO.class); - dumpSVUID(MQuery.class); - dumpSVUID(POInfo.class); - dumpSVUID(POInfoColumn.class); - dumpSVUID(GridWindowVO.class); - dumpSVUID(GridTabVO.class); - dumpSVUID(GridFieldVO.class); - dumpSVUID(MLookupInfo.class); } // main } // ServerBean diff --git a/utils/RUN_DBRestore.sh b/utils/RUN_DBRestore.sh index 24a5da7d61..0c986ed431 100644 --- a/utils/RUN_DBRestore.sh +++ b/utils/RUN_DBRestore.sh @@ -16,4 +16,4 @@ read in # globalqss - cruiz - 2007-10-09 - added fourth parameter for postgres(ignored in oracle) sh $ADEMPIERE_DB_PATH/DBRestore.sh system/$ADEMPIERE_DB_SYSTEM $ADEMPIERE_DB_USER $ADEMPIERE_DB_PASSWORD $ADEMPIERE_DB_SYSTEM -sh $ADEMPIERE_HOME/utils/RUN_SignDatabaseBuild.sh > /dev/null 2>&1 \ No newline at end of file +sh $ADEMPIERE_HOME/utils/RUN_SignDatabaseBuild.sh > /dev/null 2>&1 diff --git a/utils/RUN_ImportAdempiere.sh b/utils/RUN_ImportAdempiere.sh index ba85875ac4..5d66ccb444 100644 --- a/utils/RUN_ImportAdempiere.sh +++ b/utils/RUN_ImportAdempiere.sh @@ -26,4 +26,4 @@ read in # globalqss - cruiz - 2007-10-09 - added fourth parameter for postgres(ignored in oracle) sh $ADEMPIERE_DB_PATH/ImportAdempiere.sh $SYSUSER/$ADEMPIERE_DB_SYSTEM $ADEMPIERE_DB_USER $ADEMPIERE_DB_PASSWORD $ADEMPIERE_DB_SYSTEM -sh $ADEMPIERE_HOME/utils/RUN_SignDatabaseBuild.sh > /dev/null 2>&1 \ No newline at end of file +sh $ADEMPIERE_HOME/utils/RUN_SignDatabaseBuild.sh > /dev/null 2>&1 diff --git a/utils/RUN_SignDatabaseBuild.sh b/utils/RUN_SignDatabaseBuild.sh index 0a4bcce721..110108d404 100644 --- a/utils/RUN_SignDatabaseBuild.sh +++ b/utils/RUN_SignDatabaseBuild.sh @@ -15,4 +15,4 @@ echo Sign Database Build echo =================================== CP=$ADEMPIERE_HOME/lib/CInstall.jar:$ADEMPIERE_HOME/lib/Adempiere.jar:$ADEMPIERE_HOME/lib/CCTools.jar:$ADEMPIERE_HOME/lib/oracle.jar:$ADEMPIERE_HOME/lib/derby.jar:$ADEMPIERE_HOME/lib/fyracle.jar:$ADEMPIERE_HOME/lib/jboss.jar:$ADEMPIERE_HOME/lib/postgresql.jar: -$JAVA -classpath $CP -DADEMPIERE_HOME=$ADEMPIERE_HOME org.adempiere.process.SignDatabaseBuild \ No newline at end of file +$JAVA -classpath $CP -DADEMPIERE_HOME=$ADEMPIERE_HOME org.adempiere.process.SignDatabaseBuild diff --git a/utils/myDBcopyTemplate.sh b/utils/myDBcopyTemplate.sh index 839665f626..c73c937400 100644 --- a/utils/myDBcopyTemplate.sh +++ b/utils/myDBcopyTemplate.sh @@ -5,4 +5,4 @@ DATE=`date +%Y%m%d_%H%M%S` mv $ADEMPIERE_HOME/data/ExpDat.jar $ADEMPIERE_HOME/data/ExpDat$DATE.jar echo copy $ADEMPIERE_HOME/data/ExpDat$DATE.jar to backup media -sleep 30 \ No newline at end of file +sleep 30 diff --git a/utils/unix/adempiere_Debian.sh b/utils/unix/adempiere_Debian.sh index a36749972b..4b116ba1a1 100644 --- a/utils/unix/adempiere_Debian.sh +++ b/utils/unix/adempiere_Debian.sh @@ -162,4 +162,4 @@ case "$1" in exit 1 esac -exit 0 \ No newline at end of file +exit 0 diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/AEnv.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/AEnv.java index 42873f958d..17dc13797b 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/AEnv.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/AEnv.java @@ -364,47 +364,7 @@ public final class AEnv log.info("Cached=" + mWindowVO); } } - // try to get from Server when enabled - if (mWindowVO == null && DB.isRemoteObjects() && isServerActive()) - { - log.config("trying server"); - try - { - s_server = CConnection.get().getServer(); - if (s_server != null) - { - mWindowVO = s_server.getWindowVO(Env.getCtx(), WindowNo, AD_Window_ID, AD_Menu_ID); - log.config("from Server: success"); - } - } - catch (RemoteException e) - { - log.log(Level.SEVERE, "(RE)", e); - mWindowVO = null; - s_server = null; - } - catch (Exception e) - { - Throwable tt = e.getCause(); - if (tt != null && tt instanceof InvalidClassException) - log.log(Level.SEVERE, "(Server<>Client class) " + tt); - else if (tt != null && tt instanceof NotSerializableException) - log.log(Level.SEVERE, "Serialization: " + tt.getMessage(), e); - else - log.log(Level.SEVERE, "ex", e); - mWindowVO = null; - s_server = null; - } - catch (Throwable t) - { - log.log(Level.SEVERE, t.toString()); - mWindowVO = null; - s_server = null; - } - if (mWindowVO != null) - s_windows.put(AD_Window_ID, mWindowVO); - } // from Server - + // Create Window Model on Client if (mWindowVO == null) {