+
+
diff --git a/dbPort/documentation.bat b/dbPort/documentation.bat
new file mode 100644
index 0000000000..659c934f80
--- /dev/null
+++ b/dbPort/documentation.bat
@@ -0,0 +1,5 @@
+@Rem API Documentation for Base
+
+call ..\doc\documentation.bat src doc -private
+
+@pause
\ No newline at end of file
diff --git a/dbPort/packages.txt b/dbPort/packages.txt
new file mode 100644
index 0000000000..0efb2bb2e7
--- /dev/null
+++ b/dbPort/packages.txt
@@ -0,0 +1,2 @@
+org.compiere.db
+org.compiere.dbPort
\ No newline at end of file
diff --git a/dbPort/src/org/adempiere/util/GenerateModelJPA.java b/dbPort/src/org/adempiere/util/GenerateModelJPA.java
new file mode 100755
index 0000000000..6b5f0b04f6
--- /dev/null
+++ b/dbPort/src/org/adempiere/util/GenerateModelJPA.java
@@ -0,0 +1,834 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 Adempiere Fundation. 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., *
+ * or via info@adempiere.org or http://www.adempiere.org/license.html *
+ * Enterprise: e-Evolution,SC
+ * Contributor: Victor Perez Juarez
+ *****************************************************************************/
+package org.adempiere.util;
+
+import java.io.*;
+import java.math.*;
+import java.sql.*;
+import java.util.logging.*;
+import org.compiere.*;
+import org.compiere.util.*;
+
+/**
+ * Generate Model Classes extending PO.
+ * Base class for CMP interface - will be extended to create byte code directly
+ *
+ * @author Jorg Janke
+ * @version $Id: GenerateModel.java,v 1.5 2006/07/30 00:54:36 jjanke Exp $
+ */
+public class GenerateModelJPA
+{
+ /**
+ * Generate PO Class
+ * @param AD_Table_ID table id
+ * @param directory directory with \ or / at the end.
+ * @param packageName package name
+ */
+ public GenerateModelJPA (int AD_Table_ID, String directory, String packageName)
+ {
+ // create column access methods
+ StringBuffer mandatory = new StringBuffer();
+ StringBuffer sb = createColumns(AD_Table_ID, mandatory);
+ // add header stuff
+ String tableName = createHeader(AD_Table_ID, sb, mandatory, packageName);
+ // Save it
+ writeToFile (sb, directory + tableName + ".java");
+ } // GenerateModel
+
+ /** File Header */
+ public static final String COPY =
+ "/******************************************************************************\n"
+ +" * Product: Adempiere ERP & CRM Smart Business Solution *\n"
+ +" * Copyright (C) 1999-2006 Adempiere Fundation. All Rights Reserved. *\n"
+ +" * This program is free software; you can redistribute it and/or modify it *\n"
+ +" * under the terms version 2 of the GNU General Public License as published *\n"
+ +" * by the Free Software Foundation. This program is distributed in the hope *\n"
+ +" * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *\n"
+ +" * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *\n"
+ +" * See the GNU General Public License for more details. *\n"
+ +" * You should have received a copy of the GNU General Public License along *\n"
+ +" * with this program; if not, write to the Free Software Foundation, Inc., *\n"
+ //+" * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *\n"
+ //+" * For the text or an alternative of this public license, you may reach us *\n"
+ +" * or via info@adempiere.org or http://www.adempiere.org/license.html *\n"
+ +" * Enterprise: e-Evolution,SC www.e-evolution.com *\n"
+ +" * Contributor: Victor Perez Juarez *\n"
+ +" *****************************************************************************/\n";
+
+ /** Generated on */
+ private Timestamp s_run = new Timestamp(System.currentTimeMillis());
+
+ /** Logger */
+ private static CLogger log = CLogger.getCLogger (GenerateModelJPA.class);
+
+ /**
+ * Add Header info to buffer
+ * @param AD_Table_ID table
+ * @param sb buffer
+ * @param mandatory init call for mandatory columns
+ * @param packageName package name
+ * @return class name
+ */
+ private String createHeader (int AD_Table_ID, StringBuffer sb, StringBuffer mandatory, String packageName)
+ {
+ String tableName = "";
+ int accessLevel = 0;
+ String sql = "SELECT TableName, AccessLevel FROM AD_Table WHERE AD_Table_ID=?";
+ PreparedStatement pstmt = null;
+ try
+ {
+ pstmt = DB.prepareStatement(sql, null);
+ pstmt.setInt(1, AD_Table_ID);
+ ResultSet rs = pstmt.executeQuery();
+ if (rs.next())
+ {
+ tableName = rs.getString(1);
+ accessLevel = rs.getInt(2);
+ }
+ rs.close();
+ pstmt.close();
+ pstmt = null;
+ }
+ catch (Exception e)
+ {
+ log.log(Level.SEVERE, sql, e);
+ }
+ finally
+ {
+ try
+ {
+ if (pstmt != null)
+ pstmt.close ();
+ }
+ catch (Exception e)
+ {}
+ pstmt = null;
+ }
+ if (tableName == null)
+ throw new RuntimeException ("TableName not found for ID=" + AD_Table_ID);
+ //
+ String accessLevelInfo = accessLevel + " ";
+ if (accessLevel >= 4 )
+ accessLevelInfo += "- System ";
+ if (accessLevel == 2 || accessLevel == 3 || accessLevel == 6 || accessLevel == 7)
+ accessLevelInfo += "- Client ";
+ if (accessLevel == 1 || accessLevel == 3 || accessLevel == 5 || accessLevel == 7)
+ accessLevelInfo += "- Org ";
+
+ String keyColumn = tableName + "_ID";
+ //String className = "X_" + tableName;
+ String className = "" + tableName;
+ //
+ StringBuffer start = new StringBuffer ()
+ .append (COPY)
+ .append ("package " + packageName + ";\n"
+ + "/** Generated Model JPA - DO NOT CHANGE */\n");
+ if (!packageName.equals("org.adempiere.model"))
+ start.append("import org.adempiere.model.*;");
+ start.append("import java.util.*;"
+ + "import java.sql.*;"
+ + "import java.math.*;"
+ + "import javax.persistence.*;"
+ + "import org.compiere.util.*;"
+ + "import org.adempiere.util.*;"
+ // Class
+ + "/** Generated Model for ").append(tableName).append("\n"
+ + " * @author Victor Perez (generated) \n"
+ + " * @version ").append(Adempiere.MAIN_VERSION).append(" - ").append(s_run).append(" */\n"
+ + " @Entity"
+ + "@Table(name=\""+ tableName +"\")"
+ + "public class ").append(className).append(" extends PO"
+ + " implements java.io.Serializable "
+ + "{"
+ // Standard Constructor
+ + "/** Standard Constructor\n@param ctx context\n@param "
+ + keyColumn + " id\n@param trxName transaction\n*/\n"
+ + "public ").append(className).append(" (Properties ctx, int ").append(keyColumn)
+ .append(", String trxName)"
+ + "{"
+ + "super (ctx, ").append(keyColumn).append(", trxName);"
+ + "/** if (").append(keyColumn).append(" == 0)"
+ + "{").append(mandatory).append("} */\n"
+ + "}" // Constructor End
+ // Short Constructor
+// + "/** Short Constructor */\n"
+// + "public ").append(className).append(" (Properties ctx, int ").append(keyColumn).append(")"
+// + "{"
+// + "this (ctx, ").append(keyColumn).append(", null);"
+// + "}" // Constructor End
+
+ // Load Constructor
+ + "/** Load Constructor \n@param ctx context\n@param rs result set \n@param trxName transaction\n*/\n"
+ + "public ").append(className).append(" (Properties ctx, ResultSet rs, String trxName)"
+ + "{"
+ + "super (ctx, rs, trxName);"
+ + "}" // Load Constructor End
+ //
+ + "/** AD_Table_ID=").append(AD_Table_ID).append(" */\n"
+ + "public static final int Table_ID=").append(AD_Table_ID).append(";\n"
+ //
+ + "/** TableName=").append(tableName).append(" */\n"
+ + "public static final String Table_Name=\"").append(tableName).append("\";\n"
+ + "protected static KeyNamePair Model = new KeyNamePair(").append(AD_Table_ID).append(",\"").append(tableName).append("\");\n"
+ //
+ + "protected BigDecimal accessLevel = new BigDecimal(").append(accessLevel).append(");"
+ + "/** AccessLevel\n@return ").append(accessLevelInfo).append("\n*/\n"
+ + "protected int get_AccessLevel()"
+ + "{"
+ + "return accessLevel.intValue();"
+ + "}"
+ //
+ + "/** Load Meta Data\n@param ctx context\n@return PO Info\n*/\n"
+ + "protected POInfo initPO (Properties ctx)"
+ + "{"
+ + "POInfo poi = POInfo.getPOInfo (ctx, Table_ID);"
+ + "return poi;"
+ + "}" // initPO
+ //
+ + "/** Info\n@return info\n*/\n"
+ + "public String toString()"
+ + "{"
+ + "StringBuffer sb = new StringBuffer (\"").append(className).append("[\")"
+ + ".append(get_ID()).append(\"]\");"
+ + "return sb.toString();"
+ + "}");
+
+ StringBuffer end = new StringBuffer ("}");
+ //
+ sb.insert(0, start);
+ sb.append(end);
+
+ return className;
+ } // createHeader
+
+
+ /**
+ * Create Column access methods
+ * @param AD_Table_ID table
+ * @param mandatory init call for mandatory columns
+ * @return set/get method
+ */
+ private StringBuffer createColumns (int AD_Table_ID, StringBuffer mandatory)
+ {
+ StringBuffer sb = new StringBuffer();
+ String sql = "SELECT c.ColumnName, c.IsUpdateable, c.IsMandatory," // 1..3
+ + " c.AD_Reference_ID, c.AD_Reference_Value_ID, DefaultValue, SeqNo, " // 4..7
+ + " c.FieldLength, c.ValueMin, c.ValueMax, c.VFormat, c.Callout, " // 8..12
+ + " c.Name, c.Description, c.ColumnSQL, c.IsEncrypted "
+ + "FROM AD_Column c "
+ + "WHERE c.AD_Table_ID=?"
+ + " AND c.IsActive='Y'"
+ + " AND c.ColumnName <> 'AD_Client_ID'"
+ + " AND c.ColumnName <> 'AD_Org_ID'"
+ + " AND c.ColumnName <> 'IsActive'"
+ + " AND c.ColumnName NOT LIKE 'Created%'"
+ + " AND c.ColumnName NOT LIKE 'Updated%' "
+ + "ORDER BY c.ColumnName";
+ PreparedStatement pstmt = null;
+ try
+ {
+ pstmt = DB.prepareStatement(sql, null);
+ pstmt.setInt(1, AD_Table_ID);
+ ResultSet rs = pstmt.executeQuery();
+ while (rs.next())
+ {
+ String columnName = rs.getString(1);
+ boolean isUpdateable = "Y".equals(rs.getString(2));
+ boolean isMandatory = "Y".equals(rs.getString(3));
+ int displayType = rs.getInt(4);
+ int AD_Reference_Value_ID = rs.getInt(5);
+ String defaultValue = rs.getString(6);
+ int seqNo = rs.getInt(7);
+ int fieldLength = rs.getInt(8);
+ String ValueMin = rs.getString(9);
+ String ValueMax = rs.getString(10);
+ String VFormat = rs.getString(11);
+ String Callout = rs.getString(12);
+ String Name = rs.getString(13);
+ String Description = rs.getString(14);
+ String ColumnSQL = rs.getString(15);
+ boolean virtualColumn = ColumnSQL != null && ColumnSQL.length() > 0;
+ boolean IsEncrypted = "Y".equals(rs.getString(16));
+ //
+ sb.append("@Column(name=\"" + Name+"\") ");
+ sb.append(createColumnMethods (mandatory,
+ columnName, isUpdateable, isMandatory,
+ displayType, AD_Reference_Value_ID, fieldLength,
+ defaultValue, ValueMin, ValueMax, VFormat,
+ Callout, Name, Description, virtualColumn, IsEncrypted));
+ //
+ if (seqNo == 1)
+ sb.append(createKeyNamePair(columnName, displayType));
+ }
+ rs.close();
+ pstmt.close();
+ pstmt = null;
+ }
+ catch (Exception e)
+ {
+ log.log(Level.SEVERE, sql, e);
+ }
+ finally
+ {
+ try
+ {
+ if (pstmt != null)
+ pstmt.close ();
+ }
+ catch (Exception e)
+ {}
+ pstmt = null;
+ }
+ return sb;
+ } // createColumns
+
+ /**
+ * Create set/get methods for column
+ * @param mandatory init call for mandatory columns
+ * @param columnName column name
+ * @param isUpdateable updateable
+ * @param isMandatory mandatory
+ * @param displayType display type
+ * @param AD_Reference_ID validation reference
+ * @param fieldLength int
+ * @param defaultValue default value
+ * @param ValueMin String
+ * @param ValueMax String
+ * @param VFormat String
+ * @param Callout String
+ * @param Name String
+ * @param Description String
+ * @param virtualColumn virtual column
+ * @param IsEncrypted stored encrypted
+ @return set/get method
+ */
+ private String createColumnMethods (StringBuffer mandatory,
+ String columnName, boolean isUpdateable, boolean isMandatory,
+ int displayType, int AD_Reference_ID, int fieldLength,
+ String defaultValue, String ValueMin, String ValueMax, String VFormat,
+ String Callout, String Name, String Description,
+ boolean virtualColumn, boolean IsEncrypted)
+ {
+ // Clazz
+ Class clazz = DisplayType.getClass(displayType, true);
+ if (defaultValue == null)
+ defaultValue = "";
+ if (DisplayType.isLOB(displayType)) // No length check for LOBs
+ fieldLength = 0;
+
+ // Handle Posted
+ if (columnName.equalsIgnoreCase("Posted")
+ || columnName.equalsIgnoreCase("Processed")
+ || columnName.equalsIgnoreCase("Processing"))
+ {
+ clazz = Boolean.class;
+ AD_Reference_ID = 0;
+ }
+ // Record_ID
+ else if (columnName.equalsIgnoreCase("Record_ID"))
+ {
+ clazz = Integer.class;
+ AD_Reference_ID = 0;
+ }
+ // String Key
+ else if (columnName.equalsIgnoreCase("AD_Language")
+ || columnName.equalsIgnoreCase("EntityType"))
+ {
+ clazz = String.class;
+ }
+ // Data Type
+ String dataType = clazz.getName();
+ dataType = dataType.substring(dataType.lastIndexOf('.')+1);
+ if (dataType.equals("Boolean"))
+ dataType = "boolean";
+ else if (dataType.equals("Integer"))
+ dataType = "int";
+ else if (displayType == DisplayType.Binary)
+ dataType = "byte[]";
+
+
+ StringBuffer sb = new StringBuffer();
+ // ****** Set Comment ******
+ sb.append("/** Set ").append(Name);
+ sb.append(".\n@param ").append(columnName).append(" ");
+ if (Description != null && Description.length() > 0)
+ sb.append(Description);
+ else
+ sb.append(Name);
+ sb.append(" */\n");
+
+ // Set ********
+ String setValue = "set_Value";
+ if (IsEncrypted)
+ setValue = "set_ValueE";
+ // public void setColumn (xxx variable)
+ sb.append("public ");
+ if (!isUpdateable)
+ {
+ setValue = "set_ValueNoCheck";
+ if (IsEncrypted)
+ setValue = "set_ValueNoCheckE";
+ }
+ sb.append("void set").append(columnName).append(" (").append(dataType).append(" ").append(columnName).append(")"
+ + "{");
+ // List Validation
+ if (AD_Reference_ID != 0)
+ {
+ String staticVar = addListValidation (sb, AD_Reference_ID, columnName, !isMandatory);
+ sb.insert(0, staticVar); // first check
+ }
+ // setValue ("ColumnName", xx);
+ if (virtualColumn)
+ {
+ sb.append ("throw new IllegalArgumentException (\"").append(columnName).append(" is virtual column\");");
+ }
+ else if (clazz.equals(Integer.class))
+ {
+ if (columnName.endsWith("_ID"))
+ {
+ if (isMandatory) // check mandatory ID
+ {
+ int firstOK = 1; // Valid ID 0
+ if (columnName.equals("AD_Client_ID") || columnName.equals("AD_Org_ID")
+ || columnName.equals("Record_ID") || columnName.equals("C_DocType_ID")
+ || columnName.equals("Node_ID") || columnName.equals("AD_Role_ID")
+ || columnName.equals("M_AttributeSet_ID") || columnName.equals("M_AttributeSetInstance_ID"))
+ firstOK = 0;
+ sb.append("if (").append (columnName)
+ .append (" < ").append(firstOK).append(") throw new IllegalArgumentException (\"")
+ .append(columnName).append(" is mandatory.\");");
+ }
+ else // set optional _ID to null if 0
+ sb.append("if (").append (columnName).append (" <= 0) ")
+ .append(setValue).append(" (\"").append(columnName).append("\", null); else \n");
+ }
+ sb.append(setValue).append(" (\"").append(columnName).append("\", new Integer(").append(columnName).append("));");
+ }
+ else if (clazz.equals(Boolean.class))
+ sb.append(setValue).append(" (\"").append(columnName).append("\", new Boolean(").append(columnName).append("));");
+ else
+ {
+ if (isMandatory && AD_Reference_ID == 0) // does not apply to int/boolean
+ {
+ sb.append("if (")
+ .append (columnName).append (" == null)"
+ + " throw new IllegalArgumentException (\"")
+ .append(columnName).append(" is mandatory.\");");
+ }
+ // String length check
+ if (clazz.equals(String.class) && fieldLength > 0)
+ {
+ sb.append ("if (");
+ if (!isMandatory)
+ sb.append(columnName).append(" != null && ");
+ sb.append(columnName).append(".length() > ").append(fieldLength)
+ .append("){log.warning(\"Length > ")
+ .append(fieldLength).append(" - truncated\");")
+ .append(columnName).append(" = ")
+ .append(columnName).append(".substring(0,").append(fieldLength-1).append(");}");
+ }
+
+ //
+ sb.append (setValue).append(" (\"").append (columnName).append ("\", ")
+ .append (columnName).append (");");
+ }
+ sb.append("}");
+
+ // Mandatory call in constructor
+ if (isMandatory)
+ {
+ mandatory.append("set").append(columnName).append(" (");
+ if (clazz.equals(Integer.class))
+ mandatory.append("0");
+ else if (clazz.equals(Boolean.class))
+ {
+ if (defaultValue.indexOf('Y') != -1)
+ mandatory.append(true);
+ else
+ mandatory.append("false");
+ }
+ else if (clazz.equals(BigDecimal.class))
+ mandatory.append("Env.ZERO");
+ else if (clazz.equals(Timestamp.class))
+ mandatory.append("new Timestamp(System.currentTimeMillis())");
+ else
+ mandatory.append("null");
+ mandatory.append(");");
+ if (defaultValue.length() > 0)
+ mandatory.append("// ").append(defaultValue).append(Env.NL);
+ }
+
+
+ // ****** Get Comment ******
+ sb.append("/** Get ").append(Name);
+ if (Description != null && Description.length() > 0)
+ sb.append(".\n@return ").append(Description);
+ else
+ sb.append(".\n@return ").append(Name);
+ sb.append(" */\n");
+
+ // Get ********
+ String getValue = "get_Value";
+ if (IsEncrypted)
+ getValue = "get_ValueE";
+ sb.append("public ").append(dataType);
+ if (clazz.equals(Boolean.class))
+ {
+ sb.append(" is");
+ if (columnName.toLowerCase().startsWith("is"))
+ sb.append(columnName.substring(2));
+ else
+ sb.append(columnName);
+ }
+ else
+ sb.append(" get").append(columnName);
+ sb.append("() {");
+ if (clazz.equals(Integer.class))
+ sb.append("Integer ii = (Integer)")
+ .append(getValue).append("(\"").append(columnName).append("\");"
+ + "if (ii == null)"
+ + " return 0;"
+ + "return ii.intValue();");
+ else if (clazz.equals(BigDecimal.class))
+ sb.append("BigDecimal bd = (BigDecimal)").append(getValue)
+ .append("(\"").append(columnName).append("\");"
+ + "if (bd == null)"
+ + " return Env.ZERO;"
+ + "return bd;");
+ else if (clazz.equals(Boolean.class))
+ sb.append("Object oo = ").append(getValue)
+ .append("(\"").append(columnName).append("\");"
+ + "if (oo != null) { if (oo instanceof Boolean) return ((Boolean)oo).booleanValue(); return \"Y\".equals(oo);}"
+ + "return false;");
+ else if (dataType.equals("Object"))
+ sb.append("return ").append(getValue)
+ .append("(\"").append(columnName).append("\");");
+ else
+ sb.append("return (").append(dataType).append(")").append(getValue)
+ .append("(\"").append(columnName).append("\");");
+ sb.append("}");
+ //
+ return sb.toString();
+ } // createColumnMethods
+
+
+ /**
+ * Add List Validation
+ * @param sb buffer - example:
+ if (NextAction.equals("N") || NextAction.equals("F"));
+ else throw new IllegalArgumentException ("NextAction Invalid value - Reference_ID=219 - N - F");
+ * @param AD_Reference_ID reference
+ * @param columnName column
+ * @param nullable the validation must allow null values
+ * @return static parameter - Example:
+ public static final int NEXTACTION_AD_Reference_ID=219;
+ public static final String NEXTACTION_None = "N";
+ public static final String NEXTACTION_FollowUp = "F";
+ */
+ private String addListValidation (StringBuffer sb, int AD_Reference_ID,
+ String columnName, boolean nullable)
+ {
+ StringBuffer retValue = new StringBuffer();
+ retValue.append("\n/** ").append(columnName).append(" AD_Reference_ID=").append(AD_Reference_ID) .append(" */\n")
+ .append("public static final int ").append(columnName.toUpperCase())
+ .append("_AD_Reference_ID=").append(AD_Reference_ID).append(";");
+ //
+ boolean found = false;
+ StringBuffer values = new StringBuffer("Reference_ID=")
+ .append(AD_Reference_ID);
+ StringBuffer statement = new StringBuffer();
+ if (nullable)
+ statement.append("if (").append(columnName).append(" == null");
+ //
+ String sql = "SELECT Value, Name FROM AD_Ref_List WHERE AD_Reference_ID=?";
+ PreparedStatement pstmt = null;
+ try
+ {
+ pstmt = DB.prepareStatement(sql, null);
+ pstmt.setInt(1, AD_Reference_ID);
+ ResultSet rs = pstmt.executeQuery();
+ while (rs.next())
+ {
+ String value = rs.getString(1);
+ values.append(" - ").append(value);
+ if (statement.length() == 0)
+ statement.append("if (").append(columnName)
+ .append(".equals(\"").append(value).append("\")");
+ else
+ statement.append(" || ").append(columnName)
+ .append(".equals(\"").append(value).append("\")");
+ if (!found)
+ {
+ found = true;
+ sb.append("if (")
+ .append (columnName).append (" == null)"
+ + " throw new IllegalArgumentException (\"")
+ .append(columnName).append(" is mandatory\");");
+ }
+ // Name (SmallTalkNotation)
+ String name = rs.getString(2);
+ char[] nameArray = name.toCharArray();
+ StringBuffer nameClean = new StringBuffer();
+ boolean initCap = true;
+ for (int i = 0; i < nameArray.length; i++)
+ {
+ char c = nameArray[i];
+ if (Character.isJavaIdentifierPart(c))
+ {
+ if (initCap)
+ nameClean.append(Character.toUpperCase(c));
+ else
+ nameClean.append(c);
+ initCap = false;
+ }
+ else
+ {
+ if (c == '+')
+ nameClean.append("Plus");
+ else if (c == '-')
+ nameClean.append("_");
+ else if (c == '>')
+ {
+ if (name.indexOf('<') == -1) // ignore
+ nameClean.append("Gt");
+ }
+ else if (c == '<')
+ {
+ if (name.indexOf('>') == -1) // ignore
+ nameClean.append("Le");
+ }
+ else if (c == '!')
+ nameClean.append("Not");
+ else if (c == '=')
+ nameClean.append("Eq");
+ else if (c == '~')
+ nameClean.append("Like");
+ initCap = true;
+ }
+ }
+ retValue.append("/** ").append(name).append(" = ").append(value).append(" */\n");
+ retValue.append("public static final String ").append(columnName.toUpperCase())
+ .append("_").append(nameClean)
+ .append(" = \"").append(value).append("\";");
+ }
+ rs.close();
+ pstmt.close();
+ pstmt = null;
+ }
+ catch (Exception e)
+ {
+ log.log(Level.SEVERE, sql, e);
+ found = false;
+ }
+ finally
+ {
+ try
+ {
+ if (pstmt != null)
+ pstmt.close ();
+ }
+ catch (Exception e)
+ {}
+ pstmt = null;
+ }
+ statement.append(")"
+ + "; "
+ + "else "
+ + "throw new IllegalArgumentException (\"").append(columnName)
+ .append(" Invalid value - \" + ").append(columnName)
+ .append(" + \" - ").append(values).append("\");");
+ //
+ if (found && !columnName.equals("EntityType"))
+ sb.append (statement);
+ return retValue.toString();
+ } // addListValidation
+
+ /**
+ * Create getKeyNamePair() method with first identifier
+ * @param columnName name
+ * * @param displayType int
+ @return method code
+ */
+ private StringBuffer createKeyNamePair (String columnName, int displayType)
+ {
+ String method = "get" + columnName + "()";
+ if (displayType != DisplayType.String)
+ method = "String.valueOf(" + method + ")";
+ StringBuffer sb = new StringBuffer("/** Get Record ID/ColumnName\n@return ID/ColumnName pair\n*/"
+ + "public KeyNamePair getKeyNamePair() "
+ + "{return new KeyNamePair(get_ID(), ").append(method).append(");}");
+ return sb;
+ } // createKeyNamePair
+
+
+ /**************************************************************************
+ * Write to file
+ * @param sb string buffer
+ * @param fileName file name
+ */
+ private void writeToFile (StringBuffer sb, String fileName)
+ {
+ try
+ {
+ File out = new File (fileName);
+ FileWriter fw = new FileWriter (out);
+ for (int i = 0; i < sb.length(); i++)
+ {
+ char c = sb.charAt(i);
+ // after
+ if (c == ';' || c == '}')
+ {
+ fw.write (c);
+ if (sb.substring(i+1).startsWith("//"))
+ fw.write('\t');
+ else
+ fw.write(Env.NL);
+ }
+ // before & after
+ else if (c == '{')
+ {
+ fw.write(Env.NL);
+ fw.write (c);
+ fw.write(Env.NL);
+ }
+ else
+ fw.write (c);
+ }
+ fw.flush ();
+ fw.close ();
+ float size = out.length();
+ size /= 1024;
+ log.info(out.getAbsolutePath() + " - " + size + " kB");
+ }
+ catch (Exception ex)
+ {
+ log.log(Level.SEVERE, fileName, ex);
+ }
+ } // writeToFile
+
+ /**
+ * String representation
+ * @return string representation
+ */
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer ("GenerateModel[")
+ .append("]");
+ return sb.toString();
+ } // toString
+
+
+
+ /**************************************************************************
+ * Generate PO Model Class.
+ *
+ * Example: java GenerateModel.class mydirectory myPackage 'U','A'
+ * would generate entity type User and Application classes into mydirectory.
+ * Without parameters, the default is used:
+ * C:\Adempiere\adempiere-all\extend\src\adempiere\model\ adempiere.model 'U','A'
+ *
+ * @param args directory package entityType
+ * - directory where to save the generated file
+ * - package of the classes to be generated
+ * - entityType to be generated
+ */
+ public static void main (String[] args)
+ {
+ org.compiere.Adempiere.startupEnvironment(true);
+ CLogMgt.setLevel(Level.FINE);
+ // CLogMgt.setLevel(Level.ALL);
+ log.info("Generate Model $Revision: 1.5 $");
+ log.info("----------------------------------");
+ // first parameter
+ String directory = "/app/adempiere/adempiere_branch_3.1.1/dbPort/src/org/adempiere/model/";
+ if (args.length > 0)
+ directory = args[0];
+ if (directory == null || directory.length() == 0)
+ {
+ System.err.println("No Directory");
+ System.exit(1);
+ }
+ log.info("Directory: " + directory);
+
+ // second parameter
+ String packageName = "adempiere.model";
+ if (args.length > 1)
+ packageName = args[1];
+ if (packageName == null || packageName.length() == 0)
+ {
+ System.err.println("No package");
+ System.exit(1);
+ }
+ log.info("Package: " + packageName);
+
+ // third parameter
+ String entityType = "'U','A','D'"; // User, Application
+ if (args.length > 2)
+ entityType = args[2];
+ if (entityType == null || entityType.length() == 0)
+ {
+ System.err.println("No EntityType");
+ System.exit(1);
+ }
+ StringBuffer sql = new StringBuffer("EntityType IN (")
+ .append(entityType).append(")");
+ log.info(sql.toString());
+ log.info("----------------------------------");
+
+ // complete sql
+ sql.insert(0, "SELECT AD_Table_ID "
+ + "FROM AD_Table "
+ + "WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')" // special views
+ + " OR IsView='N')"
+ + " AND TableName NOT LIKE '%_Trl' AND ");
+ sql.append(" ORDER BY TableName");
+
+ //
+ int count = 0;
+ PreparedStatement pstmt = null;
+ try
+ {
+ pstmt = DB.prepareStatement(sql.toString(), null);
+ ResultSet rs = pstmt.executeQuery();
+ while (rs.next())
+ {
+ new GenerateModelJPA(rs.getInt(1), directory, packageName);
+ count++;
+ }
+ rs.close();
+ pstmt.close();
+ pstmt = null;
+ }
+ catch (Exception e)
+ {
+ log.severe("main - " + e);
+ }
+ finally
+ {
+ try
+ {
+ if (pstmt != null)
+ pstmt.close ();
+ }
+ catch (Exception e)
+ {}
+ pstmt = null;
+ }
+ log.info("Generated = " + count);
+
+ } // main
+
+} // GenerateModel
diff --git a/dbPort/src/org/compiere/Adempiere.java b/dbPort/src/org/compiere/Adempiere.java
new file mode 100644
index 0000000000..894a0a30ba
--- /dev/null
+++ b/dbPort/src/org/compiere/Adempiere.java
@@ -0,0 +1,572 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere;
+
+import java.awt.*;
+import java.io.*;
+import java.net.*;
+import java.util.logging.*;
+import javax.jnlp.*;
+import javax.swing.*;
+import org.compiere.db.*;
+import org.compiere.model.*;
+import org.compiere.plaf.*;
+import org.compiere.util.*;
+import com.qoppa.pdf.*;
+
+/**
+ * Adempiere Control Class
+ *
+ * @author Jorg Janke
+ * @version $Id: Adempiere.java,v 1.8 2006/08/11 02:58:14 jjanke Exp $
+ */
+public final class Adempiere
+{
+ /** Timestamp */
+ static public final String ID = "$Id: Adempiere.java,v 1.8 2006/08/11 02:58:14 jjanke Exp $";
+ /** Main Version String */
+ static public final String MAIN_VERSION = "Release 3.1.1";
+ /** Detail Version as date Used for Client/Server */
+ static public final String DATE_VERSION = "2006-08-10";
+ /** Database Version as date Compared with AD_System */
+ static public final String DB_VERSION = "2006-08-10";
+
+ /** Product Name */
+ static public final String NAME = "Adempiere\u00AE";
+ /** URL of Product */
+ static public final String URL = "www.adempiere.org";
+ /** 16*16 Product Image.
+ /** Removing/modifying the Adempiere logo is a violation of the license */
+ static private final String s_File16x16 = "images/AD16.gif";
+ /** 32*32 Product Image.
+ /** Removing/modifying the Adempiere logo is a violation of the license */
+ static private final String s_file32x32 = "images/AD32.gif";
+ /** 100*30 Product Image.
+ /** Removing/modifying the Adempiere logo is a violation of the license */
+ static private final String s_file100x30 = "images/AD10030.png";
+ /** Removing/modifying the Adempiere logo is a violation of the license */
+ static private final String s_file100x30HR = "images/AD10030HR.png";
+ /** 48*15 Product Image.
+ /** Removing/modifying the Adempiere logo is a violation of the license */
+ static private final String s_file48x15 = "images/Adempiere.png";
+ /** Removing/modifying the Adempiere logo is a violation of the license */
+ static private final String s_file48x15HR = "images/AdempiereHR.png";
+ /** Support Email */
+ static private String s_supportEmail = "";
+
+ /** Subtitle */
+ static public final String SUB_TITLE = "The Open Source Profesional ERP,CRM and SCM ";
+ /** Adempiere is a wordwide registered Trademark
+ * - Don't modify this - Program will someday fail unexpectedly */
+ static public final String ADEMPIERE_R = "Adempiere\u00AE";
+ /** Copyright Notice - Don't modify this - Program will someday fail unexpectedly
+ * it also violates the license and you'll be held liable for any damage claims */
+ static public final String COPYRIGHT = "\u00A9 1999-2006 Adempiere \u00AE";
+
+ static private String s_ImplementationVersion = null;
+ static private String s_ImplementationVendor = null;
+
+ static private Image s_image16;
+ static private Image s_image48x15;
+ static private Image s_imageLogo;
+ static private ImageIcon s_imageIcon32;
+ static private ImageIcon s_imageIconLogo;
+
+ /** Logging */
+ private static CLogger log = null;
+
+ /**
+ * Get Product Name
+ * @return Application Name
+ */
+ public static String getName()
+ {
+ return NAME;
+ } // getName
+
+ /**
+ * Get Product Version
+ * @return Application Version
+ */
+ public static String getVersion()
+ {
+ return MAIN_VERSION + " - " + DATE_VERSION;
+ } // getVersion
+
+ /**
+ * Short Summary (Windows)
+ * @return summary
+ */
+ public static String getSum()
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append(NAME).append(" ").append(MAIN_VERSION).append(SUB_TITLE);
+ return sb.toString();
+ } // getSum
+
+ /**
+ * Summary (Windows).
+ * Removing/modifying the Adempiere copyright notice is a violation of the license
+ * Adempiere(tm) Version 2.5.1a_2004-03-15 - Smart ERP & CRM - Copyright (c) 1999-2005 Jorg Janke; Implementation: 2.5.1a 20040417-0243 - (C) 1999-2005 Jorg Janke, Adempiere Inc. USA
+ * @return Summary in Windows character set
+ */
+ public static String getSummary()
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append(NAME).append(" ")
+ .append(MAIN_VERSION).append("_").append(DATE_VERSION)
+ .append(" -").append(SUB_TITLE)
+ .append("- ").append(COPYRIGHT)
+ .append("; Implementation: ").append(getImplementationVersion())
+ .append(" - ").append(getImplementationVendor());
+ return sb.toString();
+ } // getSummary
+
+ /**
+ * Set Package Info
+ */
+ private static void setPackageInfo()
+ {
+ if (s_ImplementationVendor != null)
+ return;
+
+ Package adempierePackage = Package.getPackage("org.compiere");
+ s_ImplementationVendor = adempierePackage.getImplementationVendor();
+ s_ImplementationVersion = adempierePackage.getImplementationVersion();
+ if (s_ImplementationVendor == null)
+ {
+ s_ImplementationVendor = "not supported";
+ s_ImplementationVersion = "unknown";
+ }
+ } // setPackageInfo
+
+ /**
+ * Get Jar Implementation Version
+ * @return Implementation-Version
+ */
+ public static String getImplementationVersion()
+ {
+ if (s_ImplementationVersion == null)
+ setPackageInfo();
+ return s_ImplementationVersion;
+ } // getImplementationVersion
+
+ /**
+ * Get Jar Implementation Vendor
+ * @return Implementation-Vendor
+ */
+ public static String getImplementationVendor()
+ {
+ if (s_ImplementationVendor == null)
+ setPackageInfo();
+ return s_ImplementationVendor;
+ } // getImplementationVendor
+
+ /**
+ * Get Checksum
+ * @return checksum
+ */
+ public static int getCheckSum()
+ {
+ return getSum().hashCode();
+ } // getCheckSum
+
+ /**
+ * Summary in ASCII
+ * @return Summary in ASCII
+ */
+ public static String getSummaryAscii()
+ {
+ String retValue = getSummary();
+ // Registered Trademark
+ retValue = Util.replace(retValue, "\u00AE", "(r)");
+ // Trademark
+ retValue = Util.replace(retValue, "\u2122", "(tm)");
+ // Copyright
+ retValue = Util.replace(retValue, "\u00A9", "(c)");
+ // Cr
+ retValue = Util.replace(retValue, Env.NL, " ");
+ retValue = Util.replace(retValue, "\n", " ");
+ return retValue;
+ } // getSummaryAscii
+
+ /**
+ * Get Java VM Info
+ * @return VM info
+ */
+ public static String getJavaInfo()
+ {
+ return System.getProperty("java.vm.name")
+ + " " + System.getProperty("java.vm.version");
+ } // getJavaInfo
+
+ /**
+ * Get Operating System Info
+ * @return OS info
+ */
+ public static String getOSInfo()
+ {
+ return System.getProperty("os.name") + " "
+ + System.getProperty("os.version") + " "
+ + System.getProperty("sun.os.patch.level");
+ } // getJavaInfo
+
+ /**
+ * Get full URL
+ * @return URL
+ */
+ public static String getURL()
+ {
+ return "http://" + URL;
+ } // getURL
+
+ /**
+ * Get Sub Title
+ * @return Subtitle
+ */
+ public static String getSubtitle()
+ {
+ return SUB_TITLE;
+ } // getSubitle
+
+ /**
+ * Get 16x16 Image.
+ * Removing/modifying the Adempiere logo is a violation of the license
+ * @return Image Icon
+ */
+ public static Image getImage16()
+ {
+ if (s_image16 == null)
+ {
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ URL url = org.compiere.Adempiere.class.getResource(s_File16x16);
+ // System.out.println(url);
+ if (url == null)
+ return null;
+ s_image16 = tk.getImage(url);
+ }
+ return s_image16;
+ } // getImage16
+
+ /**
+ * Get 28*15 Logo Image.
+ * @param hr high resolution
+ * @return Image Icon
+ */
+ public static Image getImageLogoSmall(boolean hr)
+ {
+ if (s_image48x15 == null)
+ {
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ URL url = null;
+ if (hr)
+ url = org.compiere.Adempiere.class.getResource(s_file48x15HR);
+ else
+ url = org.compiere.Adempiere.class.getResource(s_file48x15);
+ // System.out.println(url);
+ if (url == null)
+ return null;
+ s_image48x15 = tk.getImage(url);
+ }
+ return s_image48x15;
+ } // getImageLogoSmall
+
+ /**
+ * Get Logo Image.
+ * @return Image Logo
+ */
+ public static Image getImageLogo()
+ {
+ if (s_imageLogo == null)
+ {
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ URL url = org.compiere.Adempiere.class.getResource(s_file100x30);
+ // System.out.println(url);
+ if (url == null)
+ return null;
+ s_imageLogo = tk.getImage(url);
+ }
+ return s_imageLogo;
+ } // getImageLogo
+
+ /**
+ * Get 32x32 ImageIcon.
+ * Removing/modifying the Adempiere logo is a violation of the license
+ * @return Image Icon
+ */
+ public static ImageIcon getImageIcon32()
+ {
+ if (s_imageIcon32 == null)
+ {
+ URL url = org.compiere.Adempiere.class.getResource(s_file32x32);
+ // System.out.println(url);
+ if (url == null)
+ return null;
+ s_imageIcon32 = new ImageIcon(url);
+ }
+ return s_imageIcon32;
+ } // getImageIcon32
+
+ /**
+ * Get 100x30 ImageIcon.
+ * Removing/modifying the Adempiere logo is a violation of the license
+ * @return Image Icon
+ */
+ public static ImageIcon getImageIconLogo()
+ {
+ if (s_imageIconLogo == null)
+ {
+ URL url = org.compiere.Adempiere.class.getResource(s_file100x30);
+ // System.out.println(url);
+ if (url == null)
+ return null;
+ s_imageIconLogo = new ImageIcon(url);
+ }
+ return s_imageIconLogo;
+ } // getImageIconLogo
+
+ /**
+ * Get default (Home) directory
+ * @return Home directory
+ */
+ public static String getAdempiereHome()
+ {
+ // Try Environment
+ String retValue = Ini.getAdempiereHome();
+ // Look in current Directory
+ if (retValue == null && System.getProperty("user.dir").indexOf("Adempiere") != -1)
+ {
+ retValue = System.getProperty("user.dir");
+ int pos = retValue.indexOf("Adempiere");
+ retValue = retValue.substring(pos+9);
+ }
+ if (retValue == null)
+ retValue = File.separator + "Adempiere";
+ return retValue;
+ } // getHome
+
+ /**
+ * Get Support Email
+ * @return Support mail address
+ */
+ public static String getSupportEMail()
+ {
+ return s_supportEmail;
+ } // getSupportEMail
+
+ /**
+ * Set Support Email
+ * @param email Support mail address
+ */
+ public static void setSupportEMail(String email)
+ {
+ s_supportEmail = email;
+ } // setSupportEMail
+
+ /**
+ * Get JNLP CodeBase
+ * @return code base or null
+ */
+ public static URL getCodeBase()
+ {
+ try
+ {
+ BasicService bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService");
+ URL url = bs.getCodeBase();
+ return url;
+ }
+ catch(UnavailableServiceException ue)
+ {
+ return null;
+ }
+ } // getCodeBase
+
+ /**
+ * Get JNLP CodeBase Host
+ * @return code base or null
+ */
+ public static String getCodeBaseHost()
+ {
+ URL url = getCodeBase();
+ if (url == null)
+ return null;
+ return url.getHost();
+ } // getCodeBase
+
+ /*************************************************************************
+ * Startup Client/Server.
+ * - Print greeting,
+ * - Check Java version and
+ * - load ini parameters
+ * If it is a client, load/set PLAF and exit if error.
+ * If Client, you need to call startupEnvironment explicitly!
+ * For testing call method startupEnvironment
+ * @param isClient true for client
+ * @return successful startup
+ */
+ public static synchronized boolean startup (boolean isClient)
+ {
+ // Already started
+ if (log != null)
+ return true;
+
+ // Check Version
+ if (!Login.isJavaOK(isClient) && isClient)
+ System.exit(1);
+
+ CLogMgt.initialize(isClient);
+ Ini.setClient (isClient); // Ini requires Logging
+ // Init Log
+ log = CLogger.getCLogger(Adempiere.class);
+ // Greeting
+ log.info(getSummaryAscii());
+ // log.info(getAdempiereHome() + " - " + getJavaInfo() + " - " + getOSInfo());
+
+ // Load System environment
+ // EnvLoader.load(Ini.ENV_PREFIX);
+
+ // System properties
+ Ini.loadProperties (false);
+
+ // Set up Log
+ CLogMgt.setLevel(Ini.getProperty(Ini.P_TRACELEVEL));
+ if (isClient && Ini.isPropertyBool(Ini.P_TRACEFILE)
+ && CLogFile.get(false, null, isClient) == null)
+ CLogMgt.addHandler(CLogFile.get (true, Ini.findAdempiereHome(), isClient));
+
+ // Set UI
+ if (isClient)
+ {
+ if (CLogMgt.isLevelAll())
+ log.log(Level.FINEST, System.getProperties().toString());
+ //
+ //begin vpj-cd e-evolution
+ //CompiereTheme.load();
+ AdempiereThemeInnova.load();
+ //end vpj-cd e-evolution
+ AdempierePLAF.setPLAF (null);
+ }
+
+ // Set Default Database Connection from Ini
+ DB.setDBTarget(CConnection.get(getCodeBaseHost()));
+
+ if (isClient) // don't test connection
+ return false; // need to call
+
+ return startupEnvironment(isClient);
+ } // startup
+
+ /**
+ * Startup Adempiere Environment.
+ * Automatically called for Server connections
+ * For testing call this method.
+ * @param isClient true if client connection
+ * @return successful startup
+ */
+ public static boolean startupEnvironment (boolean isClient)
+ {
+ startup(isClient); // returns if already initiated
+ if (!DB.isConnected())
+ {
+ log.severe ("No Database");
+ System.exit(1);
+ }
+ // Initialize main cached Singletons
+ ModelValidationEngine.get();
+ try
+ {
+ MSystem system = MSystem.get(Env.getCtx()); // Initializes Base Context too
+ String className = system.getEncryptionKey();
+ if (className == null || className.length() == 0)
+ {
+ className = System.getProperty(SecureInterface.ADEMPIERE_SECURE);
+ if (className != null && className.length() > 0
+ && !className.equals(SecureInterface.ADEMPIERE_SECURE_DEFAULT))
+ {
+ SecureEngine.init(className); // test it
+ system.setEncryptionKey(className);
+ system.save();
+ }
+ }
+ SecureEngine.init(className);
+
+ //
+ if (isClient)
+ MClient.get(Env.getCtx(),0); // Login Client loaded later
+ else
+ MClient.getAll(Env.getCtx());
+ Document.setKey(system.getSummary());
+ }
+ catch (Exception e)
+ {
+ log.warning("Environment problems: " + e.toString());
+ }
+
+ // Start Workflow Document Manager (in other package) for PO
+ String className = null;
+ try
+ {
+ className = "org.compiere.wf.DocWorkflowManager";
+ Class.forName(className);
+ // Initialize Archive Engine
+ className = "org.compiere.print.ArchiveEngine";
+ Class.forName(className);
+ }
+ catch (Exception e)
+ {
+ log.warning("Not started: " + className + " - " + e.getMessage());
+ }
+
+ if (!isClient)
+ DB.updateMail();
+ return true;
+ } // startupEnvironment
+
+
+ /**
+ * Main Method
+ *
+ * @param args optional start class
+ */
+ public static void main (String[] args)
+ {
+ Splash.getSplash();
+ startup(true); // error exit and initUI
+
+ // Start with class as argument - or if nothing provided with Client
+ String className = "org.compiere.apps.AMenu";
+ for (int i = 0; i < args.length; i++)
+ {
+ if (!args[i].equals("-debug")) // ignore -debug
+ {
+ className = args[i];
+ break;
+ }
+ }
+ //
+ try
+ {
+ Class startClass = Class.forName(className);
+ startClass.newInstance();
+ }
+ catch (Exception e)
+ {
+ System.err.println("Adempiere starting: " + className + " - " + e.toString());
+ e.printStackTrace();
+ }
+ } // main
+} // Adempiere
diff --git a/dbPort/src/org/compiere/Adempiere.properties b/dbPort/src/org/compiere/Adempiere.properties
new file mode 100644
index 0000000000..9f2ea5cee5
--- /dev/null
+++ b/dbPort/src/org/compiere/Adempiere.properties
@@ -0,0 +1 @@
+build=sometime
\ No newline at end of file
diff --git a/dbPort/src/org/compiere/db/AdempiereDatabase.java b/dbPort/src/org/compiere/db/AdempiereDatabase.java
new file mode 100644
index 0000000000..33d7e78daa
--- /dev/null
+++ b/dbPort/src/org/compiere/db/AdempiereDatabase.java
@@ -0,0 +1,276 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.math.*;
+import java.sql.*;
+
+import javax.sql.*;
+
+//import org.compiere.util.CPreparedStatement;
+
+/**
+ * Interface for Adempiere Databases
+ *
+ * @author Jorg Janke
+ * @version $Id: AdempiereDatabase.java,v 1.5 2006/09/22 23:35:19 jjanke Exp $
+ */
+public interface AdempiereDatabase
+{
+ /**
+ * Get Database Name
+ * @return database short name
+ */
+ public String getName();
+
+ /**
+ * Get Database Description
+ * @return database long name and version
+ */
+ public String getDescription();
+
+ /**
+ * Get and register Database Driver
+ * @return Driver
+ * @throws SQLException
+ */
+ public Driver getDriver() throws SQLException;
+
+
+ /**
+ * Get Standard JDBC Port
+ * @return standard port
+ */
+ public int getStandardPort();
+
+ /**
+ * Get Database Connection String
+ * @param connection Connection Descriptor
+ * @return connection String
+ */
+ public String getConnectionURL (CConnection connection);
+
+ /**
+ * Get Connection URL
+ * @param dbHost db Host
+ * @param dbPort db Port
+ * @param dbName db Name
+ * @param userName user name
+ * @return url
+ */
+ public String getConnectionURL (String dbHost, int dbPort, String dbName,
+ String userName);
+
+ /**
+ * Get Database Connection String
+ * @param connectionURL Connection URL
+ * @param userName user name
+ * @return connection String
+ */
+ public String getConnectionURL (String connectionURL, String userName);
+
+ /**
+ * Get JDBC Catalog
+ * @return catalog
+ */
+ public String getCatalog();
+
+ /**
+ * Get JDBC Schema
+ * @return schema
+ */
+ public String getSchema();
+
+ /**
+ * Supports BLOB
+ * @return true if BLOB is supported
+ */
+ public boolean supportsBLOB();
+
+ /**
+ * String Representation
+ * @return info
+ */
+ public String toString();
+
+
+ /**************************************************************************
+ * Convert an individual Oracle Style statements to target database statement syntax
+ *
+ * @param oraStatement oracle statement
+ * @return converted Statement
+ */
+ public String convertStatement (String oraStatement);
+
+
+
+ /**
+ * Check if DBMS support the sql statement
+ * @sql SQL statement
+ * @return true: yes
+ */
+ public boolean isSupported(String sql);
+
+
+
+
+ /**
+ * Get constraint type associated with the index
+ * @conn connection
+ * @tableName table name
+ * @IXName Index name
+ * @return String[0] = 0: do not know, 1: Primary Key 2: Foreign Key
+ * String[1] - String[n] = Constraint Name
+ */
+ public String getConstraintType(Connection conn, String tableName, String IXName);
+
+
+ /**
+ * Check and generate an alternative SQL
+ * @reExNo number of re-execution
+ * @msg previous execution error message
+ * @sql previous executed SQL
+ * @return String, the alternative SQL, null if no alternative
+ */
+ public String getAlternativeSQL(int reExNo, String msg, String sql);
+
+ /**
+ * Get Name of System User
+ * @return e.g. sa, system
+ */
+ public String getSystemUser();
+
+ /**
+ * Get Name of System Database
+ * @param databaseName database Name
+ * @return e.g. master or database Name
+ */
+ public String getSystemDatabase(String databaseName);
+
+
+ /**
+ * Create SQL TO Date String from Timestamp
+ *
+ * @param time Date to be converted
+ * @param dayOnly true if time set to 00:00:00
+ * @return date function
+ */
+ public String TO_DATE (Timestamp time, boolean dayOnly);
+
+ /**
+ * Create SQL for formatted Date, Number
+ *
+ * @param columnName the column name in the SQL
+ * @param displayType Display Type
+ * @param AD_Language 6 character language setting (from Env.LANG_*)
+ *
+ * @return TRIM(TO_CHAR(columnName,'9G999G990D00','NLS_NUMERIC_CHARACTERS='',.'''))
+ * or TRIM(TO_CHAR(columnName,'TM9')) depending on DisplayType and Language
+ * @see org.compiere.util.DisplayType
+ * @see org.compiere.util.Env
+ *
+ **/
+ public String TO_CHAR (String columnName, int displayType, String AD_Language);
+
+
+ /**
+ * Return number as string for INSERT statements with correct precision
+ * @param number number
+ * @param displayType display Type
+ * @return number as string
+ */
+ public String TO_NUMBER (BigDecimal number, int displayType);
+
+
+ /** Create User commands */
+ public static final int CMD_CREATE_USER = 0;
+ /** Create Database/Schema Commands */
+ public static final int CMD_CREATE_DATABASE = 1;
+ /** Drop Database/Schema Commands */
+ public static final int CMD_DROP_DATABASE = 2;
+
+ /**
+ * Get SQL Commands.
+ *
+ * The following variables are resolved:
+ * @SystemPassword@, @AdempiereUser@, @AdempierePassword@
+ * @SystemPassword@, @DatabaseName@, @DatabaseDevice@
+ *
+ * @param cmdType CMD_*
+ * @return array of commands to be executed
+ */
+ public String[] getCommands (int cmdType);
+
+
+ /**
+ * Get Cached Connection on Server
+ * @param connection info
+ * @param autoCommit true if autocommit connection
+ * @param transactionIsolation Connection transaction level
+ * @return connection or null
+ * @throws Exception
+ */
+ public Connection getCachedConnection (CConnection connection,
+ boolean autoCommit, int transactionIsolation) throws Exception;
+
+ /**
+ * Get Connection from Driver
+ * @param connection info
+ * @return connection or null
+ * @throws SQLException
+ */
+ public Connection getDriverConnection (CConnection connection) throws SQLException;
+
+ /**
+ * Get Driver Connection
+ * @param dbUrl URL
+ * @param dbUid user
+ * @param dbPwd password
+ * @return connection
+ * @throws SQLException
+ */
+ public Connection getDriverConnection (String dbUrl, String dbUid, String dbPwd)
+ throws SQLException;
+
+ /**
+ * Create DataSource
+ * @param connection connection
+ * @return data dource
+ */
+ public DataSource getDataSource(CConnection connection);
+
+ /**
+ * Get Status
+ * @return status info
+ */
+ public String getStatus();
+
+ /**
+ * Close
+ */
+ public void close();
+
+ /**
+ * Get Data Type
+ * @param DisplayType display type
+ * @return data type
+ */
+// public String getDataType (int displayType, int precision,
+// boolean defaultValue)
+
+} // AdempiereDatabase
+
diff --git a/dbPort/src/org/compiere/db/CConnection.java b/dbPort/src/org/compiere/db/CConnection.java
new file mode 100644
index 0000000000..a981a17b3a
--- /dev/null
+++ b/dbPort/src/org/compiere/db/CConnection.java
@@ -0,0 +1,1660 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.io.*;
+import java.sql.*;
+import java.util.*;
+import java.util.logging.*;
+import javax.naming.*;
+import javax.sql.*;
+import org.compiere.*;
+import org.compiere.interfaces.*;
+import org.compiere.util.*;
+
+/**
+ * Adempiere Connection Descriptor
+ *
+ * @author Jorg Janke
+ * @author Marek Mosiewicz - support for RMI over HTTP
+ * @version $Id: CConnection.java,v 1.5 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class CConnection implements Serializable
+{
+ /** Connection */
+ private static CConnection s_cc = null;
+ /** Logger */
+ private static CLogger log = CLogger.getCLogger (CConnection.class);
+
+ /** Connection profiles */
+ public static ValueNamePair[] CONNECTIONProfiles = new ValueNamePair[]{
+ new ValueNamePair("L", "LAN"),
+ new ValueNamePair("T", "Terminal Server"),
+ new ValueNamePair("V", "VPN"),
+ new ValueNamePair("W", "WAN") };
+
+ /** Connection Profile LAN */
+ public static final String PROFILE_LAN = "L";
+ /** Connection Profile Terminal Server */
+ public static final String PROFILE_TERMINAL = "T";
+ /** Connection Profile VPM */
+ public static final String PROFILE_VPN = "V";
+ /** Connection Profile WAN */
+ public static final String PROFILE_WAN = "W";
+
+ /**
+ * Get/Set default client/server Connection
+ * @return Connection Descriptor
+ */
+ public static CConnection get ()
+ {
+ return get(null);
+ } // get
+
+ /**
+ * Get/Set default client/server Connection
+ * @param apps_host optional apps host for new connections
+ * @return Connection Descriptor
+ */
+ public static CConnection get (String apps_host)
+ {
+ if (s_cc == null)
+ {
+ String attributes = Ini.getProperty (Ini.P_CONNECTION);
+ if (attributes == null || attributes.length () == 0)
+ {
+ CConnectionDialog ccd = new CConnectionDialog (new CConnection(apps_host));
+ s_cc = ccd.getConnection ();
+ // set also in ALogin and Ctrl
+ Ini.setProperty (Ini.P_CONNECTION, s_cc.toStringLong ());
+ Ini.saveProperties (Ini.isClient ());
+ }
+ else
+ {
+ s_cc = new CConnection (null);
+ s_cc.setAttributes (attributes);
+ }
+ log.fine(s_cc.toString());
+ }
+
+ return s_cc;
+ } // get
+
+
+ /**
+ * Get specific connection
+ * @param type database Type, e.g. Database.DB_ORACLE
+ * @param db_host db host
+ * @param db_port db port
+ * @param db_name db name
+ * @return connection
+ */
+ public static CConnection get (String type, String db_host, int db_port, String db_name)
+ {
+ return get (type, db_host, db_port, db_name, null, null);
+ } // get
+
+ /**
+ * Get specific client connection
+ * @param type database Type, e.g. Database.DB_ORACLE
+ * @param db_host db host
+ * @param db_port db port
+ * @param db_name db name
+ * @param db_uid db user id
+ * @param db_pwd db user password
+ * @return connection
+ */
+ public static CConnection get (String type, String db_host, int db_port,
+ String db_name, String db_uid, String db_pwd)
+ {
+ CConnection cc = new CConnection (db_host);
+ cc.setAppsHost (db_host); // set Apps=DB
+ cc.setType (type);
+ cc.setDbHost (db_host);
+ cc.setDbPort (db_port);
+ cc.setDbName (db_name);
+ //
+ if (db_uid != null)
+ cc.setDbUid (db_uid);
+ if (db_pwd != null)
+ cc.setDbPwd (db_pwd);
+ return cc;
+ } // get
+
+
+
+ /**************************************************************************
+ * Adempiere Connection
+ * @param host optional application/db host
+ */
+ private CConnection (String host)
+ {
+ if (host != null)
+ {
+ m_apps_host = host;
+ m_db_host = host;
+ }
+ } // CConnection
+
+ /** Name of Connection */
+ private String m_name = "Standard";
+
+ /** Application Host */
+ private String m_apps_host = "MyAppsServer";
+ /** Application Port */
+ private int m_apps_port = 1099;
+
+ /** Database Type */
+ private String m_type = "";
+
+ /** Database Host */
+ private String m_db_host = "MyDBServer";
+ /** Database Port */
+ private int m_db_port = 0;
+ /** Database name */
+ private String m_db_name = "MyDBName";
+
+ /** Connection Profile */
+ private String m_connectionProfile = null;
+
+ /** In Memory connection */
+ private boolean m_bequeath = false;
+
+ /** Connection uses Firewall */
+ private boolean m_firewall = false;
+ /** Firewall host */
+ private String m_fw_host = "";
+ /** Firewall port */
+ private int m_fw_port = 0;
+
+ /** DB User name */
+ private String m_db_uid = "adempiere";
+ /** DB User password */
+ private String m_db_pwd = "adempiere";
+
+ /** Database */
+ private AdempiereDatabase m_db = null;
+ /** ConnectionException */
+ private Exception m_dbException = null;
+ private Exception m_appsException = null;
+
+ /** Database Connection */
+ private boolean m_okDB = false;
+ /** Apps Server Connection */
+ private boolean m_okApps = false;
+
+ /** Info */
+ private String[] m_info = new String[2];
+
+ /** Server Version */
+ private String m_version = null;
+
+ /** DataSource */
+ private DataSource m_ds = null;
+ /** Server Session */
+ private Server m_server = null;
+ /** DB Info */
+ private String m_dbInfo = null;
+
+
+ /*************************************************************************
+ * Get Name
+ * @return connection name
+ */
+ public String getName ()
+ {
+ return m_name;
+ }
+
+ /**
+ * Set Name
+ * @param name connection name
+ */
+ public void setName (String name)
+ {
+ m_name = name;
+ } // setName
+
+ /**
+ * Set Name
+ */
+ protected void setName ()
+ {
+ m_name = toString ();
+ } // setName
+
+
+ /*************
+ * Get Application Host
+ * @return apps host
+ */
+ public String getAppsHost ()
+ {
+ return m_apps_host;
+ }
+
+ /**
+ * Set Application Host
+ * @param apps_host apps host
+ */
+ public void setAppsHost (String apps_host)
+ {
+ m_apps_host = apps_host;
+ m_name = toString ();
+ m_okApps = false;
+ }
+
+ /**
+ * Get Apps Port
+ * @return port
+ */
+ public int getAppsPort ()
+ {
+ return m_apps_port;
+ }
+
+ /**
+ * Set Apps Port
+ * @param apps_port apps port
+ */
+ public void setAppsPort (int apps_port)
+ {
+ m_apps_port = apps_port;
+ m_okApps = false;
+ }
+
+ /**
+ * Set Apps Port
+ * @param apps_portString appd port as String
+ */
+ public void setAppsPort (String apps_portString)
+ {
+ try
+ {
+ if (apps_portString == null || apps_portString.length() == 0)
+ ;
+ else
+ setAppsPort (Integer.parseInt (apps_portString));
+ }
+ catch (Exception e)
+ {
+ log.severe(e.toString ());
+ }
+ } // setAppsPort
+
+ /**
+ * Is Application Server OK
+ * @param tryContactAgain try to contact again
+ * @return true if Apps Server exists
+ */
+ public boolean isAppsServerOK (boolean tryContactAgain)
+ {
+ if (!tryContactAgain)
+ return m_okApps;
+
+ // Get Context
+ if (m_iContext == null)
+ {
+ getInitialContext (false);
+ if (!m_okApps)
+ return false;
+ }
+
+ // Contact it
+ try
+ {
+ StatusHome statusHome = (StatusHome)m_iContext.lookup (StatusHome.JNDI_NAME);
+ Status status = statusHome.create ();
+ m_version = status.getDateVersion ();
+ status.remove ();
+ m_okApps = true;
+ }
+ catch (Exception ce)
+ {
+ m_okApps = false;
+ }
+ catch (Throwable t)
+ {
+ m_okApps = false;
+ }
+ return m_okApps;
+ } // isAppsOK
+
+ /**
+ * Test ApplicationServer
+ * @return Exception or null
+ */
+ public Exception testAppsServer ()
+ {
+ if (queryAppsServerInfo ())
+ testDatabase (false);
+ return getAppsServerException ();
+ } // testAppsServer
+
+ /**
+ * Get Server
+ * @return Server
+ */
+ public Server getServer()
+ {
+ if (m_server == null)
+ {
+ try
+ {
+ InitialContext ic = getInitialContext (true);
+ if (ic != null)
+ {
+ ServerHome serverHome = (ServerHome)ic.lookup (ServerHome.JNDI_NAME);
+ if (serverHome != null)
+ m_server = serverHome.create();
+ }
+ }
+ catch (Exception ex)
+ {
+ log.log(Level.SEVERE, "", ex);
+ m_iContext = null;
+ }
+ }
+ return m_server;
+ } // getServer
+
+
+ /**
+ * Get Apps Server Version
+ * @return db host name
+ */
+ public String getServerVersion ()
+ {
+ return m_version;
+ } // getServerVersion
+
+
+ /*************
+ * Get Database Host name
+ * @return db host name
+ */
+ public String getDbHost ()
+ {
+ return m_db_host;
+ } // getDbHost
+
+ /**
+ * Set Database host name
+ * @param db_host db host
+ */
+ public void setDbHost (String db_host)
+ {
+ m_db_host = db_host;
+ m_name = toString ();
+ m_okDB = false;
+ } // setDbHost
+
+ /**
+ * Get Database Name (Service Name)
+ * @return db name
+ */
+ public String getDbName ()
+ {
+ return m_db_name;
+ } // getDbName
+
+ /**
+ * Set Database Name (Service Name)
+ * @param db_name db name
+ */
+ public void setDbName (String db_name)
+ {
+ m_db_name = db_name;
+ m_name = toString ();
+ m_okDB = false;
+ } // setDbName
+
+ /**
+ * Get DB Port
+ * @return port
+ */
+ public int getDbPort ()
+ {
+ return m_db_port;
+ } // getDbPort
+
+ /**
+ * Set DB Port
+ * @param db_port db port
+ */
+ public void setDbPort (int db_port)
+ {
+ m_db_port = db_port;
+ m_okDB = false;
+ } // setDbPort
+
+ /**
+ * Set DB Port
+ * @param db_portString db port as String
+ */
+ public void setDbPort (String db_portString)
+ {
+ try
+ {
+ if (db_portString == null || db_portString.length() == 0)
+ ;
+ else
+ setDbPort (Integer.parseInt (db_portString));
+ }
+ catch (Exception e)
+ {
+ log.severe(e.toString ());
+ }
+ } // setDbPort
+
+ /**
+ * Get Database Password
+ * @return db password
+ */
+ public String getDbPwd ()
+ {
+ return m_db_pwd;
+ } // getDbPwd
+
+ /**
+ * Set DB password
+ * @param db_pwd db user password
+ */
+ public void setDbPwd (String db_pwd)
+ {
+ m_db_pwd = db_pwd;
+ m_okDB = false;
+ } // setDbPwd
+
+ /**
+ * Get Database User
+ * @return db user
+ */
+ public String getDbUid ()
+ {
+ return m_db_uid;
+ } // getDbUid
+
+ /**
+ * Set Database User
+ * @param db_uid db user id
+ */
+ public void setDbUid (String db_uid)
+ {
+ m_db_uid = db_uid;
+ m_name = toString ();
+ m_okDB = false;
+ } // setDbUid
+
+ /**
+ * RMI over HTTP
+ * @return true if RMI over HTTP (Wan Connection Profile)
+ */
+ public boolean isRMIoverHTTP ()
+ {
+ return Ini.isClient()
+ && getConnectionProfile().equals(PROFILE_WAN);
+ } // isRMIoverHTTP
+
+ /**
+ * Set Connection Profile
+ * @param connectionProfile connection profile
+ */
+ public void setConnectionProfile (ValueNamePair connectionProfile)
+ {
+ if (connectionProfile != null)
+ setConnectionProfile(connectionProfile.getValue());
+ } // setConnectionProfile
+
+ /**
+ * Set Connection Profile
+ * @param connectionProfile connection profile
+ */
+ public void setConnectionProfile (String connectionProfile)
+ {
+ if (connectionProfile == null
+ || (m_connectionProfile != null
+ && m_connectionProfile.equals(connectionProfile))) // same
+ return;
+
+ if (PROFILE_LAN.equals(connectionProfile)
+ || PROFILE_TERMINAL.equals(connectionProfile)
+ || PROFILE_VPN.equals(connectionProfile)
+ || PROFILE_WAN.equals(connectionProfile))
+ {
+ if (m_connectionProfile != null)
+ {
+ log.config(m_connectionProfile + " -> " + connectionProfile);
+ m_connectionProfile = connectionProfile;
+ Ini.setProperty(Ini.P_CONNECTION, toStringLong());
+ }
+ else
+ m_connectionProfile = connectionProfile;
+ }
+ else
+ log.warning("Invalid: " + connectionProfile);
+ } // setConnectionProfile
+
+ /**
+ * Get Connection Profile
+ * @return connection profile
+ */
+ public String getConnectionProfile ()
+ {
+ if (m_connectionProfile != null)
+ return m_connectionProfile;
+ return PROFILE_LAN;
+ } // getConnectionProfile
+
+ /**
+ * Get Connection Profile Text
+ * @param connectionProfile
+ * @return connection profile text
+ */
+ public String getConnectionProfileText (String connectionProfile)
+ {
+ for (int i = 0; i < CONNECTIONProfiles.length; i++)
+ {
+ if (CONNECTIONProfiles[i].getValue().equals(connectionProfile))
+ return CONNECTIONProfiles[i].getName();
+ }
+ return CONNECTIONProfiles[0].getName();
+ } // getConnectionProfileText
+
+ /**
+ * Get Connection Profile Text
+ * @return connection profile text
+ */
+ public String getConnectionProfileText ()
+ {
+ return getConnectionProfileText(getConnectionProfile());
+ } // getConnectionProfileText
+
+ /**
+ * Get Connection Profile
+ * @return connection profile
+ */
+ public ValueNamePair getConnectionProfilePair ()
+ {
+ for (int i = 0; i < CONNECTIONProfiles.length; i++)
+ {
+ if (CONNECTIONProfiles[i].getValue().equals(getConnectionProfile()))
+ return CONNECTIONProfiles[i];
+ }
+ return CONNECTIONProfiles[0];
+ } // getConnectionProfilePair
+
+ /**
+ * Should objects be created on Server ?
+ * @return true if client and VPN/WAN
+ */
+ public boolean isServerObjects()
+ {
+ return (Ini.isClient()
+ && (getConnectionProfile().equals(PROFILE_VPN)
+ || getConnectionProfile().equals(PROFILE_WAN) ));
+ } // isServerObjects
+
+ /**
+ * Should objects be created on Server ?
+ * @return true if client and Terminal/VPN/WAN
+ */
+ public boolean isServerProcess()
+ {
+ return (Ini.isClient()
+ && (getConnectionProfile().equals(PROFILE_TERMINAL)
+ || getConnectionProfile().equals(PROFILE_VPN)
+ || getConnectionProfile().equals(PROFILE_WAN) ));
+ } // isServerProcess
+
+ /**
+ * Is this a Terminal Server ?
+ * @return true if client and Terminal
+ */
+ public boolean isTerminalServer()
+ {
+ return Ini.isClient() && getConnectionProfile().equals(PROFILE_TERMINAL);
+ } // isTerminalServer
+
+ /**
+ * Is DB via Firewall
+ * @return true if via firewall
+ */
+ public boolean isViaFirewall ()
+ {
+ return m_firewall;
+ }
+
+ /**
+ * Method setViaFirewall
+ * @param viaFirewall boolean
+ */
+ public void setViaFirewall (boolean viaFirewall)
+ {
+ m_firewall = viaFirewall;
+ m_okDB = false;
+ }
+
+ /**
+ * Method setViaFirewall
+ * @param viaFirewallString String
+ */
+ public void setViaFirewall (String viaFirewallString)
+ {
+ try
+ {
+ setViaFirewall (Boolean.valueOf (viaFirewallString).booleanValue ());
+ }
+ catch (Exception e)
+ {
+ log.severe(e.toString ());
+ }
+ }
+
+ /**
+ * Method getFwHost
+ * @return String
+ */
+ public String getFwHost ()
+ {
+ return m_fw_host;
+ }
+
+ /**
+ * Method setFwHost
+ * @param fw_host String
+ */
+ public void setFwHost (String fw_host)
+ {
+ m_fw_host = fw_host;
+ m_okDB = false;
+ }
+
+ /**
+ * Get Firewall port
+ * @return firewall port
+ */
+ public int getFwPort ()
+ {
+ return m_fw_port;
+ }
+
+ /**
+ * Set Firewall port
+ * @param fw_port firewall port
+ */
+ public void setFwPort (int fw_port)
+ {
+ m_fw_port = fw_port;
+ m_okDB = false;
+ }
+
+ /**
+ * Set Firewall port
+ * @param fw_portString firewall port as String
+ */
+ public void setFwPort (String fw_portString)
+ {
+ try
+ {
+ if (fw_portString == null || fw_portString.length() == 0)
+ ;
+ else
+ setFwPort (Integer.parseInt (fw_portString));
+ }
+ catch (Exception e)
+ {
+ log.severe(e.toString ());
+ }
+ }
+
+ /**
+ * Is it a bequeath connection
+ * @return true if bequeath connection
+ */
+ public boolean isBequeath ()
+ {
+ return m_bequeath;
+ }
+
+ /**
+ * Set Bequeath
+ * @param bequeath bequeath connection
+ */
+ public void setBequeath (boolean bequeath)
+ {
+ m_bequeath = bequeath;
+ m_okDB = false;
+ }
+
+ /**
+ * Set Bequeath
+ * @param bequeathString bequeath connection as String (true/false)
+ */
+ public void setBequeath (String bequeathString)
+ {
+ try
+ {
+ setBequeath (Boolean.valueOf (bequeathString).booleanValue ());
+ }
+ catch (Exception e)
+ {
+ log.severe(e.toString ());
+ }
+ } // setBequeath
+
+ /**
+ * Get Database Type
+ * @return database type
+ */
+ public String getType ()
+ {
+ return m_type;
+ }
+
+ /**
+ * Set Database Type and default settings.
+ * Checked against installed databases
+ * @param type database Type, e.g. Database.DB_ORACLE
+ */
+ public void setType (String type)
+ {
+ for (int i = 0; i < Database.DB_NAMES.length; i++)
+ {
+ if (Database.DB_NAMES[i].equals (type))
+ {
+ m_type = type;
+ m_okDB = false;
+ break;
+ }
+ }
+ // Oracle
+ if (isOracle ())
+ {
+ if (getDbPort () != DB_Oracle.DEFAULT_PORT)
+ setDbPort (DB_Oracle.DEFAULT_PORT);
+ setFwPort (DB_Oracle.DEFAULT_CM_PORT);
+ }
+ else
+ {
+ setBequeath (false);
+ setViaFirewall (false);
+ }
+
+ // DB2
+ if (isDB2())
+ {
+ if (getDbPort () != DB_DB2.DEFAULT_PORT)
+ setDbPort (DB_DB2.DEFAULT_PORT);
+ }
+ else if (isDerby())
+ {
+// if (getDbPort () != DB_Derby.DEFAULT_PORT)
+// setDbPort (DB_Derby.DEFAULT_PORT);
+ }
+ // begin vpj-cd e-evolution 09 ene 2006
+ // PostgreSQL
+ if (isPostgreSQL ())
+ {
+ if (getDbPort () != DB_PostgreSQL.DEFAULT_PORT)
+ setDbPort (DB_PostgreSQL.DEFAULT_PORT);
+ }
+ //end vpj-cd e-evolution 09 ene 2006
+ } // setType
+
+ /**
+ * Supports BLOB
+ * @return true if BLOB is supported
+ */
+ public boolean supportsBLOB ()
+ {
+ return m_db.supportsBLOB ();
+ } // supportsBLOB
+
+
+ /**
+ * Is Oracle DB
+ * @return true if Oracle
+ */
+ public boolean isOracle ()
+ {
+ return Database.DB_ORACLE.equals (m_type);
+ } // isOracle
+
+ /**
+ * Is IBM DB/2
+ * @return true if DB/2
+ */
+ public boolean isDB2 ()
+ {
+ return Database.DB_DB2.equals (m_type);
+ } // isDB2
+
+ /**
+ * Is Apache Derby
+ * @return true if Derby
+ */
+ public boolean isDerby ()
+ {
+ return Database.DB_DERBY.equals (m_type);
+ } // isDerby
+
+ /**
+ * Is Microsoft SQL Server
+ * @return true if Derby
+ */
+ public boolean isMSSQLServer()
+ {
+ return Database.DB_MSSQLServer.equals (m_type);
+ } // isMSSQLServer
+
+ //begin e-evolution vpj-cd 30 nov 2005
+ /**
+ * Is PostgreSQL DB
+ * @return true if PostgreSQL
+ */
+// public boolean isEDB ()
+// {
+// return Database.DB_EDB.equals (m_type);
+// } // isPostgreSQL
+ /**
+ * Is PostgreSQL DB
+ * @return true if PostgreSQL
+ */
+ public boolean isPostgreSQL ()
+ {
+ return Database.DB_POSTGRESQL.equals (m_type);
+ } // isPostgreSQL
+ //end
+
+ /**
+ * Is Database Connection OK
+ * @return true if database connection is OK
+ */
+ public boolean isDatabaseOK ()
+ {
+ return m_okDB;
+ } // isDatabaseOK
+
+ /**************************************************************************
+ * Create DB Connection
+ * @return data source != null
+ */
+ public boolean setDataSource()
+ {
+ // System.out.println ("CConnection.setDataSource - " + m_ds + " - Client=" + Ini.isClient());
+ if (m_ds == null && Ini.isClient())
+ {
+ if (getDatabase() != null) // no db selected
+ m_ds = getDatabase().getDataSource(this);
+ // System.out.println ("CConnection.setDataSource - " + m_ds);
+ }
+ return m_ds != null;
+ } // setDataSource
+
+ /**
+ * Set Data Source
+ * @param ds data source
+ * @return data source != null
+ */
+ public boolean setDataSource(DataSource ds)
+ {
+ if (ds == null && m_ds != null)
+ getDatabase().close();
+ m_ds = ds;
+ return m_ds != null;
+ } // setDataSource
+
+ /**
+ * Get Server Connection
+ * @return DataSource
+ */
+ public DataSource getDataSource ()
+ {
+ return m_ds;
+ } // getDataSource
+
+ /**
+ * Has Server Connection
+ * @return true if DataSource exists
+ */
+ public boolean isDataSource ()
+ {
+ return m_ds != null;
+ } // isDataSource
+
+
+ /**************************************************************************
+ * Test Database Connection.
+ * -- Example --
+ * Database: PostgreSQL - 7.1.3
+ * Driver: PostgreSQL Native Driver - PostgreSQL 7.2 JDBC2
+ * -- Example --
+ * Database: Oracle - Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production With the Partitioning option JServer Release 8.1.7.0.0 - Production
+ * Driver: Oracle JDBC driver - 9.0.1.1.0
+ * @param retest
+ * @return Exception or null
+ */
+ public Exception testDatabase(boolean retest)
+ {
+ // At this point Application Server Connection is tested.
+ if (isRMIoverHTTP())
+ return null;
+ if (!retest && m_ds != null && m_okDB)
+ return null;
+
+ if (m_ds != null)
+ getDatabase().close();
+ m_ds = null;
+ setDataSource();
+ // the actual test
+ Connection conn = getConnection (true,
+ Connection.TRANSACTION_READ_COMMITTED);
+ if (conn != null)
+ {
+ try
+ {
+ DatabaseMetaData dbmd = conn.getMetaData ();
+ m_info[0] = "Database=" + dbmd.getDatabaseProductName ()
+ + " - " + dbmd.getDatabaseProductVersion ();
+ m_info[0] = m_info[0].replace ('\n', ' ');
+ m_info[1] = "Driver =" + dbmd.getDriverName ()
+ + " - " + dbmd.getDriverVersion ();
+ if (isDataSource())
+ m_info[1] += " - via DataSource";
+ m_info[1] = m_info[1].replace ('\n', ' ');
+ log.config(m_info[0] + " - " + m_info[1]);
+ conn.close ();
+ }
+ catch (Exception e)
+ {
+ log.severe (e.toString());
+ return e;
+ }
+ }
+ return m_dbException; // from opening
+ } // testDatabase
+
+
+ /*************************************************************************
+ * Short String representation
+ * @return appsHost{dbHost-dbName-uid}
+ */
+ public String toString ()
+ {
+ StringBuffer sb = new StringBuffer (m_apps_host);
+ sb.append ("{").append (m_db_host)
+ .append ("-").append (m_db_name)
+ .append ("-").append (m_db_uid)
+ .append ("}");
+ return sb.toString ();
+ } // toString
+
+ /**
+ * Detail Info
+ * @return info
+ */
+ public String toStringDetail ()
+ {
+ StringBuffer sb = new StringBuffer (m_apps_host);
+ sb.append ("{").append (m_db_host)
+ .append ("-").append (m_db_name)
+ .append ("-").append (m_db_uid)
+ .append ("}");
+ //
+ Connection conn = getConnection (true,
+ Connection.TRANSACTION_READ_COMMITTED);
+ if (conn != null)
+ {
+ try
+ {
+ DatabaseMetaData dbmd = conn.getMetaData ();
+ sb.append("\nDatabase=" + dbmd.getDatabaseProductName ()
+ + " - " + dbmd.getDatabaseProductVersion());
+ sb.append("\nDriver =" + dbmd.getDriverName ()
+ + " - " + dbmd.getDriverVersion ());
+ if (isDataSource())
+ sb.append(" - via DS");
+ conn.close ();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ conn = null;
+ return sb.toString ();
+ } // toStringDetail
+
+ /**
+ * Get DB Version Info
+ * @return info
+ */
+ public String getDBInfo()
+ {
+ if (m_dbInfo != null)
+ return m_dbInfo;
+ StringBuffer sb = new StringBuffer ();
+ Connection conn = getConnection (true,
+ Connection.TRANSACTION_READ_COMMITTED);
+ if (conn != null)
+ {
+ try
+ {
+ DatabaseMetaData dbmd = conn.getMetaData ();
+ sb.append(dbmd.getDatabaseProductVersion())
+ .append(";").append(dbmd.getDriverVersion());
+ if (isDataSource())
+ sb.append(";DS");
+ conn.close ();
+ m_dbInfo = sb.toString ();
+ }
+ catch (Exception e)
+ {
+ log.log(Level.SEVERE, "", e);
+ sb.append(e.getLocalizedMessage());
+ }
+ }
+ conn = null;
+ return sb.toString();
+ } // toStringDetail
+
+
+ /**
+ * String representation.
+ * Used also for Instanciation
+ * @return string representation
+ * @see #setAttributes(String) setAttributes
+ */
+ public String toStringLong ()
+ {
+ StringBuffer sb = new StringBuffer ("CConnection[");
+ 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)
+ .append (",DBname=").append (m_db_name)
+ .append (",BQ=").append (m_bequeath)
+ .append (",FW=").append (m_firewall)
+ .append (",FWhost=").append (m_fw_host)
+ .append (",FWport=").append (m_fw_port)
+ .append (",UID=").append (m_db_uid)
+ .append (",PWD=").append (m_db_pwd)
+ ; // the format is read by setAttributes
+ sb.append ("]");
+ return sb.toString ();
+ } // toStringLong
+
+ /**
+ * Set Attributes from String (pares toStringLong())
+ * @param attributes attributes
+ */
+ private void setAttributes (String attributes)
+ {
+ try
+ {
+ setName (attributes.substring (attributes.indexOf ("name=") + 5, attributes.indexOf (",AppsHost=")));
+ 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=")));
+ setDbPort (attributes.substring (attributes.indexOf ("DBport=") + 7, attributes.indexOf (",DBname=")));
+ setDbName (attributes.substring (attributes.indexOf ("DBname=") + 7, attributes.indexOf (",BQ=")));
+ //
+ setBequeath (attributes.substring (attributes.indexOf ("BQ=") + 3, attributes.indexOf (",FW=")));
+ setViaFirewall (attributes.substring (attributes.indexOf ("FW=") + 3, attributes.indexOf (",FWhost=")));
+ setFwHost (attributes.substring (attributes.indexOf ("FWhost=") + 7, attributes.indexOf (",FWport=")));
+ setFwPort (attributes.substring (attributes.indexOf ("FWport=") + 7, attributes.indexOf (",UID=")));
+ //
+ setDbUid (attributes.substring (attributes.indexOf ("UID=") + 4, attributes.indexOf (",PWD=")));
+ setDbPwd (attributes.substring (attributes.indexOf ("PWD=") + 4, attributes.indexOf ("]")));
+ //
+ }
+ catch (Exception e)
+ {
+ log.severe(attributes + " - " + e.toString ());
+ }
+ } // setAttributes
+
+ /**
+ * Equals
+ * @param o object
+ * @return true if o equals this
+ */
+ public boolean equals (Object o)
+ {
+ if (o instanceof CConnection)
+ {
+ CConnection cc = (CConnection)o;
+ if (cc.getAppsHost().equals (m_apps_host)
+ && 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)
+ && cc.getDbPwd().equals(m_db_pwd))
+ return true;
+ }
+ return false;
+ } // equals
+
+ /**
+ * Get Info.
+ * - Database, Driver, Status Info
+ * @return info
+ */
+ public String getInfo ()
+ {
+ StringBuffer sb = new StringBuffer (m_info[0]);
+ sb.append (" - ").append (m_info[1])
+ .append ("\n").append (getDatabase ().toString ())
+ .append ("\nAppsServerOK=").append (isAppsServerOK (false))
+ .append (", DatabaseOK=").append (isDatabaseOK ());
+ return sb.toString ();
+ } // getInfo
+
+
+ /*************************************************************************
+ * Hashcode
+ * @return hashcode of name
+ */
+ public int hashCode ()
+ {
+ return m_name.hashCode ();
+ } // hashCode
+
+ /**
+ * Get Database
+ * @return database
+ */
+ public AdempiereDatabase getDatabase ()
+ {
+ // different driver
+ if (m_db != null && !m_db.getName ().equals (m_type))
+ m_db = null;
+
+ if (m_db == null)
+ {
+ try
+ {
+ for (int i = 0; i < Database.DB_NAMES.length; i++)
+ {
+ if (Database.DB_NAMES[i].equals (m_type))
+ {
+ m_db = (AdempiereDatabase)Database.DB_CLASSES[i].
+ newInstance ();
+ break;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ log.severe(e.toString ());
+ }
+ }
+ return m_db;
+ } // getDatabase
+
+ /**
+ * Get Connection String
+ * @return connection string
+ */
+ public String getConnectionURL ()
+ {
+ getDatabase (); // updates m_db
+ if (m_db != null)
+ return m_db.getConnectionURL (this);
+ else
+ return "";
+ } // getConnectionURL
+
+ /**
+ * Get Server Connection - do close
+ * @param autoCommit true if autocommit connection
+ * @param trxLevel Connection transaction level
+ * @return Connection
+ */
+ public Connection getServerConnection (boolean autoCommit, int trxLevel)
+ {
+ Connection conn = null;
+ // Server Connection
+ if (m_ds != null)
+ {
+ try
+ {
+ conn = m_ds.getConnection ();
+ conn.setAutoCommit (autoCommit);
+ conn.setTransactionIsolation (trxLevel);
+ m_okDB = true;
+ }
+ catch (SQLException ex)
+ {
+ m_dbException = ex;
+ log.log(Level.SEVERE, "", ex);
+ }
+ }
+
+ // Server
+ return conn;
+ } // getServerConnection
+
+
+ /**
+ * Create Connection - no not close.
+ * Sets m_dbException
+ * @param autoCommit true if autocommit connection
+ * @param transactionIsolation Connection transaction level
+ * @return Connection
+ */
+ public Connection getConnection (boolean autoCommit, int transactionIsolation)
+ {
+ Connection conn = null;
+ m_dbException = null;
+ m_okDB = false;
+ //
+ getDatabase (); // updates m_db
+ if (m_db == null)
+ {
+ m_dbException = new IllegalStateException("No Database Connector");
+ return null;
+ }
+ //
+
+ try
+ {
+ // if (!Ini.isClient() // Server
+ // && trxLevel != Connection.TRANSACTION_READ_COMMITTED) // PO_LOB.save()
+ // {
+ Exception ee = null;
+ try
+ {
+ conn = m_db.getCachedConnection(this, autoCommit, transactionIsolation);
+ }
+ catch (Exception e)
+ {
+ ee = e;
+ }
+ if (conn == null)
+ {
+ Thread.yield();
+ log.config("retrying - " + ee);
+ conn = m_db.getCachedConnection(this, autoCommit, transactionIsolation);
+ }
+ // System.err.println ("CConnection.getConnection(Cache) - " + getConnectionURL() + ", AutoCommit=" + autoCommit + ", TrxLevel=" + trxLevel);
+ // }
+ // else if (isDataSource()) // Client
+ // {
+ // conn = m_ds.getConnection();
+ // System.err.println ("CConnection.getConnection(DataSource) - " + getConnectionURL() + ", AutoCommit=" + autoCommit + ", TrxLevel=" + trxLevel);
+ // }
+ // else
+ // {
+ // conn = m_db.getDriverConnection (this);
+ // System.err.println ("CConnection.getConnection(Driver) - " + getConnectionURL() + ", AutoCommit=" + autoCommit + ", TrxLevel=" + trxLevel);
+ // }
+ // Verify Connection
+ if (conn != null)
+ {
+ if (conn.getTransactionIsolation() != transactionIsolation)
+ conn.setTransactionIsolation (transactionIsolation);
+ if (conn.getAutoCommit() != autoCommit)
+ conn.setAutoCommit (autoCommit);
+ m_okDB = true;
+ }
+ }
+ catch (UnsatisfiedLinkError ule)
+ {
+ String msg = ule.getLocalizedMessage()
+ + " -> Did you set the LD_LIBRARY_PATH ? - " + getConnectionURL();
+ m_dbException = new Exception(msg);
+ log.severe(msg);
+ }
+ catch (SQLException ex)
+ {
+ m_dbException = ex;
+ if (conn == null)
+ log.log(Level.SEVERE, getConnectionURL ()
+ + ", (1) AutoCommit=" + autoCommit + ",TrxIso=" + getTransactionIsolationInfo(transactionIsolation)
+ // + " (" + getDbUid() + "/" + getDbPwd() + ")"
+ + " - " + ex.getMessage());
+ else
+ {
+ try
+ {
+ log.severe(getConnectionURL ()
+ + ", (2) AutoCommit=" + conn.getAutoCommit() + "->" + autoCommit
+ + ", TrxIso=" + getTransactionIsolationInfo(conn.getTransactionIsolation()) + "->" + getTransactionIsolationInfo(transactionIsolation)
+ // + " (" + getDbUid() + "/" + getDbPwd() + ")"
+ + " - " + ex.getMessage());
+ }
+ catch (Exception ee)
+ {
+ log.severe(getConnectionURL ()
+ + ", (3) AutoCommit=" + autoCommit + ", TrxIso=" + getTransactionIsolationInfo(transactionIsolation)
+ // + " (" + getDbUid() + "/" + getDbPwd() + ")"
+ + " - " + ex.getMessage());
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ m_dbException = ex;
+ log.log(Level.SEVERE, getConnectionURL(), ex);
+ }
+ // System.err.println ("CConnection.getConnection - " + conn);
+ return conn;
+ } // getConnection
+
+ /**
+ * Get Database Exception of last connection attempt
+ * @return Exception or null
+ */
+ public Exception getDatabaseException ()
+ {
+ return m_dbException;
+ } // getConnectionException
+
+ /*************************************************************************/
+
+ private InitialContext m_iContext = null;
+ private Hashtable m_env = null;
+
+ /**
+ * Get Application Server Initial Context
+ * @param useCache if true, use existing cache
+ * @return Initial Context or null
+ */
+ public InitialContext getInitialContext (boolean useCache)
+ {
+ if (useCache && m_iContext != null)
+ return m_iContext;
+
+ // Set Environment
+ if (m_env == null || !useCache)
+ m_env = getInitialEnvironment(getAppsHost(), getAppsPort(), isRMIoverHTTP());
+ String connect = (String)m_env.get(Context.PROVIDER_URL);
+ Env.setContext(Env.getCtx(), Context.PROVIDER_URL, connect);
+
+ // Get Context
+ m_iContext = null;
+ try
+ {
+ m_iContext = new InitialContext (m_env);
+ }
+ catch (Exception ex)
+ {
+ m_okApps = false;
+ m_appsException = ex;
+ if (connect == null)
+ connect = (String)m_env.get(Context.PROVIDER_URL);
+ log.severe(connect
+ + "\n - " + ex.toString ()
+ + "\n - " + m_env);
+ if (CLogMgt.isLevelFinest())
+ ex.printStackTrace();
+ }
+ return m_iContext;
+ } // getInitialContext
+
+ /**
+ * Get Initial Environment
+ * @param AppsHost host
+ * @param AppsPort port
+ * @param RMIoverHTTP true if tunnel through HTTP
+ * @return environment
+ */
+ public static Hashtable getInitialEnvironment (String AppsHost, int AppsPort,
+ boolean RMIoverHTTP)
+ {
+ // 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);
+ }
+ 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
+ env.put (org.jnp.interfaces.TimedSocketFactory.JNP_SO_TIMEOUT, "5000");
+ // JNP - default timeout 5 sec
+ env.put(org.jnp.interfaces.NamingContext.JNP_DISCOVERY_TIMEOUT, "5000");
+ return env;
+ } // getInitialEnvironment
+
+ /**
+ * Get Initial Context
+ * @param env environment
+ * @return Initial Context
+ */
+ public static InitialContext getInitialContext (Hashtable env)
+ {
+ InitialContext iContext = null;
+ try
+ {
+ iContext = new InitialContext (env);
+ }
+ catch (Exception ex)
+ {
+ log.warning ("URL=" + env.get(Context.PROVIDER_URL)
+ + "\n - " + ex.toString ()
+ + "\n - " + env);
+ iContext = null;
+ if (CLogMgt.isLevelFinest())
+ ex.printStackTrace();
+ }
+ return iContext;
+ } // getInitialContext
+
+
+ /**
+ * Query Application Server Status.
+ * update okApps
+ * @return true ik OK
+ */
+ private boolean queryAppsServerInfo ()
+ {
+ log.finer(getAppsHost());
+ long start = System.currentTimeMillis();
+ m_okApps = false;
+ m_appsException = null;
+ //
+ getInitialContext (false);
+ if (m_iContext == null)
+ return m_okApps; // false
+
+ // Carlos Ruiz - globalqss - speed up when jnp://MyAppsServer:1099 is set
+ if (getAppsHost().equalsIgnoreCase("MyAppsServer")) {
+ log.warning (getAppsHost() + " ignored");
+ return m_okApps; // false
+ }
+
+ // Prevent error trace
+ // CLogMgtLog4J.enable(false);
+ try
+ {
+ StatusHome statusHome = (StatusHome)m_iContext.lookup (StatusHome.JNDI_NAME);
+ Status status = statusHome.create ();
+ //
+ updateInfoFromServer(status);
+ //
+ status.remove ();
+ m_okApps = true;
+ }
+ catch (CommunicationException ce) // not a "real" error
+ {
+ // m_appsException = ce;
+ String connect = (String)m_env.get(Context.PROVIDER_URL);
+ log.warning (connect
+ + "\n - " + ce.toString ()
+ + "\n - " + m_env);
+ }
+ catch (Exception e)
+ {
+ m_appsException = e;
+ String connect = (String)m_env.get(Context.PROVIDER_URL);
+ log.warning (connect
+ + "\n - " + e.toString ()
+ + "\n - " + m_env);
+ }
+ CLogMgtLog4J.enable(true);
+ log.fine("Success=" + m_okApps + " - " + (System.currentTimeMillis()-start) + "ms");
+ return m_okApps;
+ } // setAppsServerInfo
+
+ /**
+ * Get Last Exception of Apps Server Connection attempt
+ * @return Exception or null
+ */
+ public Exception getAppsServerException ()
+ {
+ return m_appsException;
+ } // getAppsServerException
+
+ /**
+ * Update Connection Info from Apps Server
+ * @param svr Apps Server Status
+ * @throws Exception
+ */
+ private void updateInfoFromServer (Status svr) throws Exception
+ {
+ if (svr == null)
+ throw new IllegalArgumentException ("AppsServer was NULL");
+
+ setType (svr.getDbType());
+ setDbHost (svr.getDbHost());
+ setDbPort (svr.getDbPort ());
+ setDbName (svr.getDbName ());
+ setDbUid (svr.getDbUid ());
+ setDbPwd (svr.getDbPwd ());
+ setBequeath (false);
+ //
+ setFwHost (svr.getFwHost ());
+ setFwPort (svr.getFwPort ());
+ if (getFwHost ().length () == 0)
+ setViaFirewall (false);
+ m_version = svr.getDateVersion ();
+ log.config("Server=" + getDbHost() + ", DB=" + getDbName());
+ } // update Info
+
+ /**
+ * Convert Statement
+ * @param origStatement original statement (Oracle notation)
+ * @return converted Statement
+ * @throws Exception
+ */
+ public String convertStatement (String origStatement)
+ throws Exception
+ {
+ // make sure we have a good database
+ if (m_db != null && !m_db.getName ().equals (m_type))
+ getDatabase ();
+ if (m_db != null)
+ return m_db.convertStatement (origStatement);
+ throw new Exception (
+ "CConnection.convertStatement - No Converstion Database");
+ } // convertStatement
+
+ /**
+ * Get Status Info
+ * @return info
+ */
+ public String getStatus()
+ {
+ StringBuffer sb = new StringBuffer (m_apps_host);
+ sb.append ("{").append (m_db_host)
+ .append ("-").append (m_db_name)
+ .append ("-").append (m_db_uid)
+ .append ("}");
+ if (m_db != null)
+ sb.append (m_db.getStatus());
+ return sb.toString ();
+ } // getStatus
+
+ /**
+ * Get Transaction Isolation Info
+ * @param transactionIsolation trx iso
+ * @return clear test
+ */
+ public static String getTransactionIsolationInfo(int transactionIsolation)
+ {
+ if (transactionIsolation == Connection.TRANSACTION_NONE)
+ return "NONE";
+ if (transactionIsolation == Connection.TRANSACTION_READ_COMMITTED)
+ return "READ_COMMITTED";
+ if (transactionIsolation == Connection.TRANSACTION_READ_UNCOMMITTED)
+ return "READ_UNCOMMITTED";
+ if (transactionIsolation == Connection.TRANSACTION_REPEATABLE_READ)
+ return "REPEATABLE_READ";
+ if (transactionIsolation == Connection.TRANSACTION_READ_COMMITTED)
+ return "SERIALIZABLE";
+ return "" + transactionIsolation + "?>";
+ } // getTransactionIsolationInfo
+
+
+ /**************************************************************************
+ * Testing
+ * @param args ignored
+ */
+ public static void main (String[] args)
+ {
+ boolean server = true;
+ if (args.length == 0)
+ System.out.println("CConnection ");
+ else
+ server = "server".equals(args[0]);
+ System.out.println("CConnection - " + (server ? "server" : "client"));
+ //
+ if (server)
+ {
+ Adempiere.startup(false);
+ }
+ else
+ Adempiere.startup(true);
+ //
+ System.out.println ("Connection = ");
+ // CConnection[name=localhost{dev-dev1-adempiere},AppsHost=localhost,AppsPort=1099,type=Oracle,DBhost=dev,DBport=1521,DBname=dev1,BQ=false,FW=false,FWhost=,FWport=1630,UID=adempiere,PWD=adempiere]
+ System.out.println (Ini.getProperty (Ini.P_CONNECTION));
+
+ CConnection cc = CConnection.get ();
+ System.out.println (">> " + cc.toStringLong ());
+ Connection con = cc.getConnection (false,
+ Connection.TRANSACTION_READ_COMMITTED);
+ new CConnectionDialog(cc);
+ } // main
+
+} // CConnection
diff --git a/dbPort/src/org/compiere/db/CConnectionDialog.java b/dbPort/src/org/compiere/db/CConnectionDialog.java
new file mode 100644
index 0000000000..aba7f85942
--- /dev/null
+++ b/dbPort/src/org/compiere/db/CConnectionDialog.java
@@ -0,0 +1,513 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+import java.util.logging.*;
+import javax.swing.*;
+import org.compiere.plaf.*;
+import org.compiere.swing.*;
+import org.compiere.util.*;
+
+/**
+ * Connection Dialog.
+ *
+ * @author Jorg Janke
+ * @author Marek Mosiewicz - support for RMI over HTTP
+ * @version $Id: CConnectionDialog.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class CConnectionDialog extends CDialog implements ActionListener
+{
+ /**
+ * Connection Dialog using current Connection
+ */
+ public CConnectionDialog()
+ {
+ this (null);
+ } // CConnectionDialog
+
+ /**
+ * Connection Dialog
+ * @param cc Adempiere Connection
+ */
+ public CConnectionDialog(CConnection cc)
+ {
+ super((Frame)null, true);
+ try
+ {
+ jbInit();
+ setConnection (cc);
+ }
+ catch(Exception e)
+ {
+ log.log(Level.SEVERE, "", e);
+ }
+ AdempierePLAF.showCenterScreen(this);
+ } // CConnection
+
+ /** Resources */
+ private static ResourceBundle res = ResourceBundle.getBundle("org.compiere.db.DBRes");
+
+ static
+ {
+ /** Connection Profiles */
+ CConnection.CONNECTIONProfiles = new ValueNamePair[]{
+ new ValueNamePair("L", res.getString("LAN")),
+ new ValueNamePair("T", res.getString("TerminalServer")),
+ new ValueNamePair("V", res.getString("VPN")),
+ new ValueNamePair("W", res.getString("WAN"))
+ };
+ }
+
+ /** Default HTTP Port */
+ public static final String APPS_PORT_HTTP = "80";
+ /** Default RMI Port */
+ public static final String APPS_PORT_JNP = "1099";
+ /** Connection */
+ private CConnection m_cc = null;
+ private CConnection m_ccResult = null;
+ private boolean m_updating = false;
+ private boolean m_saved = false;
+
+ /** Logger */
+ private static CLogger log = CLogger.getCLogger (CConnectionDialog.class);
+
+ private CPanel mainPanel = new CPanel();
+ private BorderLayout mainLayout = new BorderLayout();
+ private CPanel centerPanel = new CPanel();
+ private CPanel southPanel = new CPanel();
+ private CButton bOK = AdempierePLAF.getOKButton();
+ private CButton bCancel = AdempierePLAF.getCancelButton();
+ private FlowLayout southLayout = new FlowLayout();
+ private GridBagLayout centerLayout = new GridBagLayout();
+ private CLabel nameLabel = new CLabel();
+ private CTextField nameField = new CTextField();
+ private CLabel hostLabel = new CLabel();
+ private CTextField hostField = new CTextField();
+ private CLabel portLabel = new CLabel();
+ private CTextField dbPortField = new CTextField();
+ private CLabel sidLabel = new CLabel();
+ private CTextField sidField = new CTextField();
+ private CCheckBox cbFirewall = new CCheckBox();
+ private CLabel fwHostLabel = new CLabel();
+ private CTextField fwHostField = new CTextField();
+ private CLabel fwPortLabel = new CLabel();
+ private CTextField fwPortField = new CTextField();
+ private CButton bTestDB = new CButton();
+ private CLabel dbTypeLabel = new CLabel();
+ private CComboBox dbTypeField = new CComboBox(Database.DB_NAMES);
+ private CCheckBox cbBequeath = new CCheckBox();
+ private CLabel appsHostLabel = new CLabel();
+ private CTextField appsHostField = new CTextField();
+ private CLabel appsPortLabel = new CLabel();
+ private CTextField appsPortField = new CTextField();
+ private CButton bTestApps = new CButton();
+ private CCheckBox cbOverwrite = new CCheckBox();
+ 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);
+
+
+ /**
+ * Static Layout
+ * @throws Exception
+ */
+ private void jbInit() throws Exception
+ {
+ this.setTitle(res.getString("CConnectionDialog"));
+ mainPanel.setLayout(mainLayout);
+ southPanel.setLayout(southLayout);
+ southLayout.setAlignment(FlowLayout.RIGHT);
+ centerPanel.setLayout(centerLayout);
+ nameLabel.setText(res.getString("Name"));
+ nameField.setColumns(30);
+ nameField.setReadWrite(false);
+ hostLabel.setText(res.getString("DBHost"));
+ hostField.setColumns(30);
+ portLabel.setText(res.getString("DBPort"));
+ dbPortField.setColumns(10);
+ sidLabel.setText(res.getString("DBName"));
+ cbFirewall.setToolTipText("");
+ cbFirewall.setText(res.getString("ViaFirewall"));
+ fwHostLabel.setText(res.getString("FWHost"));
+ fwHostField.setColumns(30);
+ fwPortLabel.setText(res.getString("FWPort"));
+ bTestDB.setText(res.getString("TestConnection"));
+ bTestDB.setHorizontalAlignment(JLabel.LEFT);
+ dbTypeLabel.setText(res.getString("Type"));
+ sidField.setColumns(30);
+ fwPortField.setColumns(10);
+ cbBequeath.setText(res.getString("BequeathConnection"));
+ appsHostLabel.setText(res.getString("AppsHost"));
+ appsHostField.setColumns(30);
+ appsPortLabel.setText(res.getString("AppsPort"));
+ appsPortField.setColumns(10);
+ bTestApps.setText(res.getString("TestApps"));
+ bTestApps.setHorizontalAlignment(JLabel.LEFT);
+ 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);
+ southPanel.add(bCancel, null);
+ southPanel.add(bOK, null);
+ //
+ centerPanel.add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
+ ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0));
+ centerPanel.add(nameField, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0
+ ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0));
+ centerPanel.add(appsHostLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
+ ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0));
+ centerPanel.add(appsHostField, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0
+ ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0));
+
+ centerPanel.add(appsPortLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
+ ,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
+ ,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
+ ,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
+ ,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
+ ,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
+ ,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
+ ,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
+ ,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
+ ,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
+ ,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
+ ,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
+ ,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
+ ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
+ centerPanel.add(dbPwdField, new GridBagConstraints(2, 9, 1, 1, 0.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
+ ,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
+ ,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
+ ,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
+ ,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
+ ,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
+ ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 12, 0), 0, 0));
+ //
+ nameField.addActionListener(this);
+ appsHostField.addActionListener(this);
+ appsPortField.addActionListener(this);
+ cbOverwrite.addActionListener(this);
+ bTestApps.addActionListener(this);
+ //
+ dbTypeField.addActionListener(this);
+ hostField.addActionListener(this);
+ dbPortField.addActionListener(this);
+ sidField.addActionListener(this);
+ cbBequeath.addActionListener(this);
+ cbFirewall.addActionListener(this);
+ fwHostField.addActionListener(this);
+ fwPortField.addActionListener(this);
+ bTestDB.addActionListener(this);
+ bOK.addActionListener(this);
+ bCancel.addActionListener(this);
+
+ // Server
+ if (!Ini.isClient())
+ {
+ appsHostLabel.setVisible(false);
+ appsHostField.setVisible(false);
+ appsPortLabel.setVisible(false);
+ appsPortField.setVisible(false);
+ bTestApps.setVisible(false);
+ connectionProfileLabel.setVisible(false);
+ connectionProfileField.setVisible(false);
+ }
+ else // Client
+ cbBequeath.setVisible(false);
+ } // jbInit
+
+ /**
+ * Set Busy - lock UI
+ * @param busy busy
+ */
+ private void setBusy (boolean busy)
+ {
+ if (busy)
+ this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ else
+ this.setCursor(Cursor.getDefaultCursor());
+ m_updating = busy;
+ } // setBusy
+
+ /**
+ * Set Connection
+ * @param cc - if null use current connection
+ */
+ public void setConnection (CConnection cc)
+ {
+ m_cc = cc;
+ if (m_cc == null)
+ {
+ m_cc = CConnection.get();
+ m_cc.setName();
+ }
+ // Should copy values
+ m_ccResult = m_cc;
+ //
+ String type = m_cc.getType();
+ if (type == null || type.length() == 0)
+ dbTypeField.setSelectedItem(null);
+ else
+ m_cc.setType(m_cc.getType()); // sets defaults
+ updateInfo();
+ } // setConnection
+
+ /**
+ * Get Connection
+ * @return CConnection
+ */
+ public CConnection getConnection()
+ {
+ return m_ccResult;
+ } // getConnection;
+
+ /**
+ * ActionListener
+ * @param e event
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ if (m_updating)
+ return;
+ Object src = e.getSource();
+
+ if (src == bOK)
+ {
+ m_cc.setName();
+ m_ccResult = m_cc;
+ dispose();
+ return;
+ }
+ else if (src == bCancel)
+ {
+ m_cc.setName();
+ 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)
+ return;
+ }
+
+
+ if (Ini.isClient())
+ {
+ m_cc.setAppsHost(appsHostField.getText());
+ m_cc.setAppsPort(appsPortField.getText());
+ }
+ 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());
+ m_cc.setDbName(sidField.getText());
+ m_cc.setDbUid(dbUidField.getText());
+ m_cc.setDbPwd(String.valueOf(dbPwdField.getPassword()));
+ m_cc.setBequeath(cbBequeath.isSelected());
+ m_cc.setViaFirewall(cbFirewall.isSelected());
+ m_cc.setFwHost(fwHostField.getText());
+ m_cc.setFwPort(fwPortField.getText());
+ //
+ if (src == bTestApps)
+ cmd_testApps();
+
+ // Database Selection Changed
+ else if (src == dbTypeField)
+ {
+ m_cc.setType((String)dbTypeField.getSelectedItem());
+ dbPortField.setText(String.valueOf(m_cc.getDbPort()));
+ cbBequeath.setSelected(m_cc.isBequeath());
+ fwPortField.setText(String.valueOf(m_cc.getFwPort()));
+ }
+ //
+ else if (src == bTestDB)
+ cmd_testDB();
+
+ // Name
+ if (src == nameField)
+ m_cc.setName(nameField.getText());
+
+ updateInfo();
+ } // actionPerformed
+
+ /**
+ * Update Fields from Connection
+ */
+ private void updateInfo()
+ {
+ m_updating = true;
+ nameField.setText(m_cc.getName());
+ 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());
+
+ cbOverwrite.setVisible(m_cc.isAppsServerOK(false));
+ boolean rw = cbOverwrite.isSelected() || !m_cc.isAppsServerOK(false);
+ //
+ dbTypeLabel.setReadWrite(rw);
+ dbTypeField.setReadWrite(rw);
+ dbTypeField.setSelectedItem(m_cc.getType());
+ //
+ hostLabel.setReadWrite(rw);
+ hostField.setReadWrite(rw);
+ hostField.setText(m_cc.getDbHost());
+ portLabel.setReadWrite(rw);
+ dbPortField.setReadWrite(rw);
+ dbPortField.setText(String.valueOf(m_cc.getDbPort()));
+ sidLabel.setReadWrite(rw);
+ sidField.setReadWrite(rw);
+ sidField.setText(m_cc.getDbName());
+ //
+ dbUidLabel.setReadWrite(rw);
+ dbUidField.setReadWrite(rw);
+ dbUidField.setText(m_cc.getDbUid());
+ dbPwdField.setEditable(rw);
+ dbPwdField.setText(m_cc.getDbPwd());
+ //
+ cbBequeath.setReadWrite(rw);
+ cbBequeath.setEnabled(m_cc.isOracle());
+ cbBequeath.setSelected(m_cc.isBequeath());
+ //
+ boolean fwEnabled = rw && m_cc.isViaFirewall() && m_cc.isOracle();
+ cbFirewall.setReadWrite(rw && m_cc.isOracle());
+ cbFirewall.setSelected(m_cc.isViaFirewall());
+ fwHostLabel.setReadWrite(fwEnabled);
+ fwHostField.setReadWrite(fwEnabled);
+ fwHostField.setText(m_cc.getFwHost());
+ fwPortLabel.setReadWrite(fwEnabled);
+ fwPortField.setReadWrite(fwEnabled);
+ fwPortField.setText(String.valueOf(m_cc.getFwPort()));
+ //
+ bTestDB.setToolTipText(m_cc.getConnectionURL());
+ bTestDB.setIcon(getStatusIcon(m_cc.isDatabaseOK()));
+ m_updating = false;
+ } // updateInfo
+
+ /**
+ * Get Status Icon - ok or not
+ * @param ok ok
+ * @return Icon
+ */
+ private Icon getStatusIcon (boolean ok)
+ {
+ if (ok)
+ return bOK.getIcon();
+ else
+ return bCancel.getIcon();
+ } // getStatusIcon
+
+ /**
+ * Test Database connection
+ */
+ private void cmd_testDB()
+ {
+ setBusy (true);
+ Exception e = m_cc.testDatabase(true);
+ if (e != null)
+ {
+ JOptionPane.showMessageDialog(this,
+ e, // message
+ res.getString("ConnectionError") + ": " + m_cc.getConnectionURL(),
+ JOptionPane.ERROR_MESSAGE);
+ }
+ setBusy (false);
+ } // cmd_testDB
+
+ /**
+ * Test Application connection
+ */
+ private void cmd_testApps()
+ {
+ setBusy (true);
+ Exception e = m_cc.testAppsServer();
+ if (e != null)
+ {
+ JOptionPane.showMessageDialog(this,
+ e.getLocalizedMessage(),
+ res.getString("ServerNotActive") + " - " + m_cc.getAppsHost(),
+ JOptionPane.ERROR_MESSAGE);
+ }
+ setBusy (false);
+ } // cmd_testApps
+
+} // CConnectionDialog
diff --git a/dbPort/src/org/compiere/db/CConnectionEditor.java b/dbPort/src/org/compiere/db/CConnectionEditor.java
new file mode 100644
index 0000000000..d363404d58
--- /dev/null
+++ b/dbPort/src/org/compiere/db/CConnectionEditor.java
@@ -0,0 +1,286 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+import org.compiere.plaf.*;
+import org.compiere.swing.*;
+
+/**
+ * Connection Editor.
+ * A combo box and a button
+ *
+ * @author Jorg Janke
+ * @version $Id: CConnectionEditor.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class CConnectionEditor extends JComponent
+ implements CEditor
+{
+ /**
+ * Connection Editor creating new Connection
+ */
+ public CConnectionEditor()
+ {
+ super();
+ setName("ConnectionEditor");
+ CConnectionEditor_MouseListener ml = new CConnectionEditor_MouseListener();
+ // Layout
+ m_text.setEditable(false);
+ m_text.setBorder(null);
+ m_text.addMouseListener(ml);
+ m_server.setIcon(new ImageIcon(getClass().getResource("Server16.gif")));
+ m_server.setFocusable(false);
+ m_server.setBorder(null);
+ m_server.setOpaque(true);
+ m_server.addMouseListener(ml);
+ m_db.setIcon(new ImageIcon(getClass().getResource("Database16.gif")));
+ m_db.setFocusable(false);
+ m_db.setBorder(null);
+ m_db.setOpaque(true);
+ m_db.addMouseListener(ml);
+ LookAndFeel.installBorder(this, "TextField.border");
+ //
+ setLayout(new BorderLayout(0,0));
+ add(m_server, BorderLayout.WEST);
+ add(m_text, BorderLayout.CENTER);
+ add(m_db, BorderLayout.EAST);
+ } // CConnectionEditor
+
+ /** Text Element */
+ private JTextField m_text = new JTextField(10);
+ /** DB Button Element */
+ private JLabel m_db = new JLabel ();
+ /** Host Button Element */
+ private JLabel m_server = new JLabel();
+ /** The Value */
+ private CConnection m_value = null;
+ /** ReadWrite */
+ private boolean m_rw = true;
+ /** Mandatory */
+ private boolean m_mandatory = false;
+
+ /**
+ * Enable Editor
+ * @param rw true, if you can enter/select data
+ */
+ public void setReadWrite (boolean rw)
+ {
+ m_rw = rw;
+ setBackground(false);
+ } // setReadWrite
+
+ /**
+ * Is it possible to edit
+ * @return true, if editable
+ */
+ public boolean isReadWrite()
+ {
+ return m_rw;
+ } // isReadWrite
+
+ /**
+ * Set Editor Mandatory
+ * @param mandatory true, if you have to enter data
+ */
+ public void setMandatory (boolean mandatory)
+ {
+ m_mandatory = mandatory;
+ } // setMandatory
+
+ /**
+ * Is Field mandatory
+ * @return true, if mandatory
+ */
+ public boolean isMandatory()
+ {
+ return m_mandatory;
+ } // isMandatory
+
+ /**
+ * Set Background based on editable / mandatory / error
+ * @param error if true, set background to error color, otherwise mandatory/editable
+ */
+ public void setBackground (boolean error)
+ {
+ Color c = null;
+ if (error)
+ c = AdempierePLAF.getFieldBackground_Error();
+ else if (!m_rw)
+ c = AdempierePLAF.getFieldBackground_Inactive();
+ else if (m_mandatory)
+ c = AdempierePLAF.getFieldBackground_Mandatory();
+ else
+ c = AdempierePLAF.getFieldBackground_Normal();
+ setBackground(c);
+ } // setBackground
+
+ /**
+ * Set Background color
+ * @param color
+ */
+ public void setBackground (Color color)
+ {
+ m_server.setBackground(color);
+ m_text.setBackground(color);
+ m_db.setBackground(color);
+ } // setBackground
+
+ /**
+ * Set Visible
+ * @param visible true if field is to be shown
+ */
+ public void setVisible (boolean visible)
+ {
+ this.setVisible(visible);
+ }
+
+ /**
+ * Set Editor to value
+ * @param value value of the editor
+ */
+ public void setValue (Object value)
+ {
+ if (value != null && value instanceof CConnection)
+ m_value = (CConnection)value;
+ setDisplay();
+ } // setValue
+
+ /**
+ * Return Editor value
+ * @return current value
+ */
+ public Object getValue()
+ {
+ return m_value;
+ } // getValue
+
+ /**
+ * Return Display Value
+ * @return displayed String value
+ */
+ public String getDisplay()
+ {
+ if (m_value == null)
+ return "";
+ return m_value.getName();
+ } // getDisplay
+
+ /**
+ * Update Display with Connection info
+ */
+ public void setDisplay()
+ {
+ m_text.setText(getDisplay());
+ if (m_value == null)
+ return;
+ // Text
+ if (m_value.isAppsServerOK(false) || m_value.isDatabaseOK())
+ {
+ m_text.setForeground(AdempierePLAF.getTextColor_OK());
+ setBackground(false);
+ if (!m_value.isAppsServerOK(false))
+ m_server.setBackground(AdempierePLAF.getFieldBackground_Error());
+ if (!m_value.isDatabaseOK())
+ m_db.setBackground(AdempierePLAF.getFieldBackground_Error());
+ }
+ else
+ {
+ m_text.setForeground(AdempierePLAF.getTextColor_Issue());
+ setBackground(true);
+ }
+ } // setDisplay
+
+
+ /**************************************************************************
+ * Remove Action Listener
+ * @param l
+ */
+ public synchronized void removeActionListener(ActionListener l)
+ {
+ listenerList.remove(ActionListener.class, l);
+ } // removeActionListener
+
+ /**
+ * Add Action Listener
+ * @param l
+ */
+ public synchronized void addActionListener(ActionListener l)
+ {
+ listenerList.add(ActionListener.class, l);
+ } // addActionListener
+
+ /**
+ * Fire Action Performed
+ */
+ private void fireActionPerformed()
+ {
+ ActionEvent e = null;
+ ActionListener[] listeners = listenerList.getListeners(ActionListener.class);
+ for (int i = 0; i < listeners.length; i++)
+ {
+ if (e == null)
+ e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "actionPerformed");
+ listeners[i].actionPerformed(e);
+ }
+ } // fireActionPerformed
+
+
+ /**************************************************************************
+ * Test Method
+ * @param args
+ */
+ public static void main(String[] args)
+ {
+ // System.out.println("CConnectionEditor");
+ JFrame frame = new JFrame("CConnectionEditor");
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.getRootPane().getContentPane().add(new CConnectionEditor());
+ AdempierePLAF.showCenterScreen(frame);
+ } // main
+
+
+ /**
+ * MouseListener
+ */
+ public class CConnectionEditor_MouseListener extends MouseAdapter
+ {
+ /**
+ * Mouse Clicked - Open Dialog
+ * @param e
+ */
+ public void mouseClicked(MouseEvent e)
+ {
+ if (!isEnabled() || !m_rw || m_active)
+ return;
+ m_active = true;
+ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ //
+ CConnectionDialog cd = new CConnectionDialog(m_value);
+ setValue(cd.getConnection());
+ fireActionPerformed();
+ //
+ setCursor(Cursor.getDefaultCursor());
+ m_active = false;
+ } // mouseClicked
+
+ private boolean m_active = false;
+ } // CConnectionExitor_MouseListener
+
+} // CConnectionEditor
diff --git a/dbPort/src/org/compiere/db/CreateAdempiere.java b/dbPort/src/org/compiere/db/CreateAdempiere.java
new file mode 100644
index 0000000000..05cf945767
--- /dev/null
+++ b/dbPort/src/org/compiere/db/CreateAdempiere.java
@@ -0,0 +1,846 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.io.*;
+import java.math.*;
+import java.sql.*;
+import java.util.*;
+import java.util.logging.*;
+import org.compiere.*;
+import org.compiere.model.*;
+import org.compiere.util.*;
+
+/**
+ * Class to Create a new Adempiere Database from a reference DB.
+ *
+ *
+ * @author Jorg Janke
+ * @version $Id: CreateAdempiere.java,v 1.5 2006/09/22 23:35:19 jjanke Exp $
+ */
+public class CreateAdempiere
+{
+ /**
+ * Constructor
+ * @param databaseType AdempiereDatabase.TYPE_
+ * @param databaseHost database host
+ * @param databasePort database port 0 for default
+ * @param systemPassword system password
+ */
+ public CreateAdempiere(String databaseType, String databaseHost, int databasePort,
+ String systemPassword)
+ {
+ initDatabase(databaseType);
+ m_databaseHost = databaseHost;
+ if (databasePort == 0)
+ m_databasePort = m_dbTarget.getStandardPort();
+ else
+ m_databasePort = databasePort;
+ m_systemPassword = systemPassword;
+ log.info(m_dbTarget.getName() + " on " + databaseHost);
+ } // create
+
+ /** Adempiere Target Database */
+ private AdempiereDatabase m_dbTarget = null;
+ /** Adempiere Source Database */
+ private AdempiereDatabase m_dbSource = null;
+ //
+ private String m_databaseHost = null;
+ private int m_databasePort = 0;
+ private String m_systemPassword = null;
+ private String m_adempiereUser = null;
+ private String m_adempierePassword = null;
+ private String m_databaseName = null;
+ private String m_databaseDevice = null;
+ //
+ private Properties m_ctx = new Properties ();
+ /** Cached connection */
+ private Connection m_conn = null;
+
+ /** Logger */
+ private static CLogger log = CLogger.getCLogger (CreateAdempiere.class);
+
+ /**
+ * Create Adempiere Database
+ * @param databaseType Database.DB_
+ */
+ private void initDatabase(String databaseType)
+ {
+ try
+ {
+ for (int i = 0; i < Database.DB_NAMES.length; i++)
+ {
+ if (Database.DB_NAMES[i].equals (databaseType))
+ {
+ m_dbTarget = (AdempiereDatabase)Database.DB_CLASSES[i].
+ newInstance ();
+ break;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ log.severe(e.toString ());
+ e.printStackTrace();
+ }
+ if (m_dbTarget == null)
+ throw new IllegalStateException("No database: " + databaseType);
+
+ // Source Database
+ m_dbSource = DB.getDatabase();
+ } // createDatabase
+
+ /**
+ * Clean Start - drop & re-create DB
+ */
+ public void cleanStart()
+ {
+ Connection conn = getConnection(true, true);
+ if (conn == null)
+ throw new IllegalStateException("No Database");
+ //
+ dropDatabase(conn);
+ createUser(conn);
+ createDatabase(conn);
+ //
+ try
+ {
+ if (conn != null)
+ conn.close();
+ }
+ catch (SQLException e2)
+ {
+ log.log(Level.SEVERE, "close connection", e2);
+ }
+ conn = null;
+ } // cleanStart
+
+
+ /**
+ * Set Adempiere User
+ * @param adempiereUser adempiere id
+ * @param adempierePassword adempiere password
+ */
+ public void setAdempiereUser (String adempiereUser, String adempierePassword)
+ {
+ m_adempiereUser = adempiereUser;
+ m_adempierePassword = adempierePassword;
+ } // setAdempiereUser
+
+ /**
+ * Set Database Name
+ * @param databaseName db name
+ * @param databaseDevice device or table space
+ */
+ public void setDatabaseName (String databaseName, String databaseDevice)
+ {
+ m_databaseName = databaseName;
+ m_databaseDevice = databaseDevice;
+ } // createDatabase
+
+
+ /**
+ * Test Connection
+ * @return connection
+ */
+ public boolean testConnection()
+ {
+ String dbUrl = m_dbTarget.getConnectionURL (m_databaseHost, m_databasePort,
+ m_databaseName, m_dbTarget.getSystemUser()); // adempiere may not be defined yet
+ log.info(dbUrl + " - " + m_dbTarget.getSystemUser() + "/" + m_systemPassword);
+ try
+ {
+ Connection conn = m_dbTarget.getDriverConnection(dbUrl, m_dbTarget.getSystemUser(), m_systemPassword);
+ //
+ JDBCInfo info = new JDBCInfo(conn);
+ if (CLogMgt.isLevelFinest())
+ {
+ info.listCatalogs();
+ info.listSchemas();
+ }
+ }
+ catch (Exception e)
+ {
+ log.log(Level.SEVERE, "test", e);
+ return false;
+ }
+
+ return true;
+ } // testConnection
+
+
+ /**************************************************************************
+ * Create User
+ * @param sysConn system connection
+ * @return true if success
+ */
+ public boolean createUser (Connection sysConn)
+ {
+ log.info(m_adempiereUser + "/" + m_adempierePassword);
+ return executeCommands(m_dbTarget.getCommands(AdempiereDatabase.CMD_CREATE_USER),
+ sysConn, true, false);
+ } // createUser
+
+ /**
+ * Create Database (User)
+ * @param sysConn system connection
+ * @return true if success
+ */
+ public boolean createDatabase (Connection sysConn)
+ {
+ log.info(m_databaseName + "(" + m_databaseDevice + ")");
+ return executeCommands(m_dbTarget.getCommands(AdempiereDatabase.CMD_CREATE_DATABASE),
+ sysConn, true, false);
+ } // createDatabase
+
+ /**
+ * Drop Database (User)
+ * @param sysConn system connection
+ * @return true if success
+ */
+ public boolean dropDatabase (Connection sysConn)
+ {
+ log.info(m_databaseName);
+ return executeCommands(m_dbTarget.getCommands(AdempiereDatabase.CMD_DROP_DATABASE),
+ sysConn, true, false);
+ } // dropDatabase
+
+
+ /**
+ * Create Tables and copy data
+ * @param whereClause optional where clause
+ * @param dropFirst drop first
+ * @return true if executed
+ */
+ public boolean copy (String whereClause, boolean dropFirst)
+ {
+ log.info(whereClause);
+ if (getConnection(false, true) == null)
+ return false;
+ //
+ boolean success = true;
+ int count = 0;
+ ArrayList list = new ArrayList();
+ String sql = "SELECT * FROM AD_Table";
+ if (whereClause != null && whereClause.length() > 0)
+ sql += " WHERE " + whereClause;
+ sql += " ORDER BY TableName";
+ //
+ PreparedStatement pstmt = null;
+ try
+ {
+ pstmt = DB.prepareStatement (sql, null);
+ //jz: pstmt.getConnection() could be null
+ Connection conn = pstmt.getConnection();
+ DatabaseMetaData md = null;
+ if (conn != null)
+ md = conn.getMetaData();
+ else
+ {
+ //jz: globalization issue??
+ throw new DBException("No Connection");
+ }
+
+ ResultSet rs = pstmt.executeQuery ();
+ while (rs.next() && success)
+ {
+ MTable table = new MTable (m_ctx, rs, null);
+ if (table.isView())
+ continue;
+ if (dropFirst)
+ {
+ executeCommands(new String[]
+ {"DROP TABLE " + table.getTableName()},
+ m_conn, false, false);
+ }
+ //
+ if (createTable (table, md))
+ {
+ list.add(table.getTableName());
+ count++;
+ }
+ else
+ success = false;
+ }
+ rs.close ();
+ pstmt.close ();
+ pstmt = null;
+ }
+ catch (Exception e)
+ {
+ log.log (Level.SEVERE, sql, e);
+ success = false;
+ }
+ try
+ {
+ if (pstmt != null)
+ pstmt.close ();
+ pstmt = null;
+ }
+ catch (Exception e)
+ {
+ pstmt = null;
+ }
+ if (!success)
+ return false;
+
+ /** Enable Contraints */
+ enableConstraints(list);
+
+ databaseBuild();
+
+ log.info("#" + count);
+
+ try
+ {
+ if (m_conn != null)
+ m_conn.close();
+ }
+ catch (SQLException e2)
+ {
+ log.log(Level.SEVERE, "close connection", e2);
+ }
+ m_conn = null;
+ return success;
+ } // copy
+
+ /**
+ * Execute Script
+ * @param script file with script
+ * @return true if executed
+ */
+ public boolean execute (File script)
+ {
+ return false;
+ } // createTables
+
+
+
+ /**
+ * Create Table
+ * @param mTable table model
+ * @param md meta data
+ * @return true if created
+ */
+ private boolean createTable (MTable mTable, DatabaseMetaData md)
+ {
+ String tableName = mTable.getTableName();
+ log.info(tableName);
+ String catalog = m_dbSource.getCatalog();
+ String schema = m_dbSource.getSchema();
+ String table = tableName.toUpperCase();
+ //
+ MColumn[] columns = mTable.getColumns(false);
+
+ StringBuffer sb = new StringBuffer("CREATE TABLE ");
+ sb.append(tableName).append(" (");
+ try
+ {
+ // Columns
+ boolean first = true;
+ ResultSet sourceColumns = md.getColumns(catalog, schema, table, null);
+ while (sourceColumns.next())
+ {
+ sb.append(first ? "" : ", ");
+ first = false;
+ // Case sensitive Column Name
+ MColumn column = null;
+ String columnName = sourceColumns.getString("COLUMN_NAME");
+ for (int i = 0; i < columns.length; i++)
+ {
+ String cn = columns[i].getColumnName();
+ if (cn.equalsIgnoreCase(columnName))
+ {
+ columnName = cn;
+ column = columns[i];
+ break;
+ }
+ }
+ sb.append(columnName).append(" ");
+ // Data Type & Precision
+ int sqlType = sourceColumns.getInt ("DATA_TYPE"); // sql.Types
+ String typeName = sourceColumns.getString ("TYPE_NAME"); // DB Dependent
+ int size = sourceColumns.getInt ("COLUMN_SIZE");
+ int decDigits = sourceColumns.getInt("DECIMAL_DIGITS");
+ if (sourceColumns.wasNull())
+ decDigits = -1;
+ if (typeName.equals("NUMBER"))
+ {
+ /** Oracle Style *
+ if (decDigits == -1)
+ sb.append(typeName);
+ else
+ sb.append(typeName).append("(")
+ .append(size).append(",").append(decDigits).append(")");
+ /** Other DBs */
+ int dt = column.getAD_Reference_ID();
+ if (DisplayType.isID(dt))
+ sb.append("INTEGER");
+ else
+ {
+ int scale = DisplayType.getDefaultPrecision(dt);
+ sb.append("DECIMAL(")
+ .append(18+scale).append(",").append(scale).append(")");
+ }
+ }
+ else if (typeName.equals("DATE") || typeName.equals("BLOB") || typeName.equals("CLOB"))
+ sb.append(typeName);
+ else if (typeName.equals("CHAR") || typeName.startsWith("VARCHAR"))
+ sb.append(typeName).append("(").append(size).append(")");
+ else if (typeName.startsWith("NCHAR") || typeName.startsWith("NVAR"))
+ sb.append(typeName).append("(").append(size/2).append(")");
+ else if (typeName.startsWith("TIMESTAMP"))
+ sb.append("DATE");
+ else
+ log.severe("Do not support data type " + typeName);
+ // Default
+ String def = sourceColumns.getString("COLUMN_DEF");
+ if (def != null)
+ {
+ //jz: replace '' to \', otherwise exception
+ def.replaceAll("''", "\\'");
+ sb.append(" DEFAULT ").append(def);
+ }
+ // Null
+ if (sourceColumns.getInt("NULLABLE") == DatabaseMetaData.columnNoNulls)
+ sb.append(" NOT NULL");
+ else
+ sb.append(" NULL");
+
+ // Check Contraints
+
+
+ } // for all columns
+ sourceColumns.close();
+
+ // Primary Key
+ ResultSet sourcePK = md.getPrimaryKeys(catalog, schema, table);
+ // TABLE_CAT=null, TABLE_SCHEM=REFERENCE, TABLE_NAME=A_ASSET, COLUMN_NAME=A_ASSET_ID, KEY_SEQ=1, PK_NAME=A_ASSET_KEY
+ first = true;
+ boolean hasPK = false;
+ while (sourcePK.next())
+ {
+ hasPK = true;
+ if (first)
+ sb.append(", CONSTRAINT ").append(sourcePK.getString("PK_NAME")).append(" PRIMARY KEY (");
+ else
+ sb.append(",");
+ first = false;
+ String columnName = sourcePK.getString("COLUMN_NAME");
+ sb.append(checkColumnName(columnName));
+ }
+ if (hasPK) // close constraint
+ sb.append(")"); // USING INDEX TABLESPACE INDX
+ sourcePK.close();
+ //
+ sb.append(")"); // close create table
+ }
+ catch (Exception ex)
+ {
+ log.log(Level.SEVERE, "createTable", ex);
+ return false;
+ }
+
+ // Execute Create Table
+ if (!executeCommands(new String[]{sb.toString()}, m_conn, false, true))
+ return true; // continue
+
+ // Create Inexes
+ createTableIndexes(mTable, md);
+
+ return createTableData(mTable);
+ } // createTable
+
+ /**
+ * Check Column Name
+ * @param columnName column name
+ * @return column name with correct case
+ */
+ private String checkColumnName (String columnName)
+ {
+ return M_Element.getColumnName (columnName);
+ } // checkColumnName
+
+ /**
+ * Create Table Indexes
+ * @param mTable table
+ * @param md meta data
+ */
+ private void createTableIndexes(MTable mTable, DatabaseMetaData md)
+ {
+ String tableName = mTable.getTableName();
+ log.info(tableName);
+ String catalog = m_dbSource.getCatalog();
+ String schema = m_dbSource.getSchema();
+ String table = tableName.toUpperCase();
+ try
+ {
+ ResultSet sourceIndex = md.getIndexInfo(catalog, schema, table, false, false);
+
+ }
+ catch (Exception e)
+ {
+
+ }
+ } // createTableIndexes
+
+
+ /**
+ * Create/Copy Table Data
+ * @param mTable model table
+ * @return true if data created/copied
+ */
+ private boolean createTableData (MTable mTable)
+ {
+ boolean success = true;
+ int count = 0;
+ int errors = 0;
+ long start = System.currentTimeMillis();
+
+ // Get Table Data
+ String sql = "SELECT * FROM " + mTable.getTableName();
+ PreparedStatement pstmt = null;
+ try
+ {
+ pstmt = DB.prepareStatement (sql, mTable.get_TrxName());
+ ResultSet rs = pstmt.executeQuery ();
+ while (rs.next ())
+ {
+ if (createTableDataRow(rs, mTable))
+ count++;
+ else
+ errors++;
+ }
+ rs.close ();
+ pstmt.close ();
+ pstmt = null;
+ }
+ catch (Exception e)
+ {
+ log.log (Level.SEVERE, sql, e);
+ success = false;
+ }
+ try
+ {
+ if (pstmt != null)
+ pstmt.close ();
+ pstmt = null;
+ }
+ catch (Exception e)
+ {
+ pstmt = null;
+ }
+ long elapsed = System.currentTimeMillis() - start;
+ log.config("Inserted=" + count + " - Errors=" + errors
+ + " - " + elapsed + " ms");
+ return success;
+ } // createTableData
+
+ /**
+ * Create Table Data Row
+ * @param rs result set
+ * @param mTable table
+ * @return true if created
+ */
+ private boolean createTableDataRow (ResultSet rs, MTable mTable)
+ {
+ StringBuffer insert = new StringBuffer ("INSERT INTO ")
+ .append(mTable.getTableName()).append(" (");
+ StringBuffer values = new StringBuffer ();
+ //
+ MColumn[] columns = mTable.getColumns(false);
+ for (int i = 0; i < columns.length; i++)
+ {
+ if (i != 0)
+ {
+ insert.append(",");
+ values.append(",");
+ }
+ MColumn column = columns[i];
+ String columnName = column.getColumnName();
+ insert.append(columnName);
+ //
+ int dt = column.getAD_Reference_ID();
+ try
+ {
+ Object value = rs.getObject(columnName);
+ if (rs.wasNull())
+ {
+ values.append("NULL");
+ }
+ else if (columnName.endsWith("_ID") // Record_ID, C_ProjectType defined as Button
+ || DisplayType.isNumeric(dt)
+ || (DisplayType.isID(dt) && !columnName.equals("AD_Language")))
+ {
+ BigDecimal bd = rs.getBigDecimal(columnName);
+ String s = m_dbTarget.TO_NUMBER(bd, dt);
+ values.append(s);
+ }
+ else if (DisplayType.isDate(dt))
+ {
+ Timestamp ts = rs.getTimestamp(columnName);
+ String tsString = m_dbTarget.TO_DATE(ts, dt == DisplayType.Date);
+ values.append(tsString);
+ }
+ else if (DisplayType.isLOB(dt))
+ {
+ // ignored
+ values.append("NULL");
+ }
+ else if (DisplayType.isText(dt) || dt == DisplayType.YesNo
+ || dt == DisplayType.List || dt == DisplayType.Button
+ || columnName.equals("AD_Language"))
+ {
+ String s = rs.getString(columnName);
+ values.append(DB.TO_STRING(s));
+ }
+ else
+ {
+ log.warning("Unknown DisplayType=" + dt
+ + " - " + value + " [" + value.getClass().getName() + "]");
+ values.append("NuLl");
+ }
+ }
+ catch (Exception e)
+ {
+ log.log(Level.SEVERE, columnName, e);
+ }
+ } // for all columns
+
+ //
+ insert.append(") VALUES (").append(values).append(")");
+ return executeCommands(new String[]{insert.toString()},
+ m_conn, false, false); // do not convert as text is converted
+ } // createTableDataRow
+
+
+ /**
+ * Enable Constraints
+ * @param list list
+ * @return true if constraints enabled/created
+ */
+ private boolean enableConstraints (ArrayList list)
+ {
+ log.info("");
+ return false;
+ } // enableConstraints
+
+
+ private void databaseBuild()
+ {
+ // Build Script
+ //jz remove hard coded path later
+ String fileName = "C:\\Adempiere\\adempiere-all2\\db\\database\\DatabaseBuild.sql";
+ File file = new File (fileName);
+ if (!file.exists())
+ log.severe("No file: " + fileName);
+
+ // FileReader reader = new FileReader (file);
+
+
+
+ } // databaseBuild
+
+ /**
+ * Get Connection
+ * @param asSystem if true execute as db system administrator
+ * @param createNew create new connection
+ * @return connection or null
+ */
+ private Connection getConnection (boolean asSystem, boolean createNew)
+ {
+ if (!createNew && m_conn != null)
+ return m_conn;
+ //
+ String dbUrl = m_dbTarget.getConnectionURL(m_databaseHost, m_databasePort,
+ (asSystem ? m_dbTarget.getSystemDatabase(m_databaseName) : m_databaseName),
+ (asSystem ? m_dbTarget.getSystemUser() : m_adempiereUser));
+ try
+ {
+ if (asSystem)
+ m_conn = m_dbTarget.getDriverConnection(dbUrl, m_dbTarget.getSystemUser(), m_systemPassword);
+ else
+ m_conn = m_dbTarget.getDriverConnection(dbUrl, m_adempiereUser, m_adempierePassword);
+ }
+ catch (Exception e)
+ {
+ log.log(Level.SEVERE, dbUrl, e);
+ }
+ return m_conn;
+ } // getConnection
+
+
+ /**************************************************************************
+ * Execute Commands
+ * @param cmds array of SQL commands
+ * @param conn connection
+ * @param batch tf true commit as batch
+ * @param doConvert convert to DB specific notation
+ * @return true if success
+ */
+ private boolean executeCommands (String[] cmds, Connection conn,
+ boolean batch, boolean doConvert)
+ {
+ if (cmds == null || cmds.length == 0)
+ {
+ log.warning("No Commands");
+ return false;
+ }
+
+ Statement stmt = null;
+ String cmd = null;
+ String cmdOriginal = null;
+ try
+ {
+ if (conn == null)
+ {
+ conn = getConnection(false, false);
+ if (conn == null)
+ return false;
+ }
+ if (conn.getAutoCommit() == batch)
+ conn.setAutoCommit(!batch);
+ stmt = conn.createStatement();
+
+ // Commands
+ for (int i = 0; i < cmds.length; i++)
+ {
+ cmd = cmds[i];
+ cmdOriginal = cmds[i];
+ if (cmd == null || cmd.length() == 0)
+ continue;
+ //
+ if (cmd.indexOf('@') != -1)
+ {
+ cmd = Util.replace(cmd, "@SystemPassword@", m_systemPassword);
+ cmd = Util.replace(cmd, "@AdempiereUser@", m_adempiereUser);
+ cmd = Util.replace(cmd, "@AdempierePassword@", m_adempierePassword);
+ cmd = Util.replace(cmd, "@SystemPassword@", m_systemPassword);
+ cmd = Util.replace(cmd, "@DatabaseName@", m_databaseName);
+ if (m_databaseDevice != null)
+ cmd = Util.replace(cmd, "@DatabaseDevice@", m_databaseDevice);
+ }
+ if (doConvert)
+ cmd = m_dbTarget.convertStatement(cmd);
+ writeLog(cmd);
+ log.finer(cmd);
+ int no = stmt.executeUpdate(cmd);
+ log.finest("# " + no);
+ }
+ //
+ stmt.close();
+ stmt = null;
+ //
+ if (batch)
+ conn.commit();
+ //
+ return true;
+ }
+ catch (Exception e)
+ {
+ String msg = e.getMessage();
+ if (msg == null || msg.length() == 0)
+ msg = e.toString();
+ msg += " (";
+ if (e instanceof SQLException)
+ {
+ msg += "State=" + ((SQLException)e).getSQLState()
+ + ",ErrorCode=" + ((SQLException)e).getErrorCode();
+ }
+ msg += ")";
+ if (cmdOriginal != null && !cmdOriginal.equals(cmd))
+ msg += " - " + cmdOriginal;
+ msg += "\n=>" + cmd;
+ log.log(Level.SEVERE, msg);
+ }
+ // Error clean up
+ try
+ {
+ if (stmt != null)
+ stmt.close();
+ }
+ catch (SQLException e1)
+ {
+ log.log(Level.SEVERE, "close statement", e1);
+ }
+ stmt = null;
+ return false;
+ } // execureCommands
+
+
+ /**
+ * Write to File Log
+ * @param cmd cmd
+ */
+ private void writeLog (String cmd)
+ {
+ try
+ {
+ if (m_writer == null)
+ {
+ File file = File.createTempFile("create", ".log");
+ m_writer = new PrintWriter(new FileWriter(file));
+ log.info(file.toString());
+ }
+ m_writer.println(cmd);
+ m_writer.flush();
+ }
+ catch (Exception e)
+ {
+ log.severe(e.toString());
+ }
+ } // writeLog
+
+ private PrintWriter m_writer = null;
+
+
+ /**************************************************************************
+ * Create DB
+ * @param args
+ */
+ public static void main (String[] args)
+ {
+ Adempiere.startup(true);
+ CLogMgt.setLevel(Level.FINE);
+ CLogMgt.setLoggerLevel(Level.FINE,null);
+
+ // C_UOM_Conversion
+ // I_BankStatement
+ //
+ // Derby
+ //jz: changed the password from "" to null
+ //begin vpj-cd e-Evolution 03/03/2005 PostgreSQL
+ //PostgreSQL
+ //CreateCompiere cc = new CreateCompiere (Database.DB_DERBY, "localhost", 1527, null);
+ //cc.setCompiereUser("adempiere", "adempiere");
+ //cc.setDatabaseName("adempiere", "adempiere");
+ CreateAdempiere cc = new CreateAdempiere (Database.DB_POSTGRESQL, "127.0.0.2", 5432 , "adempiere");
+ cc.setAdempiereUser("adempiere", "adempiere");
+ cc.setDatabaseName("adempiere", "adempiere");
+ // end begin vpj-cd e-Evolution 03/03/2005 PostgreSQL
+ if (!cc.testConnection())
+ return;
+ cc.cleanStart();
+ //
+ // cc.copy(null, false);
+ cc.copy("TableName > 'C_RfQResponseLineQty'", false);
+ } // main
+
+} // CreateAdempiere
diff --git a/dbPort/src/org/compiere/db/DBRes.java b/dbPort/src/org/compiere/db/DBRes.java
new file mode 100644
index 0000000000..e3814b6656
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes.java
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author Jorg Janke
+ * @version $Id: DBRes.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]{
+ { "CConnectionDialog", "Adempiere Connection" },
+ { "Name", "Name" },
+ { "AppsHost", "Application Host" },
+ { "AppsPort", "Application Port" },
+ { "TestApps", "Test Application Server" },
+ { "DBHost", "Database Host" },
+ { "DBPort", "Database Port" },
+ { "DBName", "Database Name" },
+ { "DBUidPwd", "User / Password" },
+ { "ViaFirewall", "via Firewall" },
+ { "FWHost", "Firewall Host" },
+ { "FWPort", "Firewall Port" },
+ { "TestConnection", "Test Database" },
+ { "Type", "Database Type" },
+ { "BequeathConnection", "Bequeath Connection" },
+ { "Overwrite", "Overwrite" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "Connection Error" },
+ { "ServerNotActive", "Server Not Active" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_ar.java b/dbPort/src/org/compiere/db/DBRes_ar.java
new file mode 100644
index 0000000000..aa547db217
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_ar.java
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ * @author Jorg Janke
+ * @version $Id: DBRes_ar.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_ar extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]{
+ { "CConnectionDialog", "\u0631\u0628\u0637 \u0643\u0645\u0628\u064a\u0631" },
+ { "Name", "\u0627\u0644\u0627\u0650\u0633\u0645" },
+ { "AppsHost", "\u0645\u0636\u064a\u0641 \u0627\u0644\u062a\u0637\u0628\u064a\u0642\u0627\u062a" },
+ { "AppsPort", "\u0627\u0644\u062a\u0637\u0628\u064a\u0642\u0627\u062a \u0645\u0646\u0641\u062f" },
+ { "TestApps", "\u062c\u0631\u0628 \u0645\u0648\u0632\u0639 \u0627\u0644\u062a\u0637\u0628\u064a\u0642\u0627\u062a" },
+ { "DBHost", "\u0645\u0636\u064a\u0641 \u0642\u0627\u0639\u062f\u0629 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a" },
+ { "DBPort", "\u0645\u0646\u0641\u0630 \u0642\u0627\u0639\u062f\u0629 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a" },
+ { "DBName", "\u0627\u0650\u0633\u0645 \u0642\u0627\u0639\u062f\u0629 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a" },
+ { "DBUidPwd", "\u0627\u0644\u0645\u0633\u062a\u0639\u0645\u0644\\u0643\u0644\u0645\u0629 \u0627\u0644\u0633\u0631" },
+ { "ViaFirewall", "\u0639\u0628\u0631 \u062c\u062f\u0627\u0631 \u0646\u0627\u0631\u064a" },
+ { "FWHost", "\u0645\u0636\u064a\u0641 \u0627\u0644\u062c\u062f\u0627\u0631 \u0627\u0644\u0646\u0627\u0631\u064a" },
+ { "FWPort", "\u0645\u0646\u0641\u0630 \u0627\u0644\u062c\u062f\u0627\u0631 \u0627\u0644\u0646\u0627\u0631\u064a" },
+ { "TestConnection", "\u0645\u0646\u0641\u0630 \u0628\u0646\u0643 \u0627\u0644\u0645\u0639\u0644\u0648\u0645\u0627\u062a" },
+ { "Type", "\u0646\u0648\u0639 \u0642\u0627\u0639\u062f\u0629 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a" },
+ { "BequeathConnection", "\u062a\u0631\u0643\u0629 \u0627\u0644\u0631\u0651\u064e\u0628\u0637" },
+ { "Overwrite", "\u0627\u0633\u062d\u0642" },
+ { "RMIoverHTTP", "HTTP \u0645\u0631\u0651\u0631 \u0627\u0644\u0643\u0627\u0626\u0646\u0627\u062a \u0639\u0628\u0631 \u0646\u0641\u0642" },
+ { "ConnectionError", "\u062e\u0637\u0623 \u0623\u062b\u0646\u0627\u0621 \u0627\u0644\u0631\u0628\u0637" },
+ { "ServerNotActive", "\u0627\u0644\u0645\u0648\u0632\u0639 \u0644\u0627 \u064a\u0639\u0645\u0644" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ * @uml.property name="contents"
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // DBRes_ar_TN
+
diff --git a/dbPort/src/org/compiere/db/DBRes_bg.java b/dbPort/src/org/compiere/db/DBRes_bg.java
new file mode 100644
index 0000000000..c02dfd80a5
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_bg.java
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author Plamen Niikolov
+ * @version $Id: DBRes_bg.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_bg extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]{
+ { "CConnectionDialog", "\u0412\u0440\u044a\u0437\u043a\u0430" },
+ { "Name", "\u0418\u043c\u0435" },
+ { "AppsHost", "\u0421\u044a\u0440\u0432\u0435\u0440 \u043d\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u0442\u043e" },
+ { "AppsPort", "\u041f\u043e\u0440\u0442 \u043d\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u0442\u043e" },
+ { "TestApps", "\u0422\u0435\u0441\u0442 \u043d\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u0442\u043e" },
+ { "DBHost", "\u0421\u044a\u0440\u0432\u0435\u0440 \u043d\u0430 \u0431\u0430\u0437\u0430\u0442\u0430 \u0434\u0430\u043d\u043d\u0438" },
+ { "DBPort", "\u041f\u043e\u0440\u0442 \u043d\u0430 \u0431\u0430\u0437\u0430\u0442\u0430 \u0434\u0430\u043d\u043d\u0438" },
+ { "DBName", "\u0418\u043c\u0435 \u043d\u0430 \u0431\u0430\u0437\u0430\u0442\u0430 \u0434\u0430\u043d\u043d\u0438" },
+ { "DBUidPwd", "\u041f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b / \u041f\u0430\u0440\u043e\u043b\u0430" },
+ { "ViaFirewall", "\u0417\u0430\u0434 \u0437\u0430\u0449\u0438\u0442\u043d\u0430 \u0441\u0442\u0435\u043d\u0430" },
+ { "FWHost", "\u0421\u044a\u0440\u0432\u0435\u0440 \u043d\u0430 \u0437\u0430\u0449\u0438\u0442\u043d\u0430\u0442\u0430 \u0441\u0442\u0435\u043d\u0430" },
+ { "FWPort", "\u041f\u043e\u0440\u0442 \u043d\u0430 \u0437\u0430\u0449\u0438\u0442\u043d\u0430\u0442\u0430 \u0441\u0442\u0435\u043d\u0430" },
+ { "TestConnection", "\u0422\u0435\u0441\u0442 \u043d\u0430 \u0431\u0430\u0437\u0430\u0442\u0430 \u0434\u0430\u043d\u043d\u0438" },
+ { "Type", "\u0412\u0438\u0434 \u043d\u0430 \u0431\u0430\u0437\u0430\u0442\u0430 \u0434\u0430\u043d\u043d\u0438" },
+ { "BequeathConnection", "\u041b\u043e\u043a\u0430\u043b\u043d\u0430 \u0432\u0440\u044a\u0437\u043a\u0430" },
+ { "Overwrite", "\u0417\u0430\u043c\u044f\u043d\u0430" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "\u0413\u0440\u0435\u0448\u043a\u0430 \u043f\u0440\u0438 \u0441\u0432\u044a\u0440\u0437\u0432\u0430\u043d\u0435" },
+ { "ServerNotActive", "\u0421\u044a\u0440\u0432\u0435\u0440\u044a\u0442 \u043d\u0435 \u0435 \u0430\u043a\u0442\u0438\u0432\u0435\u043d" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ }
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_ca.java b/dbPort/src/org/compiere/db/DBRes_ca.java
new file mode 100644
index 0000000000..86fa6f6c25
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_ca.java
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author Jaume Teixi
+ * @version $Id: DBRes_ca.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_ca extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]
+ {
+ { "CConnectionDialog", "Connexiïŋ― Adempiere" },
+ { "Name", "Nom" },
+ { "AppsHost", "Servidor Aplicaciïŋ―" },
+ { "AppsPort", "Port Aplicaciïŋ―" },
+ { "TestApps", "Provar Aplicaciïŋ―" },
+ { "DBHost", "Servidor Base de Dades" },
+ { "DBPort", "Port Base de Dades" },
+ { "DBName", "Nom Base de Dades" },
+ { "DBUidPwd", "Usuari / Contrasenya" },
+ { "ViaFirewall", "via Tallafocs" },
+ { "FWHost", "Servidor Tallafocs" },
+ { "FWPort", "Port Tallafocs" },
+ { "TestConnection", "Provar Base de Dades" },
+ { "Type", "Tipus Base de Dades" },
+ { "BequeathConnection", "Delegar Connexiïŋ―" },
+ { "Overwrite", "Sobrescriure" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "Error Connexiïŋ―" },
+ { "ServerNotActive", "Servidor No Actiu" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_da.java b/dbPort/src/org/compiere/db/DBRes_da.java
new file mode 100644
index 0000000000..91c20cb53d
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_da.java
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author Jorg Janke
+ * @version $Id: DBRes_da.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_da extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]
+ {
+ { "CConnectionDialog", "Adempiere forbindelse" },
+ { "Name", "Navn" },
+ { "AppsHost", "ProgramvÃĶrt" },
+ { "AppsPort", "Programport" },
+ { "TestApps", "Test programserver" },
+ { "DBHost", "DatabasevÃĶrt" },
+ { "DBPort", "Databaseport" },
+ { "DBName", "Databasenavn" },
+ { "DBUidPwd", "Bruger/adgangskode" },
+ { "ViaFirewall", "via Firewall" },
+ { "FWHost", "Firewall-vÃĶrt" },
+ { "FWPort", "Firewall-port" },
+ { "TestConnection", "Test database" },
+ { "Type", "Databasetype" },
+ { "BequeathConnection", "Nedarv forbindelse" },
+ { "Overwrite", "Overskriv" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "Fejl i forbindelse" },
+ { "ServerNotActive", "Server er ikke aktiv" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_de.java b/dbPort/src/org/compiere/db/DBRes_de.java
new file mode 100644
index 0000000000..bebfa6fb6c
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_de.java
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings (German)
+ *
+ * @author Jorg Janke
+ * @version $Id: DBRes_de.java,v 1.3 2006/08/30 20:30:44 comdivision Exp $
+ */
+public class DBRes_de extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]
+ {
+ { "CConnectionDialog", "Adempiere Verbindung" },
+ { "Name", "Name" },
+ { "AppsHost", "Applikationsserver" },
+ { "AppsPort", "Port Applikationsserver" },
+ { "TestApps", "Test Applikationsserver" },
+ { "DBHost", "Datenbank Server" },
+ { "DBPort", "Datenbank Port" },
+ { "DBName", "Datenbank Name" },
+ { "DBUidPwd", "Nutzer / Kennwort" },
+ { "ViaFirewall", "ïŋ―ber Firewall" },
+ { "FWHost", "Firewall Server" },
+ { "FWPort", "Firewall Port" },
+ { "TestConnection", "Teste Datenbankverbindung" },
+ { "Type", "Datenbank Typ" },
+ { "BequeathConnection", "Bequeath Connection" },
+ { "Overwrite", "ueberschreiben" },
+ { "ConnectionProfile", "Verbindungsprofil" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "Verbindungsfehler" },
+ { "ServerNotActive", "Rechner nicht erreichbar" }
+ };
+
+ /**
+ * Get Contents
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContents
+} // Res_de
diff --git a/dbPort/src/org/compiere/db/DBRes_es.java b/dbPort/src/org/compiere/db/DBRes_es.java
new file mode 100644
index 0000000000..a7544e3156
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_es.java
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author Erwin Cortes
+ * @version $Id: DBRes_es.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_es extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]{
+ { "CConnectionDialog", "Conexión ADempiere" },
+ { "Name", "Nombre" },
+ { "AppsHost", "Servidor de Aplicación" },
+ { "AppsPort", "Puerto de Aplicación" },
+ { "TestApps", "Test de Aplicación" },
+ { "DBHost", "Host de Base de Datos" },
+ { "DBPort", "Puerto de Base de Datos" },
+ { "DBName", "Nombre de Base de datos" },
+ { "DBUidPwd", "Usuario / Contraseņa" },
+ { "ViaFirewall", "vía Firewall" },
+ { "FWHost", "Servidor de Firewall" },
+ { "FWPort", "Puerto del Firewall" },
+ { "TestConnection", "Test de Base de datos" },
+ { "Type", "Tipo de Base de Datos" },
+ { "BequeathConnection", "Conexión Heredada" },
+ { "Overwrite", "Sobreescribir" },
+ { "RMIoverHTTP", "Tunelizar Objetos vía HTTP" },
+ { "ConnectionError", "Error en conexión" },
+ { "ServerNotActive", "Servidor inactivo" }};
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ }
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_fa.java b/dbPort/src/org/compiere/db/DBRes_fa.java
new file mode 100644
index 0000000000..e66572b377
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_fa.java
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author .
+ * @version $Id: DBRes_fa.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_fa extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]{
+ { "CConnectionDialog", "\u0627\u062a\u0635\u0627\u0644 \u0628\u0647 \u06a9\u0627\u0645\u067e\u064a\u0631\u0647" },
+ { "Name", "\u0646\u0627\u0645" },
+ { "AppsHost", "\u0633\u064a\u0633\u062a\u0645 \u0645\u064a\u0632\u0628\u0627\u0646 \u06a9\u0627\u0631\u0628\u0631\u062f" },
+ { "AppsPort", "\u062f\u0631\u06af\u0627\u0647 \u06a9\u0627\u0631\u0628\u0631\u062f" },
+ { "TestApps", "\u0633\u0631\u0648\u0631 \u06a9\u0627\u0631\u0628\u0631\u062f \u0622\u0632\u0645\u0627\u064a\u0634\u06cc" },
+ { "DBHost", "\u0645\u064a\u0632\u0628\u0627\u0646 \u0628\u0627\u0646\u06a9 \u0627\u0637\u0644\u0627\u0639\u0627\u062a\u06cc" },
+ { "DBPort", "\u062f\u0631\u06af\u0627\u0647 \u0628\u0627\u0646\u06a9 \u0627\u0637\u0644\u0627\u0639\u0627\u062a\u06cc" },
+ { "DBName", "\u0646\u0627\u0645 \u0628\u0627\u0646\u06a9 \u0627\u0637\u0644\u0627\u0639\u0627\u062a" },
+ { "DBUidPwd", "\u0645\u0634\u062e\u0635\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u0646\u062f\u0647 \u0648 \u06a9\u0644\u0645\u0647 \u0639\u0628\u0648\u0631" },
+ { "ViaFirewall", "\u0627\u0632 \u0637\u0631\u0650\u064a\u0642 \u0641\u0627\u064a\u0631\u0648\u0627\u0644" },
+ { "FWHost", "\u0645\u064a\u0632\u0628\u0627\u0646 \u0641\u0627\u064a\u0631\u0648\u0627\u0644" },
+ { "FWPort", "\u062f\u0631\u06af\u0627\u0647 \u0641\u0627\u064a\u0631\u0648\u0627\u0644" },
+ { "TestConnection", "\u0628\u0627\u0646\u06a9 \u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0622\u0632\u0645\u0627\u064a\u0634" },
+ { "Type", "\u0646\u0648\u0639 \u0628\u0627\u0646\u06a9 \u0627\u0637\u0644\u0627\u0639\u0627\u062a" },
+ { "BequeathConnection", "\u0627\u062a\u0635\u0627\u0644 \u062a\u062e\u0635\u064a\u0635 \u062f\u0627\u062f\u0647 \u0634\u062f\u0647" },
+ { "Overwrite", "\u0628\u0627\u0632\u0646\u0648\u064a\u0633\u06cc" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "\u062e\u0637\u0627 \u062f\u0631 \u0627\u062a\u0635\u0627\u0644" },
+ { "ServerNotActive", "\u0633\u0631\u0648\u0631 \u0641\u0639\u0627\u0644 \u0646\u064a\u0633\u062a" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_fi.java b/dbPort/src/org/compiere/db/DBRes_fi.java
new file mode 100644
index 0000000000..e8baca5b19
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_fi.java
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings for Finnish language
+ *
+ * @author Petteri Soininen (petteri.soininen@netorek.fi)
+ * @version $Id: DBRes_fi.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_fi extends ListResourceBundle
+{
+ /**
+ * Data
+ */
+ static final Object[][] contents = new String[][]{
+ { "CConnectionDialog", "Adempiere-yhteys" },
+ { "Name", "Nimi" },
+ { "AppsHost", "Sovellusverkkoasema" },
+ { "AppsPort", "Sovellusportti" },
+ { "TestApps", "Testisovelluspalvelin" },
+ { "DBHost", "Tietokantaverkkoasema" },
+ { "DBPort", "Tietokantaportti" },
+ { "DBName", "Tietokannan nimi" },
+ { "DBUidPwd", "Kïŋ―yttïŋ―jïŋ―tunnus / Salasana" },
+ { "ViaFirewall", "Palomuurin lïŋ―pi" },
+ { "FWHost", "Palomuuriverkkoasema" },
+ { "FWPort", "Palomuuriportti" },
+ { "TestConnection", "Testitietokanta" },
+ { "Type", "Tietokantatyyppi" },
+ { "BequeathConnection", "Periytyvïŋ― yhteys" },
+ { "Overwrite", "Korvaa" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "Yhteysvirhe" },
+ { "ServerNotActive", "Palvelin ei aktiivinen" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
+
diff --git a/dbPort/src/org/compiere/db/DBRes_fr.java b/dbPort/src/org/compiere/db/DBRes_fr.java
new file mode 100644
index 0000000000..86083a075e
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_fr.java
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings (French)
+ *
+ * @author Jean-Luc SCHEIDEGGER
+ * @version $Id: DBRes_fr.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_fr extends ListResourceBundle
+{
+ /** Translation Content */
+ static final Object[][] contents = new String[][]
+ {
+ { "CConnectionDialog", "Connexion Adempiere" },
+ { "Name", "Nom" },
+ { "AppsHost", "Hote d'Application" },
+ { "AppsPort", "Port de l'Application" },
+ { "TestApps", "Application de Test" },
+ { "DBHost", "Hote Base de Donnïŋ―es" },
+ { "DBPort", "Port Base de Donnïŋ―es" },
+ { "DBName", "Nom Base de Donnïŋ―es" },
+ { "DBUidPwd", "Utilisateur / Mot de Passe" },
+ { "ViaFirewall", "via Firewall" },
+ { "FWHost", "Hote Firewall" },
+ { "FWPort", "Port Firewall" },
+ { "TestConnection", "Test Base de Donnïŋ―es" },
+ { "Type", "Type Base de Donnïŋ―es" },
+ { "BequeathConnection", "Connexion dïŋ―diïŋ―e" },
+ { "Overwrite", "Ecraser" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "Erreur Connexion" },
+ { "ServerNotActive", "Serveur Non Actif" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContents
+} // DBRes_fr
diff --git a/dbPort/src/org/compiere/db/DBRes_hr.java b/dbPort/src/org/compiere/db/DBRes_hr.java
new file mode 100644
index 0000000000..ae21343e9f
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_hr.java
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author Marko Bubalo
+ * @version $Id: DBRes_hr.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_hr extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]{
+ { "CConnectionDialog", "Adempiere veza" },
+ { "Name", "Naziv" },
+ { "AppsHost", "Host aplikacije" },
+ { "AppsPort", "Port aplikacije" },
+ { "TestApps", "Testiranje servera" },
+ { "DBHost", "Host baze" },
+ { "DBPort", "Port baze" },
+ { "DBName", "Naziv baze" },
+ { "DBUidPwd", "Korisnik / lozinka" },
+ { "ViaFirewall", "via Firewall" },
+ { "FWHost", "Firewall Host" },
+ { "FWPort", "Firewall Port" },
+ { "TestConnection", "Tesiranje baze" },
+ { "Type", "Tip baze" },
+ { "BequeathConnection", "Bequeath Connection" },
+ { "Overwrite", "Prebrisati" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "Greïŋ―ka u vezi" },
+ { "ServerNotActive", "Server nije aktivan" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
+
diff --git a/dbPort/src/org/compiere/db/DBRes_in.java b/dbPort/src/org/compiere/db/DBRes_in.java
new file mode 100644
index 0000000000..94d58bf8d7
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_in.java
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author Halim Englen
+ * @version $Id: DBRes_in.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_in extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]{
+ { "CConnectionDialog", "Koneksi Ke Adempiere" },
+ { "Name", "Nama" },
+ { "AppsHost", "Pusat Aplikasi" },
+ { "AppsPort", "Port Aplikasi" },
+ { "TestApps", "Uji Server Aplikasi" },
+ { "DBHost", "Pusat Database" },
+ { "DBPort", "Port Database" },
+ { "DBName", "Nama Database" },
+ { "DBUidPwd", "ID Pengguna / Kata Sandi" },
+ { "ViaFirewall", "lewat Firewall" },
+ { "FWHost", "Pusat Firewall" },
+ { "FWPort", "Port Firewall" },
+ { "TestConnection", "Uji Koneksi" },
+ { "Type", "Tipe Database" },
+ { "BequeathConnection", "Koneksi Warisan" },
+ { "Overwrite", "Timpakan" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "Kesalahan Koneksi" },
+ { "ServerNotActive", "Server tidak aktif" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_it.java b/dbPort/src/org/compiere/db/DBRes_it.java
new file mode 100644
index 0000000000..a66b279ce7
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_it.java
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author Alessandro Riolo
+ * @version $Id: DBRes_it.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_it extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]{
+ { "CConnectionDialog", "Connessione a Adempiere" },
+ { "Name", "Nome" },
+ { "AppsHost", "Host dell'Applicativo" },
+ { "AppsPort", "Porta dell'Applicativo" },
+ { "TestApps", "Applicazione di Test" },
+ { "DBHost", "Host del Database" },
+ { "DBPort", "Porta del Database" },
+ { "DBName", "Nome del Database" },
+ { "DBUidPwd", "Utente / Password" },
+ { "ViaFirewall", "via Firewall" },
+ { "FWHost", "Host del Firewall" },
+ { "FWPort", "Porta del Firewall" },
+ { "TestConnection", "Database di Test" },
+ { "Type", "Tipo di Database" },
+ { "BequeathConnection", "Connessione Dedicata" },
+ { "Overwrite", "Sovrascri" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "Errore di Connessione" },
+ { "ServerNotActive", "Server non Attivo" }};
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ }
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_ja.java b/dbPort/src/org/compiere/db/DBRes_ja.java
new file mode 100644
index 0000000000..1a1ad65675
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_ja.java
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author Stefan Christians
+ * @version $Id: DBRes_ja.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_ja extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]{
+ { "CConnectionDialog", "\u30b3\u30f3\u30d4\u30a8\u30fc\u30ec\u306e\u63a5\u7d9a" },
+ { "Name", "\u540d\u524d" },
+ { "AppsHost", "\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30fb\u30b5\u30fc\u30d0" },
+ { "AppsPort", "\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30fb\u30dd\u30fc\u30c8" },
+ { "TestApps", "\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30fb\u30b5\u30fc\u30d0\u306e\u30c6\u30b9\u30c8" },
+ { "DBHost", "\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30fb\u30b5\u30fc\u30d0" },
+ { "DBPort", "\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30fb\u30dd\u30fc\u30c8" },
+ { "DBName", "\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u540d\u524d" },
+ { "DBUidPwd", "\u30e6\u30fc\u30b6 / \u30d1\u30b9\u30ef\u30fc\u30c9" },
+ { "ViaFirewall", "\u30d5\u30a1\u30a4\u30a2\u30a6\u30a9\u30fc\u30eb" },
+ { "FWHost", "\u30d5\u30a1\u30a4\u30a2\u30a6\u30a9\u30fc\u30eb\u30fb\u30b5\u30fc\u30d0" },
+ { "FWPort", "\u30d5\u30a1\u30a4\u30a2\u30a6\u30a9\u30fc\u30eb\u30fb\u30dd\u30fc\u30c8" },
+ { "TestConnection", "\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30fb\u30b5\u30fc\u30d0\u306e\u30c6\u30b9\u30c8" },
+ { "Type", "\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9" },
+ { "BequeathConnection", "\u53e4\u63a5\u7d9a" },
+ { "Overwrite", "\u30aa\u30fc\u30f4\u30a1\u30e9\u30a4\u30c8" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "\u63a5\u7d9a\u306e\u30a8\u30e9\u30fc" },
+ { "ServerNotActive", "\u30b5\u30fc\u30d0\u3092\u898b\u4ed8\u3051\u308c\u306a\u3044" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_ml.java b/dbPort/src/org/compiere/db/DBRes_ml.java
new file mode 100644
index 0000000000..3298fe5c97
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_ml.java
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author .
+ * @version $Id: DBRes_ml.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_ml extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]
+ {
+ { "CConnectionDialog", "Adempiere Connection" },
+ { "Name", "Name" },
+ { "AppsHost", "Application Host" },
+ { "AppsPort", "Application Port" },
+ { "TestApps", "Test Application" },
+ { "DBHost", "Database Host" },
+ { "DBPort", "Database Port" },
+ { "DBName", "Database Name" },
+ { "DBUidPwd", "User / Password" },
+ { "ViaFirewall", "via Firewall" },
+ { "FWHost", "Firewall Host" },
+ { "FWPort", "Firewall Port" },
+ { "TestConnection", "Test Database" },
+ { "Type", "Database Type" },
+ { "BequeathConnection", "Bequeath Connection" },
+ { "Overwrite", "Overwrite" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "Connection Error" },
+ { "ServerNotActive", "Server Not Active" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_nl.java b/dbPort/src/org/compiere/db/DBRes_nl.java
new file mode 100644
index 0000000000..ba7ff7e4b6
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_nl.java
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author Eldir Tomassen
+ * @version $Id: DBRes_nl.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_nl extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]
+ {
+ { "CConnectionDialog", "Verbinding met Adempiere" },
+ { "Name", "Naam" },
+ { "AppsHost", "Applicatie Server" },
+ { "AppsPort", "Applicatie Poort" },
+ { "TestApps", "Test Applicatie" },
+ { "DBHost", "Database Server" },
+ { "DBPort", "Database Poort" },
+ { "DBName", "Database Naam" },
+ { "DBUidPwd", "Gebruikersnaam / Wachtwoord" },
+ { "ViaFirewall", "via Firewall" },
+ { "FWHost", "Firewall" },
+ { "FWPort", "Firewall Poort" },
+ { "TestConnection", "Test Database" },
+ { "Type", "Database Type" },
+ { "BequeathConnection", "Lokale Connectie" },
+ { "Overwrite", "Overschrijven" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "Fout bij verbinden" },
+ { "ServerNotActive", "Server Niet Actief" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_no.java b/dbPort/src/org/compiere/db/DBRes_no.java
new file mode 100644
index 0000000000..385cffdeb5
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_no.java
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Norwegian Connection Resource Strings
+ *
+ * @author Olaf Slazak Lïŋ―ken
+ * @version $Id: DBRes_no.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_no extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]
+ {
+ { "CConnectionDialog", "Adempiere Forbindelse" },
+ { "Name", "Navn" },
+ { "AppsHost", "Applikasjon Maskine" },
+ { "AppsPort", "Applikasjon Port" },
+ { "TestApps", "Test Applikasjon " },
+ { "DBHost", "Database Maskin" },
+ { "DBPort", "Database Port" },
+ { "DBName", "Database Navn" },
+ { "DBUidPwd", "Bruker /Passord" },
+ { "ViaFirewall", "Gjennom Brannmur" },
+ { "FWHost", "Brannmur Maskin" },
+ { "FWPort", "Brannmur Port" },
+ { "TestConnection", "Test Database" },
+ { "Type", "Database Type" },
+ { "BequeathConnection", "Bequeath Forbindelse" },
+ { "Overwrite", "Overskriv" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "Feil ved Oppkobling" },
+ { "ServerNotActive", "Server Ikke Aktivert" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_pl.java b/dbPort/src/org/compiere/db/DBRes_pl.java
new file mode 100644
index 0000000000..8116b1150b
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_pl.java
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author Adam Bodurka
+ * @version $Id: DBRes_pl.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_pl extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]
+ {
+ { "CConnectionDialog", "Po\u0142\u0105czenie z Adempiere" },
+ { "Name", "Nazwa" },
+ { "AppsHost", "Host Aplikacji" },
+ { "AppsPort", "Port Aplikacji" },
+ { "TestApps", "Test Aplikacji" },
+ { "DBHost", "Host Bazy Danych" },
+ { "DBPort", "Port Bazy Danych" },
+ { "DBName", "Nazwa Bazy Danych" },
+ { "DBUidPwd", "U\u017cytkownik / Has\u0142o" },
+ { "ViaFirewall", "via Firewall" },
+ { "FWHost", "Host Firewall-a" },
+ { "FWPort", "Port Firewall-a" },
+ { "TestConnection", "Test Bazy Danych" },
+ { "Type", "Typ Bazy Danych" },
+ { "BequeathConnection", "Zapisuj Po\u0142\u0105czenie" },
+ { "Overwrite", "Nadpisuj" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "B\u0142\u0105d po\u0142\u0105czenia" },
+ { "ServerNotActive", "Serwer nie jest aktywny" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_pt.java b/dbPort/src/org/compiere/db/DBRes_pt.java
new file mode 100644
index 0000000000..c8aa88b09d
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_pt.java
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author Jesse Jr
+ * @version $Id: DBRes_pt.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_pt extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]
+ {
+ { "CConnectionDialog", "Adempiere Conexïŋ―o" },
+ { "Name", "Nome" },
+ { "AppsHost", "Servidor de Aplicaïŋ―ïŋ―o" },
+ { "AppsPort", "Porta TCP da Aplicaïŋ―ïŋ―o" },
+ { "TestApps", "Testar Aplicaïŋ―ïŋ―o" },
+ { "DBHost", "Servidor do Banco de Dado" },
+ { "DBPort", "Porta TCP do Banco de Dados" },
+ { "DBName", "Nome do Banco de Dados" },
+ { "DBUidPwd", "Usuïŋ―rio / Senha" },
+ { "ViaFirewall", "via Firewall" },
+ { "FWHost", "Servidor de Firewall" },
+ { "FWPort", "Porta TCP do Firewall" },
+ { "TestConnection", "Testar Banco de Dados" },
+ { "Type", "Tipo de Banco de Dados" },
+ { "BequeathConnection", "Conexïŋ―o Bequeath" },
+ { "Overwrite", "Sobrescrever" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "Erro de Conexïŋ―o" },
+ { "ServerNotActive", "Servidor nïŋ―o Ativo" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_ro.java b/dbPort/src/org/compiere/db/DBRes_ro.java
new file mode 100644
index 0000000000..255faffe73
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_ro.java
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author Jorg Janke
+ * @version $Id: DBRes_ro.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_ro extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]{
+ { "CConnectionDialog", "Conexiune" },
+ { "Name", "Nume" },
+ { "AppsHost", "Server de aplica\u0163ie" },
+ { "AppsPort", "Port de aplica\u0163ie" },
+ { "TestApps", "Testare a serverului de aplica\u0163ie" },
+ { "DBHost", "Server de baz\u0103 de date" },
+ { "DBPort", "Port de baz\u0103 de date" },
+ { "DBName", "Numele bazei de date" },
+ { "DBUidPwd", "Utilizator / parol\u0103" },
+ { "ViaFirewall", "Prin firewall" },
+ { "FWHost", "Gazd\u0103 de firewall" },
+ { "FWPort", "Port de firewall" },
+ { "TestConnection", "Testare a bazei de date" },
+ { "Type", "Tip al bazei de date" },
+ { "BequeathConnection", "Cedare de conexiune" },
+ { "Overwrite", "Suprascriere" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "Eroare de conexiune" },
+ { "ServerNotActive", "Serverul este inactiv" }
+ };
+
+ /**
+ * Get Contents
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_ru.java b/dbPort/src/org/compiere/db/DBRes_ru.java
new file mode 100644
index 0000000000..d59a51dc14
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_ru.java
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author Vyacheslav Pedak
+ * @version $Id: DBRes_ru.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_ru extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]
+ {
+ { "CConnectionDialog", "\u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 Adempiere" },
+ { "Name", "\u0418\u043c\u044f" },
+ { "AppsHost", "\u0421\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f" },
+ { "AppsPort", "\u041f\u043e\u0440\u0442" },
+ { "TestApps", "\u0422\u0435\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435" },
+ { "DBHost", "\u0421\u0435\u0440\u0432\u0435\u0440 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445" },
+ { "DBPort", "\u041f\u043e\u0440\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445" },
+ { "DBName", "\u0418\u043c\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445" },
+ { "DBUidPwd", "\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c / \u041f\u0430\u0440\u043e\u043b\u044c" },
+ { "ViaFirewall", "\u0447\u0435\u0440\u0435\u0437 Firewall" },
+ { "FWHost", "\u0421\u0435\u0440\u0432\u0435\u0440 Firewall" },
+ { "FWPort", "\u041f\u043e\u0440\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 Firewall" },
+ { "TestConnection", "\u0422\u0435\u0441\u0442\u043e\u0432\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445" },
+ { "Type", "\u0422\u0438\u043f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445" },
+ { "BequeathConnection", "Bequeath \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435" },
+ { "Overwrite", "\u041f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "\u041e\u0448\u0438\u0431\u043a\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f" },
+ { "ServerNotActive", "\u0421\u0435\u0440\u0432\u0435\u0440 \u043d\u0435 \u0430\u043a\u0442\u0438\u0432\u0435\u043d" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_sl.java b/dbPort/src/org/compiere/db/DBRes_sl.java
new file mode 100644
index 0000000000..f5996cfcf7
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_sl.java
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author Matja\u017e Godec
+ * @version $Id: DBRes_sl.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_sl extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]{
+ { "CConnectionDialog", "Adempiere povezava" },
+ { "Name", "Ime" },
+ { "AppsHost", "Programski stre\u017enik" },
+ { "AppsPort", "Vrata programskega stre\u017enika" },
+ { "TestApps", "Test programskega stre\u017enika" },
+ { "DBHost", "Stre\u017enik baze podatkov" },
+ { "DBPort", "Vrata baze podatkov" },
+ { "DBName", "Ime baze podatkov" },
+ { "DBUidPwd", "Uporabnik / geslo" },
+ { "ViaFirewall", "Skozi po\u017earni zid" },
+ { "FWHost", "Po\u017earni zid" },
+ { "FWPort", "Vrata po\u017earnega zidu" },
+ { "TestConnection", "Testiranje baze podatkov" },
+ { "Type", "Tip baze podatkov" },
+ { "BequeathConnection", "Bequeath Connection" },
+ { "Overwrite", "Prepi\u0161i" },
+ { "ConnectionProfile", "Povezava" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "Napaka na povezavi" },
+ { "ServerNotActive", "Stre\u017enik ni aktiven" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
+
diff --git a/dbPort/src/org/compiere/db/DBRes_sv.java b/dbPort/src/org/compiere/db/DBRes_sv.java
new file mode 100644
index 0000000000..da946c2a7d
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_sv.java
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Swedish Connection Resource Strings
+ *
+ * @author Thomas Dilts
+ * @version $Id: DBRes_sv.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_sv extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]
+ {
+ { "CConnectionDialog", "Adempiere anslutning" },
+ { "Name", "Namn" },
+ { "AppsHost", "Program vïŋ―rddator" },
+ { "AppsPort", "Program port" },
+ { "TestApps", "Test program" },
+ { "DBHost", "Databas vïŋ―rddator" },
+ { "DBPort", "Databas port" },
+ { "DBName", "Databas namn" },
+ { "DBUidPwd", "Anvïŋ―ndarnamn / lïŋ―senord" },
+ { "ViaFirewall", "via Firewall" },
+ { "FWHost", "Firewall vïŋ―rddator" },
+ { "FWPort", "Firewall port" },
+ { "TestConnection", "Test databas" },
+ { "Type", "Databas typ" },
+ { "BequeathConnection", "Efterlïŋ―mna anslutning" },
+ { "Overwrite", "Skriv ïŋ―ver" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "Anslutningsfel" },
+ { "ServerNotActive", "Server ej activ" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_th.java b/dbPort/src/org/compiere/db/DBRes_th.java
new file mode 100644
index 0000000000..e48f91c518
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_th.java
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings (Thai)
+ *
+ * @author Sureeraya Limpaibul
+ * @version $Id: DBRes_th.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_th extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]{
+ { "CConnectionDialog", "Adempiere Connection" },
+ { "Name", "\u0e0a\u0e37\u0e48\u0e2d" },
+ { "AppsHost", "\u0e41\u0e2d\u0e47\u0e1e\u0e1e\u0e25\u0e34\u0e40\u0e04\u0e0a\u0e31\u0e48\u0e19 \u0e42\u0e2e\u0e2a" },
+ { "AppsPort", "\u0e41\u0e2d\u0e47\u0e1e\u0e1e\u0e25\u0e34\u0e40\u0e04\u0e0a\u0e31\u0e48\u0e19 \u0e1e\u0e2d\u0e23\u0e4c\u0e15" },
+ { "TestApps", "\u0e17\u0e14\u0e2a\u0e2d\u0e1a\u0e41\u0e2d\u0e47\u0e1e\u0e1e\u0e25\u0e34\u0e40\u0e04\u0e0a\u0e31\u0e48\u0e19" },
+ { "DBHost", "\u0e42\u0e2e\u0e2a\u0e02\u0e2d\u0e07\u0e10\u0e32\u0e19\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25" },
+ { "DBPort", "\u0e1e\u0e2d\u0e23\u0e4c\u0e15\u0e02\u0e2d\u0e07\u0e10\u0e32\u0e19\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25" },
+ { "DBName", "\u0e0a\u0e37\u0e48\u0e2d\u0e10\u0e32\u0e19\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25" },
+ { "DBUidPwd", "\u0e0a\u0e37\u0e48\u0e2d\u0e1c\u0e39\u0e49\u0e43\u0e0a\u0e49 / \u0e23\u0e2b\u0e31\u0e2a\u0e1c\u0e48\u0e32\u0e19" },
+ { "ViaFirewall", "\u0e1c\u0e48\u0e32\u0e19\u0e44\u0e1f\u0e23\u0e27\u0e2d\u0e25" },
+ { "FWHost", "\u0e44\u0e1f\u0e23\u0e27\u0e2d\u0e25 \u0e42\u0e2e\u0e2a" },
+ { "FWPort", "\u0e1e\u0e2d\u0e23\u0e4c\u0e15\u0e44\u0e1f\u0e23\u0e27\u0e2d\u0e25" },
+ { "TestConnection", "\u0e17\u0e14\u0e2a\u0e2d\u0e1a\u0e10\u0e32\u0e19\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25" },
+ { "Type", "\u0e1b\u0e23\u0e30\u0e40\u0e20\u0e17\u0e10\u0e32\u0e19\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25" },
+ { "BequeathConnection", "Bequeath Connection" },
+ { "Overwrite", "\u0e1a\u0e31\u0e19\u0e17\u0e36\u0e01\u0e17\u0e31\u0e1a" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "\u0e01\u0e32\u0e23\u0e40\u0e0a\u0e37\u0e48\u0e2d\u0e21\u0e15\u0e48\u0e2d\u0e1c\u0e34\u0e14\u0e1e\u0e25\u0e32\u0e14" },
+ { "ServerNotActive", "\u0e40\u0e0a\u0e34\u0e23\u0e4c\u0e1f\u0e40\u0e27\u0e2d\u0e23\u0e4c\u0e44\u0e21\u0e48\u0e41\u0e2d\u0e47\u0e04\u0e17\u0e35\u0e1f" }};
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ }
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_vi.java b/dbPort/src/org/compiere/db/DBRes_vi.java
new file mode 100644
index 0000000000..9c31fa2b88
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_vi.java
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author Bui Chi Trung
+ * @version $Id: DBRes_vi.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_vi extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]
+ {
+ { "CConnectionDialog", "K\u1EBFt n\u1ED1i" },
+ { "Name", "Tïŋ―n" },
+ { "AppsHost", "Mïŋ―y ch\u1EE7 \u1EE9ng d\u1EE5ng" },
+ { "AppsPort", "C\u1ED5ng \u1EE9ng d\u1EE5ng" },
+ { "TestApps", "Th\u1EED nghi\u1EC7m \u1EE9ng d\u1EE5ng" },
+ { "DBHost", "Mïŋ―y ch\u1EE7 CSDL" },
+ { "DBPort", "C\u1ED5ng CSDL" },
+ { "DBName", "Tïŋ―n CSDL" },
+ { "DBUidPwd", "Ng\u01B0\u1EDDi dïŋ―ng / M\u1EADt kh\u1EA9u" },
+ { "ViaFirewall", "Qua b\u1EE9c t\u01B0\u1EDDng l\u1EEDa" },
+ { "FWHost", "Mïŋ―y ch\u1EE7 b\u1EE9c t\u01B0\u1EDDng l\u1EEDa" },
+ { "FWPort", "C\u1ED5ng vïŋ―o b\u1EE9c t\u01B0\u1EDDng l\u1EEDa" },
+ { "TestConnection", "Ki\u1EC3m tra CSDL" },
+ { "Type", "Lo\u1EA1i CSDL" },
+ { "BequeathConnection", "Truy\u1EC1n l\u1EA1i k\u1EBFt n\u1ED1i" },
+ { "Overwrite", "Ghi \u0111ïŋ―" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "L\u1ED7i k\u1EBFt n\u1ED1i" },
+ { "ServerNotActive", "Mïŋ―y ch\u1EE7 hi\u1EC7n khïŋ―ng ho\u1EA1t \u0111\u1ED9ng" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_zh.java b/dbPort/src/org/compiere/db/DBRes_zh.java
new file mode 100644
index 0000000000..055b304e0a
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_zh.java
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author kirinlin
+ * @version $Id: DBRes_zh.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_zh extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]
+ {
+ { "CConnectionDialog", "Adempiere \u9023\u7dda" },
+ { "Name", "\u540d\u7a31" },
+ { "AppsHost", "\u61c9\u7528\u7a0b\u5f0f\u4e3b\u6a5f" },
+ { "AppsPort", "\u61c9\u7528\u7a0b\u5f0f\u57e0" },
+ { "TestApps", "\u6e2c\u8a66" },
+ { "DBHost", "\u8cc7\u6599\u5eab\u4e3b\u6a5f" },
+ { "DBPort", "\u8cc7\u6599\u5eab\u9023\u63a5\u57e0" },
+ { "DBName", "\u8cc7\u6599\u5eab\u540d\u7a31" },
+ { "DBUidPwd", "\u5e33\u865f / \u5bc6\u78bc" },
+ { "ViaFirewall", "\u7d93\u904e\u9632\u706b\u7246" },
+ { "FWHost", "\u9632\u706b\u7246\u4e3b\u6a5f" },
+ { "FWPort", "\u9632\u706b\u7246\u57e0" },
+ { "TestConnection", "\u6e2c\u8a66\u8cc7\u6599\u5eab" },
+ { "Type", "\u8cc7\u6599\u5eab\u7a2e\u985e" },
+ { "BequeathConnection", "\u907a\u7559\u9023\u7dda" },
+ { "Overwrite", "\u8986\u5beb" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "\u9023\u7dda\u932f\u8aa4" },
+ { "ServerNotActive", "\u4f3a\u670d\u5668\u672a\u52d5\u4f5c" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
diff --git a/dbPort/src/org/compiere/db/DBRes_zh_CN.java b/dbPort/src/org/compiere/db/DBRes_zh_CN.java
new file mode 100644
index 0000000000..e1803f6ebd
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DBRes_zh_CN.java
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+
+/**
+ * Connection Resource Strings
+ *
+ * @author ZhaoXing Meng
+ * @version $Id: DBRes_zh_CN.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class DBRes_zh_CN extends ListResourceBundle
+{
+ /** Data */
+ static final Object[][] contents = new String[][]
+ {
+ { "CConnectionDialog", "Adempiere \u8fde\u673a" },
+ { "Name", "\u540d\u79f0" },
+ { "AppsHost", "\u5e94\u7528\u670d\u52a1\u5668\u4e3b\u673a" },
+ { "AppsPort", "\u5e94\u7528\u670d\u52a1\u5668\u7aef\u53e3" },
+ { "TestApps", "\u6d4b\u8bd5\u5e94\u7528\u670d\u52a1\u5668" },
+ { "DBHost", "\u6570\u636e\u5e93\u4e3b\u673a" },
+ { "DBPort", "\u6570\u636e\u5e93\u7aef\u53e3" },
+ { "DBName", "\u6570\u636e\u5e93\u540d" },
+ { "DBUidPwd", "\u7528\u6237\u53f7 / \u53e3\u4ee4" },
+ { "ViaFirewall", "\u901a\u8fc7\u9632\u706b\u5899" },
+ { "FWHost", "\u9632\u706b\u5899\u4e3b\u673a" },
+ { "FWPort", "\u9632\u706b\u5899\u7aef\u53e3" },
+ { "TestConnection", "\u6d4b\u8bd5\u6570\u636e\u5e93" },
+ { "Type", "\u6570\u636e\u5e93\u7c7b\u578b" },
+ { "BequeathConnection", "\u9057\u7559\u8fde\u7ebf" },
+ { "Overwrite", "\u8986\u5199" },
+ { "ConnectionProfile", "Connection" },
+ { "LAN", "LAN" },
+ { "TerminalServer", "Terminal Server" },
+ { "VPN", "VPN" },
+ { "WAN", "WAN" },
+ { "ConnectionError", "\u8fde\u673a\u9519\u8bef" },
+ { "ServerNotActive", "\u670d\u52a1\u5668\u6ca1\u53cd\u5e94" }
+ };
+
+ /**
+ * Get Contsnts
+ * @return contents
+ */
+ public Object[][] getContents()
+ {
+ return contents;
+ } // getContent
+} // Res
diff --git a/dbPort/src/org/compiere/db/DB_DB2.java b/dbPort/src/org/compiere/db/DB_DB2.java
new file mode 100644
index 0000000000..0274d6e464
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DB_DB2.java
@@ -0,0 +1,836 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.math.*;
+import java.sql.*;
+import java.util.logging.*;
+import javax.sql.*;
+
+import org.compiere.util.*;
+
+import com.ibm.db2.jcc.*;
+
+/**
+ * DB2 Database Driver
+ *
+ * @author Jorg Janke
+ * @version $Id: DB_DB2.java,v 1.5 2006/09/22 23:35:19 jjanke Exp $
+ */
+public class DB_DB2
+ implements AdempiereDatabase
+{
+ /**
+ * Database DB2
+ */
+ public DB_DB2()
+ {
+
+ } // DB_DB2
+
+ /** Static Driver */
+ private static DB2Driver s_driver = null;
+ /** Driver Class Name */
+ public static final String DRIVER = "com.ibm.db2.jcc.DB2Driver";
+ /** Type 2 Driver */
+ public static final String DRIVER2 = "COM.ibm.db2.jdbc.app.DB2Driver";
+
+ /** Default Port 446 */
+ public static final int DEFAULT_PORT = 446;
+ /** Default Port 50000 */
+ public static final int DEFAULT_PORT_0 = 50000;
+
+ /** Cached User Name */
+ private String m_userName = null;
+
+ /** Connection String */
+ private String m_connectionURL;
+ private DB2SimpleDataSource m_ds = null;
+
+ /** Logger */
+ private static CLogger log = CLogger.getCLogger (DB_DB2.class);
+
+ /**
+ * Get Database Name
+ * @return database short name
+ */
+ public String getName()
+ {
+ return Database.DB_DB2;
+ } // getName
+
+ /**
+ * Get Database Description
+ * @return database long name and version
+ */
+ public String getDescription()
+ {
+ try
+ {
+ if (s_driver == null)
+ getDriver();
+ }
+ catch (Exception e)
+ {
+ }
+ if (s_driver != null)
+ return s_driver.toString();
+ return "No Driver";
+ } // getDescription
+
+ /**
+ * Get Standard JDBC Port
+ * @return standard port
+ */
+ public int getStandardPort()
+ {
+ return DEFAULT_PORT_0;
+ } // getStandardPort
+
+ /**
+ * Get and register Database Driver
+ * @return Driver
+ * @throws SQLException
+ */
+ public Driver getDriver() throws SQLException
+ {
+ if (s_driver == null)
+ {
+ s_driver = new DB2Driver();
+ DriverManager.registerDriver (s_driver);
+ DriverManager.setLoginTimeout (Database.CONNECTION_TIMEOUT);
+ }
+ return s_driver;
+ } // getDriver
+
+ /**
+ * Get Database Connection String.
+ *
+ * Timing:
+ *
+ * @param connection Connection Descriptor
+ * @return connection String
+ */
+ public String getConnectionURL (CConnection connection)
+ {
+ StringBuffer sb = null;
+ // connection//server:port/database
+ sb = new StringBuffer ("jdbc:db2:");
+ // Cloudscape = jdbc:db2j:net:
+ sb.append("//")
+ .append(connection.getDbHost())
+ .append(":").append(connection.getDbPort())
+ .append("/").append(connection.getDbName());
+ m_connectionURL = sb.toString();
+ // log.config(m_connectionURL);
+ //
+ m_userName = connection.getDbUid();
+ return m_connectionURL;
+ } // getConnectionURL
+
+ /**
+ * Get Connection URL.
+ * @param dbHost db Host
+ * @param dbPort db Port
+ * @param dbName db Name
+ * @param userName user name
+ * @return connection
+ */
+ public String getConnectionURL (String dbHost, int dbPort, String dbName,
+ String userName)
+ {
+ m_userName = userName;
+ m_connectionURL = "jdbc:db2://"
+ + dbHost + ":" + dbPort + "/" + dbName;
+ return m_connectionURL;
+ } // getConnectionURL
+
+ /**
+ * Get Database Connection String
+ * @param connectionURL Connection URL
+ * @param userName user name
+ * @return connection String
+ */
+ public String getConnectionURL (String connectionURL, String userName)
+ {
+ m_userName = userName;
+ m_connectionURL = connectionURL;
+ return m_connectionURL;
+ } // getConnectionURL
+
+ /**
+ * Get JDBC Catalog
+ * @return null - not used
+ */
+ public String getCatalog()
+ {
+ return null;
+ } // getCatalog
+
+ /**
+ * Get JDBC Schema
+ * @return user name
+ */
+ public String getSchema()
+ {
+ if (m_userName != null)
+ return m_userName.toUpperCase();
+ log.severe("User Name not set (yet) - call getConnectionURL first");
+ return null;
+ } // getSchema
+
+ /**
+ * Supports BLOB
+ * @return true if BLOB is supported
+ */
+ public boolean supportsBLOB()
+ {
+ return true;
+ } // supportsBLOB
+
+ /**
+ * String Representation
+ * @return info
+ */
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer("DB_DB2[");
+ sb.append(m_connectionURL);
+ sb.append("]");
+ return sb.toString();
+ } // toString
+
+ /**
+ * Get Status
+ * @return status info
+ */
+ public String getStatus()
+ {
+ StringBuffer sb = new StringBuffer();
+ return sb.toString();
+ } // getStatus
+
+
+ /**************************************************************************
+ * Convert an individual Oracle Style statements to target database statement syntax.
+ * @param oraStatement oracle statement
+ * @return converted Statement oracle statement
+ */
+ public String convertStatement (String oraStatement)
+ {
+ return oraStatement;
+ } // convertStatement
+
+
+ /**
+ * Check if DBMS support the sql statement
+ * @sql SQL statement
+ * @return true: yes
+ */
+ public boolean isSupported(String sql)
+ {
+ return true;
+ //jz temp, modify later
+ }
+
+
+
+ /**
+ * Get constraint type associated with the index
+ * @tableName table name
+ * @IXName Index name
+ * @return String[0] = 0: do not know, 1: Primary Key 2: Foreign Key
+ * String[1] - String[n] = Constraint Name
+ */
+ public String getConstraintType(Connection conn, String tableName, String IXName)
+ {
+ if (IXName == null || IXName.length()==0)
+ return "0";
+
+ return "0";
+ //jz temp, modify later
+ }
+
+ /**
+ * Get Name of System User
+ * @return system
+ */
+ public String getSystemUser()
+ {
+ return "db2adm";
+ } // getSystemUser
+
+ /**
+ * Get Name of System Database
+ * @param databaseName database Name
+ * @return e.g. master or database Name
+ */
+ public String getSystemDatabase(String databaseName)
+ {
+ return databaseName;
+ } // getSystemDatabase
+
+
+ /**
+ * Create SQL TO Date String from Timestamp
+ *
+ * @param time Date to be converted
+ * @param dayOnly true if time set to 00:00:00
+ *
+ * @return TO_DATE('1999-12-31 23:59:59', 'YYYY-MM-DD HH24:MI:SS')
+ * or TIMESTAMP('2000-01-10-00.00.00.000000')
+ */
+ public String TO_DATE (Timestamp time, boolean dayOnly)
+ {
+
+ if (time == null)
+ {
+ if (dayOnly)
+ return "trunc(CURRENT TIMESTAMP)";
+ return "CURRENT TIMESTAMP";
+ }
+
+ // TIMESTAMP('2000-01-10-00.00.00.000000')
+ StringBuffer dateString = new StringBuffer("TIMESTAMP('");
+ // YYYY-MM-DD HH24:MI:SS.mmmm JDBC Timestamp format
+ String myDate = time.toString();
+ if (dayOnly)
+ {
+ dateString.append(myDate.substring(0,10));
+ dateString.append("-00.00.00.000000')");
+ }
+ else
+ {
+ myDate = myDate.replace('-', ' ');
+ myDate = myDate.replace(':', '.');
+ dateString.append(myDate);
+ dateString.append("00')");
+ }
+ return dateString.toString();
+ } // TO_DATE
+
+ /**
+ * Create SQL for formatted Date, Number
+ *
+ * @param columnName the column name in the SQL
+ * @param displayType Display Type
+ * @param AD_Language 6 character language setting (from Env.LANG_*)
+ *
+ * @return TRIM(TO_CHAR(columnName,'9G999G990D00','NLS_NUMERIC_CHARACTERS='',.'''))
+ * or TRIM(TO_CHAR(columnName,'TM9')) depending on DisplayType and Language
+ * @see org.compiere.util.DisplayType
+ * @see org.compiere.util.Env
+ *
+ * */
+ public String TO_CHAR (String columnName, int displayType, String AD_Language)
+ {
+ return columnName;
+ /**
+ StringBuffer retValue = new StringBuffer("TRIM(TO_CHAR(");
+ retValue.append(columnName);
+
+ // Numbers
+ if (DisplayType.isNumeric(displayType))
+ {
+ if (displayType == DisplayType.Amount)
+ retValue.append(",'9G999G990D00'");
+ else
+ retValue.append(",'TM9'");
+ // TO_CHAR(GrandTotal,'9G999G990D00','NLS_NUMERIC_CHARACTERS='',.''')
+ if (!Language.isDecimalPoint(AD_Language)) // reversed
+ retValue.append(",'NLS_NUMERIC_CHARACTERS='',.'''");
+ }
+ else if (DisplayType.isDate(displayType))
+ {
+ retValue.append(",'")
+ .append(Language.getLanguage(AD_Language).getDBdatePattern())
+ .append("'");
+ }
+ retValue.append("))");
+ //
+ return retValue.toString();
+ **/
+ } // TO_CHAR
+
+ /**
+ * Return number as string for INSERT statements with correct precision
+ * @param number number
+ * @param displayType display Type
+ * @return number as string
+ */
+ public String TO_NUMBER (BigDecimal number, int displayType)
+ {
+ if (number == null)
+ return "NULL";
+ return number.toString();
+ } // TO_NUMBER
+
+
+ /**
+ * Get SQL Commands.
+ * The following variables are resolved:
+ * @SystemPassword@, @AdempiereUser@, @AdempierePassword@
+ * @SystemPassword@, @DatabaseName@, @DatabaseDevice@
+ * @param cmdType CMD_*
+ * @return array of commands to be executed
+ */
+ public String[] getCommands (int cmdType)
+ {
+ if (CMD_CREATE_USER == cmdType)
+ return new String[]
+ {
+
+ };
+ //
+ if (CMD_CREATE_DATABASE == cmdType)
+ return new String[]
+ {
+
+ };
+ //
+ if (CMD_DROP_DATABASE == cmdType)
+ return new String[]
+ {
+
+ };
+ //
+ return null;
+ } // getCommands
+
+ /**
+ * Create DataSource
+ * @param connection connection
+ * @return data dource
+ */
+ public DataSource getDataSource(CConnection connection)
+ {
+ if (m_ds == null)
+ {
+ m_ds = new DB2SimpleDataSource();
+ m_ds.setServerName(connection.getDbHost());
+ m_ds.setPortNumber(connection.getDbPort());
+ m_ds.setDatabaseName(connection.getDbName());
+ m_ds.setDescription("Adempiere DataSource");
+ m_ds.setUser(connection.getDbUid());
+ m_ds.setPassword(connection.getDbPwd());
+ m_ds.setLoginTimeout(5); // seconds
+ // m_ds.setUseCachedCursor(true);
+ }
+ return m_ds;
+ } // getDataSource
+
+
+ /**
+ * Get Cached Connection
+ * @param connection info
+ * @param autoCommit true if autocommit connection
+ * @param transactionIsolation Connection transaction level
+ * @return connection or null
+ * @throws Exception
+ */
+ public Connection getCachedConnection (CConnection connection,
+ boolean autoCommit, int transactionIsolation)
+ throws Exception
+ {
+ Connection conn = getDataSource(connection).getConnection();
+ conn.setAutoCommit(autoCommit);
+ conn.setTransactionIsolation(transactionIsolation);
+ return conn;
+ } // getCachedConnection
+
+ /**
+ * Get Connection from Driver
+ * @param connection info
+ * @return connection or null
+ * @throws SQLException
+ */
+ public Connection getDriverConnection (CConnection connection) throws SQLException
+ {
+ getDriver();
+ return DriverManager.getConnection (getConnectionURL (connection),
+ connection.getDbUid(), connection.getDbPwd());
+ } // getDriverConnection
+
+ /**
+ * Get Driver Connection
+ * @param dbUrl URL
+ * @param dbUid user
+ * @param dbPwd password
+ * @return connection
+ * @throws SQLException
+ */
+ public Connection getDriverConnection (String dbUrl, String dbUid, String dbPwd)
+ throws SQLException
+ {
+ getDriver();
+ return DriverManager.getConnection (dbUrl, dbUid, dbPwd);
+ } // getDriverConnection
+
+ /**
+ * Close
+ */
+ public void close()
+ {
+ log.config(toString());
+ m_ds = null;
+ } // close
+
+ /**
+ * Clean up
+ */
+ public void cleanup()
+ {
+ log.config("");
+ } // cleanup
+
+
+ /**
+ * Get Data Type
+ * @param displayType display type
+ * @param precision precision
+ * @param defaultValue if true adds default value
+ * @return data type
+ */
+ public String getDataType (int displayType, int precision,
+ boolean defaultValue)
+ {
+ String retValue = null;
+ switch (displayType)
+ {
+ // IDs
+ case DisplayType.Account:
+ case DisplayType.Assignment:
+ case DisplayType.Color:
+ case DisplayType.ID:
+ case DisplayType.Location:
+ case DisplayType.Locator:
+ case DisplayType.PAttribute:
+ case DisplayType.Search:
+ case DisplayType.Table:
+ case DisplayType.TableDir:
+ case DisplayType.Image:
+ retValue = "INTEGER";
+ break;
+
+ // Dynamic Precision
+ case DisplayType.Amount:
+ retValue = "DECIMAL(18,2)";
+ if (defaultValue)
+ retValue += " DEFAULT 0";
+ break;
+
+ case DisplayType.Binary:
+ retValue = "BLOB";
+ break;
+
+ case DisplayType.Button:
+ retValue = "CHAR(1)";
+ break;
+
+ // Number Dynamic Precision
+ case DisplayType.CostPrice:
+ retValue = "DECIMAL(22,6)";
+ if (defaultValue)
+ retValue += " DEFAULT 0";
+ break;
+
+ // Date
+ case DisplayType.Date:
+ case DisplayType.DateTime:
+ case DisplayType.Time:
+ retValue = "Timestamp";
+ if (defaultValue)
+ retValue += " DEFAULT 0";
+ break;
+
+ // Number(10)
+ case DisplayType.Integer:
+ retValue = "NUMBER(10)";
+ break;
+
+ case DisplayType.List:
+ retValue = "CHAR(" + precision + ")";
+ break;
+
+ // NVARCHAR
+ case DisplayType.Memo:
+ case DisplayType.String:
+ case DisplayType.Text:
+ retValue = "NVARCHAR(" + precision + ")";
+ break;
+
+ case DisplayType.TextLong:
+ retValue = "CLOB";
+ break;
+
+ // Dyn Prec
+ case DisplayType.Quantity:
+ retValue = "NUMBER";
+ break;
+
+ case DisplayType.YesNo:
+ retValue = "CHAR(1)";
+ break;
+
+ default:
+ log.severe("Unknown: " + displayType);
+ break;
+ }
+ return retValue;
+ } // getDataType
+
+
+ /**
+ * Check and generate an alternative SQL
+ * @reExNo number of re-execution
+ * @msg previous execution error message
+ * @sql previous executed SQL
+ * @return String, the alternative SQL, null if no alternative
+ */
+ public String getAlternativeSQL(int reExNo, String msg, String sql)
+ {
+ return null; //do not do re-execution of alternative SQL
+ }
+
+
+ /**************************************************************************
+ * Testing
+ * @param args ignored
+ */
+ public static void main (String[] args)
+ {
+ /**
+ Adempiere.startupEnvironment(true);
+ CConnection cc = CConnection.get();
+ DB_Oracle db = (DB_Oracle)cc.getDatabase();
+ db.cleanup();
+
+ try
+ {
+ Connection conn = ;
+ // System.out.println("Driver=" + db.getDriverConnection(cc));
+ DataSource ds = db.getDataSource(cc);
+ System.out.println("DS=" + ds.getConnection());
+ conn = db.getCachedConnection(cc, true, Connection.TRANSACTION_READ_COMMITTED);
+ System.out.println("Cached=" + conn);
+ System.out.println(db);
+ //////////////////////////
+ System.out.println("JAVA classpath: [\n" +
+ System.getProperty("java.class.path") + "\n]");
+ DatabaseMetaData dmd = conn.getMetaData();
+ System.out.println("DriverVersion: ["+
+ dmd.getDriverVersion()+"]");
+ System.out.println("DriverMajorVersion: ["+
+ dmd.getDriverMajorVersion()+"]");
+ System.out.println("DriverMinorVersion: ["+
+ dmd.getDriverMinorVersion()+"]");
+ System.out.println("DriverName: ["+
+ dmd.getDriverName()+"]");
+ System.out.println("ProductName: ["+
+ dmd.getDatabaseProductName() +"]");
+ System.out.println("ProductVersion: [\n"+
+ dmd.getDatabaseProductVersion()+"\n]");
+ //////////////////////////
+ }
+ catch (Exception e1)
+ {
+ e1.printStackTrace();
+ }
+ db.cleanup();
+
+ System.out.println("--------------------------------------------------");
+ try
+ {
+ Connection conn1 = db.getCachedConnection(cc, false, Connection.TRANSACTION_READ_COMMITTED);
+ Connection conn2 = db.getCachedConnection(cc, true, Connection.TRANSACTION_READ_COMMITTED);
+ Connection conn3 = db.getCachedConnection(cc, false, Connection.TRANSACTION_READ_COMMITTED);
+ System.out.println("3 -> " + db);
+ conn1.close();
+ conn2.close();
+ conn1 = db.getCachedConnection(cc, true, Connection.TRANSACTION_READ_COMMITTED);
+ conn2 = db.getCachedConnection(cc, true, Connection.TRANSACTION_READ_COMMITTED);
+ System.out.println("3 -> " + db);
+ conn1.close();
+ conn2.close();
+ conn3.close();
+ System.out.println("0 -> " + db);
+ }
+ catch (Exception e1)
+ {
+ e1.printStackTrace();
+ }
+
+ db.cleanup();
+
+ // System.exit(0);
+ System.out.println("--------------------------------------------------");
+
+ System.out.println(DB.getConnectionRO());
+ System.out.println(DB.getConnectionRW());
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+
+ System.out.println(DB.getConnectionRO());
+ System.out.println(DB.getConnectionRW());
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+
+ System.out.println(DB.getConnectionRO());
+ System.out.println(DB.getConnectionRW());
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+
+ System.out.println(DB.getConnectionRO());
+ System.out.println(DB.getConnectionRW());
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+
+ System.out.println(DB.getConnectionRO());
+ System.out.println(DB.getConnectionRW());
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+
+ System.out.println(DB.getConnectionRO());
+ System.out.println(DB.getConnectionRW());
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+
+ System.out.println(DB.getConnectionRO());
+ System.out.println(DB.getConnectionRW());
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+
+ System.out.println(DB.getConnectionRO());
+ System.out.println(DB.getConnectionRW());
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+
+ System.out.println(db);
+
+
+ try
+ {
+ System.out.println("-- Sleeping --");
+ Thread.sleep(60000);
+ System.out.println(db);
+ db.close();
+ db.cleanup();
+ System.out.println(db);
+ }
+ catch (InterruptedException e)
+ {
+ }
+ /** **/
+
+
+ /** **/
+ // Connection option 1
+ try
+ {
+ DB2Driver driver = new DB2Driver();
+ DriverManager.registerDriver(driver);
+
+ Connection con = DriverManager.getConnection("jdbc:db2://dev1:50000/sample",
+ "db2admin", "db2admin");
+// "adempiere", "adempiere");
+// "db2inst1", "daDm7rfr");
+ System.out.println("Connection Catalog = " + con.getCatalog());
+ //
+ DatabaseMetaData md = con.getMetaData();
+ System.out.println(md.getDatabaseProductName() + " - " + md.getDatabaseProductVersion());
+ // System.out.println(md.getDatabaseMajorVersion() + " - " + md.getDatabaseMinorVersion());
+ System.out.println(md.getDriverName() + " - " + md.getDriverVersion());
+ // System.out.println(md.getDriverMajorVersion() + " - " + md.getDriverMinorVersion());
+ System.out.println("URL=" + md.getURL());
+ System.out.println("User=" + md.getUserName());
+ //
+ System.out.println(md.getNumericFunctions());
+ System.out.println(md.getStringFunctions());
+ System.out.println(md.getTimeDateFunctions());
+ System.out.println(md.getSystemFunctions());
+ //
+ System.out.println("Catalogs - " + md.getCatalogTerm());
+ ResultSet rs = md.getCatalogs();
+ while (rs.next())
+ System.out.println("- " + rs.getString(1));
+ //
+ System.out.println("Schemas - " + md.getSchemaTerm());
+ rs = md.getSchemas();
+ while (rs.next())
+ System.out.println("- " + rs.getString(1));
+
+
+ String sql = "SELECT GRANTOR,GRANTEE,DBADMAUTH FROM SYSCAT.DBAUTH";
+ PreparedStatement pstmt = null;
+ try
+ {
+ pstmt = con.prepareStatement (sql);
+ rs = pstmt.executeQuery ();
+ while (rs.next ())
+ {
+ String GRANTOR = rs.getString(1);
+ String GRANTEE = rs.getString(2);
+ String DBADMAUTH = rs.getString(3);
+ System.out.println(GRANTOR + " -> " + GRANTEE + " = " + DBADMAUTH);
+ }
+ rs.close ();
+ pstmt.close ();
+ pstmt = null;
+ }
+ catch (Exception e)
+ {
+ log.log (Level.SEVERE, sql, e);
+ }
+ try
+ {
+ if (pstmt != null)
+ pstmt.close ();
+ pstmt = null;
+ }
+ catch (Exception e)
+ {
+ pstmt = null;
+ }
+
+
+ System.out.println("SysCat Table");
+ rs = md.getTables(null, "SYSCAT", null, new String[] {"TABLE", "VIEW"});
+ while (rs.next())
+ System.out.println("- User=" + rs.getString(2) + " | Table=" + rs.getString(3)
+ + " | Type=" + rs.getString(4) + " | " + rs.getString(5));
+ //
+ System.out.println("Column");
+ rs = md.getColumns(null, "SYSCAT", "DBAUTH", null);
+ while (rs.next())
+ System.out.println("- Tab=" + rs.getString(3) + " | Col=" + rs.getString(4)
+ + " | Type=" + rs.getString(5) + ", " + rs.getString(6)
+ + " | Size=" + rs.getString(7) + " | " + rs.getString(8)
+ + " | Digits=" + rs.getString(9) + " | Radix=" + rs.getString(10)
+ + " | Null=" + rs.getString(11) + " | Rem=" + rs.getString(12)
+ + " | Def=" + rs.getString(13) + " | " + rs.getString(14)
+ + " | " + rs.getString(15) + " | " + rs.getString(16)
+ + " | Ord=" + rs.getString(17) + " | Null=" + rs.getString(18)
+ );
+
+ con.close();
+ }
+ catch (SQLException ex)
+ {
+ ex.printStackTrace();
+ }
+ /** **/
+ } // main
+
+} // DB_DB2
diff --git a/dbPort/src/org/compiere/db/DB_Oracle.java b/dbPort/src/org/compiere/db/DB_Oracle.java
new file mode 100644
index 0000000000..9f46fad846
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DB_Oracle.java
@@ -0,0 +1,1112 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.math.*;
+import java.sql.*;
+import java.util.*;
+import java.util.logging.*;
+import javax.sql.*;
+import oracle.jdbc.*;
+import oracle.jdbc.pool.*;
+import org.compiere.*;
+import org.compiere.util.*;
+
+/**
+ * Oracle Database Port
+ *
+ * @author Jorg Janke
+ * @version $Id: DB_Oracle.java,v 1.7 2006/09/22 23:35:19 jjanke Exp $
+ */
+public class DB_Oracle implements AdempiereDatabase, OracleConnectionCacheCallback
+{
+ /**
+ * Oracle Database
+ */
+ public DB_Oracle()
+ {
+ /** Causes VPN problems ???
+ try
+ {
+ getDriver();
+ }
+ catch (Exception e)
+ {
+ log.log(Level.SEVERE, e.getMessage());
+ }
+ **/
+ } // DB_Oracle
+
+ /** Static Driver */
+ private static OracleDriver s_driver = null;
+ /** Driver Class Name */
+ public static final String DRIVER = "oracle.jdbc.OracleDriver";
+
+ /** Default Port */
+ public static final int DEFAULT_PORT = 1521;
+ /** Default Connection Manager Port */
+ public static final int DEFAULT_CM_PORT = 1630;
+
+ /** Connection String */
+ private String m_connectionURL;
+
+ /** Statement Cache (50) */
+ private static final int MAX_STATEMENTS = 50;
+ /** Data Source */
+ private OracleDataSource m_ds = null;
+
+ /** Use Connection Cache (false)*/
+ private static final boolean USE_CACHE = false;
+ /** Connection Cache */
+ private OracleConnectionCacheManager m_cacheMgr = null;
+ /** Connection Cache Name */
+ private static final String CACHE_NAME = "AdempiereCCache";
+ /** Cached User Name */
+ private String m_userName = null;
+
+ /** Logger */
+ private static CLogger log = CLogger.getCLogger (DB_Oracle.class);
+
+ /**
+ * Get Database Name
+ * @return database short name
+ */
+ public String getName()
+ {
+ return Database.DB_ORACLE;
+ } // getName
+
+ /**
+ * Get Database Description
+ * @return database long name and version
+ */
+ public String getDescription()
+ {
+ try
+ {
+ if (s_driver == null)
+ getDriver();
+ }
+ catch (Exception e)
+ {
+ }
+ if (s_driver != null)
+ return s_driver.toString();
+ return "No Driver";
+ } // getDescription
+
+ /**
+ * Get Standard JDBC Port
+ * @return standard port
+ */
+ public int getStandardPort()
+ {
+ return DEFAULT_PORT;
+ } // getStandardPort
+
+ /**
+ * Get and register Database Driver
+ * @return Driver
+ * @throws SQLException
+ */
+ public Driver getDriver() throws SQLException
+ {
+ if (s_driver == null)
+ {
+ // Speed up transfer rate
+ System.setProperty("oracle.jdbc.TcpNoDelay", "true");
+ // Oracle Multi - Language
+ System.setProperty("oracle.jdbc.defaultNChar", "true");
+ //
+ s_driver = new OracleDriver();
+ DriverManager.registerDriver (s_driver);
+ DriverManager.setLoginTimeout (Database.CONNECTION_TIMEOUT);
+ }
+ return s_driver;
+ } // getDriver
+
+ /**
+ * Get Database Connection String.
+ *
+ * Timing:
+ * - CM with source_route not in address_list = 28.5 sec
+ * - CM with source_route in address_list = 58.0 sec
+ * - direct = 4.3-8 sec (no real difference if on other box)
+ * - bequeath = 3.4-8 sec
+ *
+ * @param connection Connection Descriptor
+ * @return connection String
+ */
+ public String getConnectionURL (CConnection connection)
+ {
+ StringBuffer sb = null;
+ // Server Connections (bequeath)
+ if (connection.isBequeath())
+ {
+ sb = new StringBuffer ("jdbc:oracle:oci8:@");
+ // bug: does not work if there is more than one db instance - use Net8
+ // sb.append(connection.getDbName());
+ }
+ else // thin driver
+ {
+ sb = new StringBuffer ("jdbc:oracle:thin:@");
+ // direct connection
+ if (connection.isViaFirewall())
+ {
+ // (description=(address_list=
+ // ( (source_route=yes)
+ // (address=(protocol=TCP)(host=cmhost)(port=1630))
+ // (address=(protocol=TCP)(host=dev)(port=1521))
+ // (connect_data=(service_name=dev1.adempiere.org)))
+ sb.append("(DESCRIPTION=(ADDRESS_LIST=")
+ .append("(SOURCE_ROUTE=YES)")
+ .append("(ADDRESS=(PROTOCOL=TCP)(HOST=").append(connection.getFwHost())
+ .append(")(PORT=").append(connection.getFwPort()).append("))")
+ .append("(ADDRESS=(PROTOCOL=TCP)(HOST=").append(connection.getDbHost())
+ .append(")(PORT=").append(connection.getDbPort()).append(")))")
+ .append("(CONNECT_DATA=(SERVICE_NAME=").append(connection.getDbName()).append(")))");
+ }
+ else
+ {
+ // old: jdbc:oracle:thin:@dev2:1521:sid
+ // new: jdbc:oracle:thin:@//dev2:1521/serviceName
+ sb.append("//")
+ .append(connection.getDbHost())
+ .append(":").append(connection.getDbPort())
+ .append("/").append(connection.getDbName());
+ }
+ }
+ m_connectionURL = sb.toString();
+ // log.config(m_connectionURL);
+ //
+ m_userName = connection.getDbUid();
+ return m_connectionURL;
+ } // getConnectionURL
+
+ /**
+ * Get Connection URL.
+ * http://download-east.oracle.com/docs/cd/B14117_01/java.101/b10979/urls.htm#BEIDBFDF
+ * @param dbHost db Host
+ * @param dbPort db Port
+ * @param dbName db Name
+ * @param userName user name
+ * @return connection
+ */
+ public String getConnectionURL (String dbHost, int dbPort, String dbName,
+ String userName)
+ {
+ m_userName = userName;
+ m_connectionURL = "jdbc:oracle:thin:@//"
+ + dbHost + ":" + dbPort + "/" + dbName;
+ return m_connectionURL;
+ } // getConnectionURL
+
+ /**
+ * Get Database Connection String
+ * @param connectionURL Connection URL
+ * @param userName user name
+ * @return connection String
+ */
+ public String getConnectionURL (String connectionURL, String userName)
+ {
+ m_userName = userName;
+ m_connectionURL = connectionURL;
+ return m_connectionURL;
+ } // getConnectionURL
+
+ /**
+ * Get JDBC Catalog
+ * @return null - not used
+ */
+ public String getCatalog()
+ {
+ return null;
+ } // getCatalog
+
+ /**
+ * Get JDBC Schema
+ * @return user name
+ */
+ public String getSchema()
+ {
+ if (m_userName != null)
+ return m_userName.toUpperCase();
+ log.severe("User Name not set (yet) - call getConnectionURL first");
+ return null;
+ } // getSchema
+
+ /**
+ * Supports BLOB
+ * @return true if BLOB is supported
+ */
+ public boolean supportsBLOB()
+ {
+ return true;
+ } // supportsBLOB
+
+ /**
+ * String Representation
+ * @return info
+ */
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer("DB_Oracle[");
+ sb.append(m_connectionURL);
+ try
+ {
+ if (m_ds != null)
+ sb.append("-").append(m_ds.getDataSourceName())
+ // .append(",ExplCache=").append(m_ds.getExplicitCachingEnabled())
+ .append(",ImplCache=").append(m_ds.getImplicitCachingEnabled())
+ .append(",MaxStmts=").append(m_ds.getMaxStatements());
+ // .append(",Ref=").append(m_ds.getReference());
+ if (m_cacheMgr != null && m_cacheMgr.existsCache(CACHE_NAME))
+ sb.append(";ConnectionActive=").append(m_cacheMgr.getNumberOfActiveConnections(CACHE_NAME))
+ .append(",CacheAvailable=").append(m_cacheMgr.getNumberOfAvailableConnections(CACHE_NAME));
+ }
+ catch (Exception e)
+ {
+ sb.append("=").append(e.getLocalizedMessage());
+ }
+ sb.append("]");
+ return sb.toString();
+ } // toString
+
+ /**
+ * Get Status
+ * @return status info
+ */
+ public String getStatus()
+ {
+ StringBuffer sb = new StringBuffer();
+ try
+ {
+ if (m_cacheMgr != null && m_cacheMgr.existsCache(CACHE_NAME))
+ sb.append("-Connections=").append(m_cacheMgr.getNumberOfActiveConnections(CACHE_NAME))
+ .append(",Cache=").append(m_cacheMgr.getNumberOfAvailableConnections(CACHE_NAME));
+ }
+ catch (Exception e)
+ {}
+ return sb.toString();
+ } // getStatus
+
+
+ /**************************************************************************
+ * Convert an individual Oracle Style statements to target database statement syntax.
+ * @param oraStatement oracle statement
+ * @return converted Statement oracle statement
+ */
+ public String convertStatement (String oraStatement)
+ {
+ return oraStatement;
+ } // convertStatement
+
+
+
+ /**
+ * Check if DBMS support the sql statement
+ * @sql SQL statement
+ * @return true: yes
+ */
+ public boolean isSupported(String sql)
+ {
+ return true;
+ //jz temp, modify later
+ }
+
+
+
+ /**
+ * Get constraint type associated with the index
+ * @tableName table name
+ * @IXName Index name
+ * @return String[0] = 0: do not know, 1: Primary Key 2: Foreign Key
+ * String[1] - String[n] = Constraint Name
+ */
+ public String getConstraintType(Connection conn, String tableName, String IXName)
+ {
+ if (IXName == null || IXName.length()==0)
+ return "0";
+ if (IXName.endsWith("_KEY"))
+ return "1"+IXName;
+ else
+ return "0";
+ //jz temp, modify later from user.constraints
+ }
+
+ /**
+ * Get Name of System User
+ * @return system
+ */
+ public String getSystemUser()
+ {
+ return "system";
+ } // getSystemUser
+
+ /**
+ * Get Name of System Database
+ * @param databaseName database Name
+ * @return e.g. master or database Name
+ */
+ public String getSystemDatabase(String databaseName)
+ {
+ return databaseName;
+ } // getSystemDatabase
+
+
+ /**
+ * Create SQL TO Date String from Timestamp
+ *
+ * @param time Date to be converted
+ * @param dayOnly true if time set to 00:00:00
+ *
+ * @return TO_DATE('2001-01-30 18:10:20',''YYYY-MM-DD HH24:MI:SS')
+ * or TO_DATE('2001-01-30',''YYYY-MM-DD')
+ */
+ public String TO_DATE (Timestamp time, boolean dayOnly)
+ {
+ if (time == null)
+ {
+ if (dayOnly)
+ return "TRUNC(SysDate)";
+ return "SysDate";
+ }
+
+ StringBuffer dateString = new StringBuffer("TO_DATE('");
+ // YYYY-MM-DD HH24:MI:SS.mmmm JDBC Timestamp format
+ String myDate = time.toString();
+ if (dayOnly)
+ {
+ dateString.append(myDate.substring(0,10));
+ dateString.append("','YYYY-MM-DD')");
+ }
+ else
+ {
+ dateString.append(myDate.substring(0, myDate.indexOf("."))); // cut off miliseconds
+ dateString.append("','YYYY-MM-DD HH24:MI:SS')");
+ }
+ return dateString.toString();
+ } // TO_DATE
+
+ /**
+ * Create SQL for formatted Date, Number
+ *
+ * @param columnName the column name in the SQL
+ * @param displayType Display Type
+ * @param AD_Language 6 character language setting (from Env.LANG_*)
+ *
+ * @return TRIM(TO_CHAR(columnName,'9G999G990D00','NLS_NUMERIC_CHARACTERS='',.'''))
+ * or TRIM(TO_CHAR(columnName,'TM9')) depending on DisplayType and Language
+ * @see org.compiere.util.DisplayType
+ * @see org.compiere.util.Env
+ *
+ * */
+ public String TO_CHAR (String columnName, int displayType, String AD_Language)
+ {
+ StringBuffer retValue = new StringBuffer("TRIM(TO_CHAR(");
+ retValue.append(columnName);
+
+ // Numbers
+ if (DisplayType.isNumeric(displayType))
+ {
+ if (displayType == DisplayType.Amount)
+ retValue.append(",'9G999G990D00'");
+ else
+ retValue.append(",'TM9'");
+ // TO_CHAR(GrandTotal,'9G999G990D00','NLS_NUMERIC_CHARACTERS='',.''')
+ if (!Language.isDecimalPoint(AD_Language)) // reversed
+ retValue.append(",'NLS_NUMERIC_CHARACTERS='',.'''");
+ }
+ else if (DisplayType.isDate(displayType))
+ {
+ retValue.append(",'")
+ .append(Language.getLanguage(AD_Language).getDBdatePattern())
+ .append("'");
+ }
+ retValue.append("))");
+ //
+ return retValue.toString();
+ } // TO_CHAR
+
+ /**
+ * Return number as string for INSERT statements with correct precision
+ * @param number number
+ * @param displayType display Type
+ * @return number as string
+ */
+ public String TO_NUMBER (BigDecimal number, int displayType)
+ {
+ if (number == null)
+ return "NULL";
+ return number.toString();
+ } // TO_NUMBER
+
+
+ /**
+ * Get SQL Commands.
+ * The following variables are resolved:
+ * @SystemPassword@, @AdempiereUser@, @AdempierePassword@
+ * @SystemPassword@, @DatabaseName@, @DatabaseDevice@
+ * @param cmdType CMD_*
+ * @return array of commands to be executed
+ */
+ public String[] getCommands (int cmdType)
+ {
+ if (CMD_CREATE_USER == cmdType)
+ return new String[]
+ {
+
+ };
+ //
+ if (CMD_CREATE_DATABASE == cmdType)
+ return new String[]
+ {
+
+ };
+ //
+ if (CMD_DROP_DATABASE == cmdType)
+ return new String[]
+ {
+
+ };
+ //
+ return null;
+ } // getCommands
+
+ /**
+ * Create DataSource
+ * @param connection connection
+ * @return data dource
+ */
+ public DataSource getDataSource(CConnection connection)
+ {
+ if (m_ds != null)
+ return m_ds;
+ try
+ {
+ m_ds = new OracleDataSource();
+ m_ds.setDriverType("thin");
+ m_ds.setNetworkProtocol("tcp");
+ m_ds.setServerName(connection.getDbHost());
+ m_ds.setServiceName(connection.getDbName());
+ m_ds.setPortNumber(connection.getDbPort());
+ m_ds.setUser(connection.getDbUid());
+ m_ds.setPassword(connection.getDbPwd());
+ //
+ m_ds.setDataSourceName("AdempiereDS");
+ m_ds.setDescription("Adempiere Oracle Data Source");
+ m_ds.setImplicitCachingEnabled(true);
+ m_ds.setExplicitCachingEnabled(true);
+ m_ds.setMaxStatements(MAX_STATEMENTS);
+ // http://download-east.oracle.com/docs/cd/B14117_01/java.101/b10979/oralob.htm#sthref1258
+ Properties connProperties = new Properties();
+ connProperties.setProperty("SetBigStringUseClob", "true");
+ m_ds.setConnectionProperties(connProperties);
+ //
+ Properties cacheProperties = new Properties();
+ // cacheProperties.setProperty("InitialLimit", "3"); // at startup
+ // cacheProperties.setProperty("MaxStatementsLimit", "10");
+ cacheProperties.setProperty("ClosestConnectionMatch", "true");
+ cacheProperties.setProperty("ValidateConnection", "true");
+ if (Ini.isClient())
+ {
+ cacheProperties.setProperty("MinLimit", "0");
+ // cacheProperties.setProperty("MaxLimit", "5");
+ cacheProperties.setProperty("InactivityTimeout", "300"); // 5 Min
+ cacheProperties.setProperty("AbandonedConnectionTimeout", "300"); // 5 Min
+ }
+ else // Server Settings
+ {
+ cacheProperties.setProperty("MinLimit", "3");
+ // cacheProperties.setProperty("MaxLimit", "5");
+ cacheProperties.setProperty("InactivityTimeout", "600"); // 10 Min
+ cacheProperties.setProperty("AbandonedConnectionTimeout", "600"); // 10 Min
+ }
+ cacheProperties.setProperty("PropertyCheckInterval", "120"); // 2 Min
+ //
+ if (USE_CACHE)
+ {
+ m_ds.setConnectionCachingEnabled(true);
+ m_ds.setConnectionCacheName(CACHE_NAME);
+ m_ds.setFastConnectionFailoverEnabled(true);
+ }
+ //
+ if (m_cacheMgr == null && USE_CACHE)
+ {
+ m_cacheMgr = OracleConnectionCacheManager.getConnectionCacheManagerInstance();
+ if (!m_cacheMgr.existsCache(CACHE_NAME))
+ m_cacheMgr.createCache(CACHE_NAME, m_ds, cacheProperties);
+ }
+ // test
+// OracleConnection con = m_ds.getConnection();
+// con.close();
+ //
+ log.config(toString());
+ //
+ return m_ds;
+ }
+ catch (Exception e)
+ {
+ log.log(Level.SEVERE, toString(), e);
+ }
+ return null;
+ } // getDataSource
+
+
+ /**
+ * Get Cached Connection
+ * @param connection info
+ * @param autoCommit true if autocommit connection
+ * @param transactionIsolation Connection transaction level
+ * @return connection or null
+ * @throws Exception
+ */
+ public Connection getCachedConnection (CConnection connection,
+ boolean autoCommit, int transactionIsolation)
+ throws Exception
+ {
+ OracleConnection conn = null;
+ Exception exception = null;
+ try
+ {
+ if (USE_CACHE && m_cacheMgr == null)
+ getDataSource(connection);
+ if (m_ds == null)
+ getDataSource(connection);
+
+ // Properties connAttr = new Properties();
+ // connAttr.setProperty("TRANSACTION_ISOLATION", CConnection.getTransactionIsolationInfo(transactionIsolation));
+ // OracleConnection conn = (OracleConnection)m_ds.getConnection(connAttr);
+ //
+ // Try 5 times max
+ for (int i = 0; i < 5; i++)
+ {
+ try
+ {
+ conn = (OracleConnection)m_ds.getConnection();
+ if (conn != null)
+ {
+ if (conn.getTransactionIsolation() != transactionIsolation)
+ conn.setTransactionIsolation(transactionIsolation);
+ if (conn.getAutoCommit() != autoCommit)
+ conn.setAutoCommit(autoCommit);
+ conn.setDefaultRowPrefetch(20); // 10 default - reduces round trips
+ }
+ }
+ catch (Exception e)
+ {
+ exception = e;
+ conn = null;
+ if (e instanceof SQLException
+ && ((SQLException)e).getErrorCode() == 1017) // invalid username/password
+ {
+ log.severe("Cannot connect to database: "
+ + getConnectionURL(connection)
+ + " - UserID=" + connection.getDbUid());
+ break;
+ }
+ }
+ try
+ {
+ if (conn != null && conn.isClosed())
+ conn = null;
+ // OK
+ if (conn != null && !conn.isClosed())
+ break;
+ if (i == 0)
+ Thread.yield(); // give some time
+ else
+ Thread.sleep(100);
+ }
+ catch (Exception e)
+ {
+ exception = e;
+ conn = null;
+ }
+ } // 5 tries
+
+ if (conn == null && exception != null)
+ {
+ log.log(Level.SEVERE, exception.toString());
+ log.fine(toString());
+ log.finest("Reference=" + m_ds.getReference());
+ }
+ // else
+ // {
+ // System.out.println(conn + " " + getStatus());
+ // conn.registerConnectionCacheCallback(this, "test", OracleConnection.ALL_CONNECTION_CALLBACKS);
+ // }
+ }
+ catch (Exception e)
+ {
+ // System.err.println ("DB_Oracle.getCachedConnection");
+ // if (!(e instanceof SQLException))
+ // e.printStackTrace();
+ exception = e;
+ }
+ if (exception != null)
+ throw exception;
+ return conn;
+ } // getCachedConnection
+
+ /**
+ * Get Connection from Driver
+ * @param connection info
+ * @return connection or null
+ * @throws SQLException
+ */
+ public Connection getDriverConnection (CConnection connection) throws SQLException
+ {
+ getDriver();
+ return DriverManager.getConnection (getConnectionURL (connection),
+ connection.getDbUid(), connection.getDbPwd());
+ } // getDriverConnection
+
+ /**
+ * Get Driver Connection
+ * @param dbUrl URL
+ * @param dbUid user
+ * @param dbPwd password
+ * @return connection
+ * @throws SQLException
+ */
+ public Connection getDriverConnection (String dbUrl, String dbUid, String dbPwd)
+ throws SQLException
+ {
+ getDriver();
+ return DriverManager.getConnection (dbUrl, dbUid, dbPwd);
+ } // getDriverConnection
+
+ /**
+ * Close
+ */
+ public void close()
+ {
+ log.config(toString());
+ if (m_ds != null)
+ {
+ try
+ {
+ m_ds.close();
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ if (m_cacheMgr != null)
+ {
+ try
+ {
+ if (m_cacheMgr.existsCache(CACHE_NAME))
+ m_cacheMgr.purgeCache(CACHE_NAME, false); // not active
+ // m_cache.disableCache(CACHE_NAME);
+ // m_cache.removeCache(CACHE_NAME, 0);
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ m_cacheMgr = null;
+ m_ds = null;
+ } // close
+
+ /**
+ * Clean up
+ */
+ public void cleanup()
+ {
+ if (!USE_CACHE)
+ return;
+
+ log.config("");
+ try
+ {
+ if (m_cacheMgr == null)
+ m_cacheMgr = OracleConnectionCacheManager.getConnectionCacheManagerInstance();
+ String[] cacheNames = m_cacheMgr.getCacheNameList();
+ for (int i = 0; i < cacheNames.length; i++)
+ {
+ String name = cacheNames[i];
+ System.out.println(" cleanup: " + name);
+ System.out.println(" Before = Active=" + m_cacheMgr.getNumberOfActiveConnections(name)
+ + ", Available=" + m_cacheMgr.getNumberOfAvailableConnections(name));
+ m_cacheMgr.purgeCache(name, false);
+ System.out.println(" Cached = Active=" + m_cacheMgr.getNumberOfActiveConnections(name)
+ + ", Available=" + m_cacheMgr.getNumberOfAvailableConnections(name));
+ m_cacheMgr.purgeCache(name, true);
+ System.out.println(" All = Active=" + m_cacheMgr.getNumberOfActiveConnections(name)
+ + ", Available=" + m_cacheMgr.getNumberOfAvailableConnections(name));
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ } // cleanup
+
+ /**************************************************************************
+ * Handle Abandoned Connection
+ * @param conn connection
+ * @param userObject
+ * @return true if close - false for keeping it
+ */
+ public boolean handleAbandonedConnection (OracleConnection conn, Object userObject)
+ {
+ System.out.println("--------------------handleAbandonedConnection " + conn + " - " + userObject);
+ return true; // reclaim it
+ } // handleAbandonedConnection
+
+ /**
+ * Release Connection
+ * @param conn connection
+ * @param userObject
+ */
+ public void releaseConnection (OracleConnection conn, Object userObject)
+ {
+ System.out.println("----------------------releaseConnection " + conn + " - " + userObject);
+ } // releaseConnection
+
+
+ /**
+ * Get Data Type
+ * @param displayType display type
+ * @param precision precision
+ * @param defaultValue if true adds default value
+ * @return data type
+ */
+ public String getDataType (int displayType, int precision,
+ boolean defaultValue)
+ {
+ String retValue = null;
+ switch (displayType)
+ {
+ // IDs
+ case DisplayType.Account:
+ case DisplayType.Assignment:
+ case DisplayType.Color:
+ case DisplayType.ID:
+ case DisplayType.Location:
+ case DisplayType.Locator:
+ case DisplayType.PAttribute:
+ case DisplayType.Search:
+ case DisplayType.Table:
+ case DisplayType.TableDir:
+ case DisplayType.Image:
+ retValue = "NUMBER(10)";
+ break;
+
+ // Dynamic Precision
+ case DisplayType.Amount:
+ retValue = "NUMBER";
+ if (defaultValue)
+ retValue += " DEFAULT 0";
+ break;
+
+ case DisplayType.Binary:
+ retValue = "BLOB";
+ break;
+
+ case DisplayType.Button:
+ retValue = "CHAR(1)";
+ break;
+
+ // Number Dynamic Precision
+ case DisplayType.CostPrice:
+ retValue = "NUMBER";
+ if (defaultValue)
+ retValue += " DEFAULT 0";
+ break;
+
+ // Date
+ case DisplayType.Date:
+ case DisplayType.DateTime:
+ case DisplayType.Time:
+ retValue = "DATE";
+ if (defaultValue)
+ retValue += " DEFAULT SYSDATE";
+ break;
+
+ // Number(10)
+ case DisplayType.Integer:
+ retValue = "NUMBER(10)";
+ break;
+
+ case DisplayType.List:
+ retValue = "CHAR(" + precision + ")";
+ break;
+
+ // NVARCHAR
+ case DisplayType.Memo:
+ case DisplayType.String:
+ case DisplayType.Text:
+ retValue = "NVARCHAR(" + precision + ")";
+ break;
+
+ case DisplayType.TextLong:
+ retValue = "CLOB";
+ break;
+
+ // Dyn Prec
+ case DisplayType.Quantity:
+ retValue = "NUMBER";
+ break;
+
+ case DisplayType.YesNo:
+ retValue = "CHAR(1)";
+ break;
+
+ default:
+ log.severe("Unknown: " + displayType);
+ break;
+ }
+ return retValue;
+ } // getDataType
+
+
+ /**
+ * Check and generate an alternative SQL
+ * @reExNo number of re-execution
+ * @msg previous execution error message
+ * @sql previous executed SQL
+ * @return String, the alternative SQL, null if no alternative
+ */
+ public String getAlternativeSQL(int reExNo, String msg, String sql)
+ {
+ //check reExNo or based on reExNo to do a decision. Currently none
+
+ return null; //do not do re-execution of alternative SQL
+ }
+
+
+ /**************************************************************************
+ * Testing
+ * @param args ignored
+ */
+ public static void main (String[] args)
+ {
+ Adempiere.startupEnvironment(true);
+ CConnection cc = CConnection.get();
+ DB_Oracle db = (DB_Oracle)cc.getDatabase();
+ db.cleanup();
+
+ try
+ {
+ Connection conn = null;
+ // System.out.println("Driver=" + db.getDriverConnection(cc));
+ DataSource ds = db.getDataSource(cc);
+ System.out.println("DS=" + ds.getConnection());
+ conn = db.getCachedConnection(cc, true, Connection.TRANSACTION_READ_COMMITTED);
+ System.out.println("Cached=" + conn);
+ System.out.println(db);
+ //////////////////////////
+ System.out.println("JAVA classpath: [\n" +
+ System.getProperty("java.class.path") + "\n]");
+ DatabaseMetaData dmd = conn.getMetaData();
+ System.out.println("DriverVersion: ["+
+ dmd.getDriverVersion()+"]");
+ System.out.println("DriverMajorVersion: ["+
+ dmd.getDriverMajorVersion()+"]");
+ System.out.println("DriverMinorVersion: ["+
+ dmd.getDriverMinorVersion()+"]");
+ System.out.println("DriverName: ["+
+ dmd.getDriverName()+"]");
+ System.out.println("ProductName: ["+
+ dmd.getDatabaseProductName() +"]");
+ System.out.println("ProductVersion: [\n"+
+ dmd.getDatabaseProductVersion()+"\n]");
+ //////////////////////////
+ }
+ catch (Exception e1)
+ {
+ e1.printStackTrace();
+ }
+ db.cleanup();
+
+ System.out.println("--------------------------------------------------");
+ /**
+ DROP TABLE X_Test;
+ CREATE TABLE X_Test
+ (
+ Text1 NVARCHAR2(2000) NULL,
+ Text2 VARCHAR2(2000) NULL
+ );
+ **/
+ try
+ {
+ String myString1 = "123456789 12345678";
+ String myString = "";
+ for (int i = 0; i < 99; i++)
+ myString += myString1 + (char)('a'+i) + "\n";
+ System.out.println(myString.length());
+ System.out.println(Util.size(myString));
+ //
+ myString = Util.trimSize(myString, 2000);
+ System.out.println(myString.length());
+ System.out.println(Util.size(myString));
+ //
+ Connection conn2 = db.getCachedConnection(cc, true, Connection.TRANSACTION_READ_COMMITTED);
+ /** **/
+ PreparedStatement pstmt = conn2.prepareStatement
+ ("INSERT INTO X_Test(Text1, Text2) values(?,?)");
+ pstmt.setString(1, myString); // NVARCHAR2 column
+ pstmt.setString(2, myString); // VARCHAR2 column
+ System.out.println(pstmt.executeUpdate());
+ /** **/
+ Statement stmt = conn2.createStatement();
+ System.out.println(stmt.executeUpdate
+ ("INSERT INTO X_Test(Text1, Text2) values('" + myString + "','" + myString + "')"));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ db.cleanup();
+ System.out.println("--------------------------------------------------");
+ System.exit(0);
+
+
+ System.out.println("--------------------------------------------------");
+ try
+ {
+ Connection conn1 = db.getCachedConnection(cc, false, Connection.TRANSACTION_READ_COMMITTED);
+ Connection conn2 = db.getCachedConnection(cc, true, Connection.TRANSACTION_READ_COMMITTED);
+ Connection conn3 = db.getCachedConnection(cc, false, Connection.TRANSACTION_READ_COMMITTED);
+ System.out.println("3 -> " + db);
+ conn1.close();
+ conn2.close();
+ conn1 = db.getCachedConnection(cc, true, Connection.TRANSACTION_READ_COMMITTED);
+ conn2 = db.getCachedConnection(cc, true, Connection.TRANSACTION_READ_COMMITTED);
+ System.out.println("3 -> " + db);
+ conn1.close();
+ conn2.close();
+ conn3.close();
+ System.out.println("0 -> " + db);
+ }
+ catch (Exception e1)
+ {
+ e1.printStackTrace();
+ }
+
+ db.cleanup();
+
+ // System.exit(0);
+ System.out.println("--------------------------------------------------");
+
+ System.out.println(DB.getConnectionRO());
+ System.out.println(DB.getConnectionRW());
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+
+ System.out.println(DB.getConnectionRO());
+ System.out.println(DB.getConnectionRW());
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+
+ System.out.println(DB.getConnectionRO());
+ System.out.println(DB.getConnectionRW());
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+
+ System.out.println(DB.getConnectionRO());
+ System.out.println(DB.getConnectionRW());
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+
+ System.out.println(DB.getConnectionRO());
+ System.out.println(DB.getConnectionRW());
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+
+ System.out.println(DB.getConnectionRO());
+ System.out.println(DB.getConnectionRW());
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+
+ System.out.println(DB.getConnectionRO());
+ System.out.println(DB.getConnectionRW());
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+
+ System.out.println(DB.getConnectionRO());
+ System.out.println(DB.getConnectionRW());
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+ System.out.println(DB.createConnection(false, Connection.TRANSACTION_READ_COMMITTED));
+
+ System.out.println(db);
+
+
+ try
+ {
+ System.out.println("-- Sleeping --");
+ Thread.sleep(60000);
+ System.out.println(db);
+ db.close();
+ db.cleanup();
+ System.out.println(db);
+ }
+ catch (InterruptedException e)
+ {
+ }
+
+
+
+ /**
+ // Connection option 1
+ try
+ {
+ System.setProperty("oracle.jdbc.Trace", "true");
+ DriverManager.registerDriver(new OracleDriver());
+ Connection con = DriverManager.getConnection("jdbc:oracle:thin:@//dev:1521/dev", "adempiere", "adempiere");
+ System.out.println("Catalog=" + con.getCatalog());
+ DatabaseMetaData md = con.getMetaData();
+ System.out.println("URL=" + md.getURL());
+ System.out.println("User=" + md.getUserName());
+ //
+ System.out.println("Catalog");
+ ResultSet rs = md.getCatalogs();
+ while (rs.next())
+ System.out.println("- " + rs.getString(1));
+ //
+ System.out.println("Table");
+ rs = md.getTables(null, "ADEMPIERE", null, new String[] {"TABLE"});
+ while (rs.next())
+ System.out.println("- User=" + rs.getString(2) + " | Table=" + rs.getString(3)
+ + " | Type=" + rs.getString(4) + " | " + rs.getString(5));
+ //
+ System.out.println("Column");
+ rs = md.getColumns(null, "ADEMPIERE", "C_ORDER", null);
+ while (rs.next())
+ System.out.println("- Tab=" + rs.getString(3) + " | Col=" + rs.getString(4)
+ + " | Type=" + rs.getString(5) + ", " + rs.getString(6)
+ + " | Size=" + rs.getString(7) + " | " + rs.getString(8)
+ + " | Digits=" + rs.getString(9) + " | Radix=" + rs.getString(10)
+ + " | Null=" + rs.getString(11) + " | Rem=" + rs.getString(12)
+ + " | Def=" + rs.getString(13) + " | " + rs.getString(14)
+ + " | " + rs.getString(15) + " | " + rs.getString(16)
+ + " | Ord=" + rs.getString(17) + " | Null=" + rs.getString(18)
+ );
+
+ con.close();
+ }
+ catch (SQLException ex)
+ {
+ ex.printStackTrace();
+ }
+ **/
+ } // main
+
+} // DB_Oracle
diff --git a/dbPort/src/org/compiere/db/DB_PostgreSQL.java b/dbPort/src/org/compiere/db/DB_PostgreSQL.java
new file mode 100755
index 0000000000..c4289e3664
--- /dev/null
+++ b/dbPort/src/org/compiere/db/DB_PostgreSQL.java
@@ -0,0 +1,621 @@
+/******************************************************************************
+ * The contents of this file are subject to the Compiere License Version 1.1
+ * ("License"); You may not use this file except in compliance with the License
+ * You may obtain a copy of the License at http://www.compiere.org/license.html
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial
+ * Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
+ * are Copyright (C) 1999-2005 Jorg Janke.
+ * All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved.
+ * Portions created by Victor Perez are Copyright (C) 1999-2005 e-Evolution,S.C
+ * Contributor(s): Victor Perez
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.math.*;
+import java.sql.*;
+import java.util.logging.Level;
+
+import javax.sql.*;
+import org.compiere.dbPort.*;
+import org.compiere.util.*;
+
+/**
+ * PostgreSQL Database Port
+ *
+ * @author @author Jorg Janke, Victor Pïŋ―rez
+ * @version $Id: DB_PostgreSQL.java,v 1.23 2005/03/11 20:29:01 jjanke Exp $
+ */
+public class DB_PostgreSQL implements AdempiereDatabase
+{
+ /**
+ * PostgreSQL Database
+ */
+ public DB_PostgreSQL()
+ {
+ } // DB_PostgreSQL
+
+ /** Driver */
+ private org.postgresql.Driver s_driver = null;
+
+ /** Default Port */
+ public static final int DEFAULT_PORT = 5432;
+
+ /** Data Source */
+ private org.postgresql.ds.PGPoolingDataSource m_ds = null;
+
+ /** Statement Converter */
+ private Convert m_convert = new Convert(Database.DB_POSTGRESQL);
+ /** Connection String */
+ private String m_connection;
+ /** Cached Database Name */
+ private String m_dbName = null;
+
+ private String m_userName = null;
+ /** Connection String */
+ private String m_connectionURL;
+
+ /** Logger */
+ private static CLogger log = CLogger.getCLogger (DB_PostgreSQL.class);
+
+ /**
+ * Get Database Name
+ * @return database short name
+ */
+ public String getName()
+ {
+ return Database.DB_POSTGRESQL;
+ } // getName
+
+ /**
+ * Get Database Description
+ * @return database long name and version
+ */
+ public String getDescription()
+ { //begin vpj-cd e-evolution 30.09.2005
+ //return s_driver.toString();
+ try
+ {
+ if (s_driver == null)
+ getDriver();
+ }
+ catch (Exception e)
+ {
+ }
+ if (s_driver != null)
+ return s_driver.toString();
+ return "No Driver";
+ //end vpj-cd e-evolution 30.09.2005
+ } // getDescription
+
+ /**
+ * Get Standard JDBC Port
+ * @return standard port
+ */
+ public int getStandardPort()
+ {
+ return DEFAULT_PORT;
+ } // getStandardPort
+
+ /**
+ * Get and register Database Driver
+ * @return Driver
+ */
+ public java.sql.Driver getDriver() throws SQLException
+ {
+ if (s_driver == null)
+ {
+ s_driver = new org.postgresql.Driver();
+ DriverManager.registerDriver (s_driver);
+ DriverManager.setLoginTimeout (Database.CONNECTION_TIMEOUT);
+ }
+ return s_driver;
+ } // getDriver
+
+ /**
+ * Get Database Connection String.
+ * Requirements:
+ * - createdb -E UNICODE compiere
+ * @param connection Connection Descriptor
+ * @return connection String
+ */
+ public String getConnectionURL (CConnection connection)
+ {
+ // jdbc:postgresql://hostname:portnumber/databasename?encoding=UNICODE
+ StringBuffer sb = new StringBuffer("jdbc:postgresql:");
+ sb.append("//").append(connection.getDbHost())
+ .append(":").append(connection.getDbPort())
+ .append("/").append(connection.getDbName())
+ .append("?encoding=UNICODE");
+ m_connection = sb.toString();
+ return m_connection;
+ } // getConnectionString
+
+ /**
+ * Get Connection URL
+ * @param dbHost db Host
+ * @param dbPort db Port
+ * @param dbName sb Name
+ * @param userName user name
+ * @return connection url
+ */
+ public String getConnectionURL (String dbHost, int dbPort, String dbName,
+ String userName)
+ {
+ return "jdbc:postgresql://"
+ + dbHost + ":" + dbPort + "/" + dbName;
+ } // getConnectionURL
+
+ /**
+ * Get Database Connection String
+ * @param connectionURL Connection URL
+ * @param userName user name
+ * @return connection String
+ */
+ public String getConnectionURL (String connectionURL, String userName)
+ {
+ m_userName = userName;
+ m_connectionURL = connectionURL;
+ return m_connectionURL;
+ } // getConnectionURL
+
+ /**
+ * Get JDBC Catalog
+ * @return catalog (database name)
+ */
+ public String getCatalog()
+ {
+ if (m_dbName != null)
+ return m_dbName;
+ // log.severe("Database Name not set (yet) - call getConnectionURL first");
+ return null;
+ } // getCatalog
+
+ /**
+ * Get JDBC Schema
+ * @return schema (dbo)
+ */
+ public String getSchema()
+ {
+ //begin vpj-cd e-evolution 03/04/2005
+ return "adempiere";
+ //end vpj-cd e-evolution 03/04/2005
+ } // getSchema
+
+ /**
+ * Supports BLOB
+ * @return true if BLOB is supported
+ */
+ public boolean supportsBLOB()
+ {
+ return true;
+ } // supportsBLOB
+
+ /**
+ * String Representation
+ * @return info
+ */
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer("DB_PostgreSQL[");
+ sb.append(m_connection)
+ .append("]");
+ return sb.toString();
+ } // toString
+
+ /**
+ * Get Status
+ * @return status info
+ */
+ public String getStatus()
+ {
+ return "";
+ } // getStatus
+
+ /*************************************************************************
+ * Convert an individual Oracle Style statements to target database statement syntax
+ *
+ * @param oraStatement
+ * @return converted Statement
+ * @throws Exception
+ */
+ public String convertStatement (String oraStatement)
+ {
+ String retValue[] = m_convert.convert(oraStatement);
+
+ //begin vpj-cd e-evolution 03/14/2005
+ if (retValue.length == 0 )
+ return oraStatement;
+ //end vpj-cd e-evolution 03/14/2005
+
+ if (retValue == null)
+ //begin vpj-cd 24/06/2005 e-evolution
+ {
+ log.log(Level.SEVERE,("DB_PostgreSQL.convertStatement - Not Converted (" + oraStatement + ") - "
+ + m_convert.getConversionError()));
+ throw new IllegalArgumentException
+ ("DB_PostgreSQL.convertStatement - Not Converted (" + oraStatement + ") - "
+ + m_convert.getConversionError());
+ }
+ // end vpj-cd 24/06/2005 e-evolution
+ if (retValue.length != 1)
+ //begin vpj-cd 24/06/2005 e-evolution
+ {
+ log.log(Level.SEVERE, ("DB_PostgreSQL.convertStatement - Convert Command Number=" + retValue.length
+ + " (" + oraStatement + ") - " + m_convert.getConversionError()));
+ throw new IllegalArgumentException
+ ("DB_PostgreSQL.convertStatement - Convert Command Number=" + retValue.length
+ + " (" + oraStatement + ") - " + m_convert.getConversionError());
+ }
+ //end vpj-cd 24/06/2005 e-evolution
+ // Diagnostics (show changed, but not if AD_Error
+ if (!oraStatement.equals(retValue[0]) && retValue[0].indexOf("AD_Error") == -1)
+ //begin vpj-cd 24/06/2005 e-evolution
+ //System.out.println("PostgreSQL =>" + retValue[0] + "<= <" + oraStatement + ">");
+ log.log(Level.INFO, "PostgreSQL =>" + retValue[0] + "<= <" + oraStatement + ">");
+ //end vpj-cd 24/06/2005 e-evolution
+ //
+ return retValue[0];
+ } // convertStatement
+
+
+ /**
+ * Get Name of System User
+ * @return e.g. sa, system
+ */
+ public String getSystemUser()
+ {
+ return "postgres";
+ } // getSystemUser
+
+ /**
+ * Get Name of System Database
+ * @param databaseName database Name
+ * @return e.g. master or database Name
+ */
+ public String getSystemDatabase(String databaseName)
+ {
+ return "template1";
+ } // getSystemDatabase
+
+
+ /**
+ * Create SQL TO Date String from Timestamp
+ *
+ * @param time Date to be converted
+ * @param dayOnly true if time set to 00:00:00
+ *
+ * @return TO_DATE('2001-01-30 18:10:20',''YYYY-MM-DD HH24:MI:SS')
+ * or TO_DATE('2001-01-30',''YYYY-MM-DD')
+ */
+ public String TO_DATE (Timestamp time, boolean dayOnly)
+ {
+ if (time == null)
+ {
+ if (dayOnly)
+ return "current_date()";
+ return "current_date()";
+ }
+
+ StringBuffer dateString = new StringBuffer("TO_DATE('");
+ // YYYY-MM-DD HH24:MI:SS.mmmm JDBC Timestamp format
+ String myDate = time.toString();
+ if (dayOnly)
+ {
+ dateString.append(myDate.substring(0,10));
+ dateString.append("','YYYY-MM-DD')");
+ }
+ else
+ {
+ dateString.append(myDate.substring(0, myDate.indexOf("."))); // cut off miliseconds
+ dateString.append("','YYYY-MM-DD HH24:MI:SS')");
+ }
+ return dateString.toString();
+ } // TO_DATE
+
+ /**
+ * Create SQL for formatted Date, Number
+ *
+ * @param columnName the column name in the SQL
+ * @param displayType Display Type
+ * @param AD_Language 6 character language setting (from Env.LANG_*)
+ *
+ * @return TRIM(TO_CHAR(columnName,'9G999G990D00','NLS_NUMERIC_CHARACTERS='',.'''))
+ * or TRIM(TO_CHAR(columnName,'TM9')) depending on DisplayType and Language
+ * @see org.compiere.util.DisplayType
+ * @see org.compiere.util.Env
+ *
+ **/
+ public String TO_CHAR (String columnName, int displayType, String AD_Language)
+ {
+ StringBuffer retValue = new StringBuffer("CAST (");
+ retValue.append(columnName);
+ retValue.append(" AS Text)");
+
+ // Numbers
+ /*
+ if (DisplayType.isNumeric(displayType))
+ {
+ if (displayType == DisplayType.Amount)
+ retValue.append(" AS TEXT");
+ else
+ retValue.append(" AS TEXT");
+ //if (!Language.isDecimalPoint(AD_Language)) // reversed
+ //retValue.append(",'NLS_NUMERIC_CHARACTERS='',.'''");
+ }
+ else if (DisplayType.isDate(displayType))
+ {
+ retValue.append(",'")
+ .append(Language.getLanguage(AD_Language).getDBdatePattern())
+ .append("'");
+ }
+ retValue.append(")");
+ //*/
+ return retValue.toString();
+ } // TO_CHAR
+
+ /**
+ * Return number as string for INSERT statements with correct precision
+ * @param number number
+ * @param displayType display Type
+ * @return number as string
+ */
+ public String TO_NUMBER (BigDecimal number, int displayType)
+ {
+ if (number == null)
+ return "NULL";
+ BigDecimal result = number;
+ int scale = DisplayType.getDefaultPrecision(displayType);
+ if (scale > number.scale())
+ {
+ try
+ {
+ result = number.setScale(scale, BigDecimal.ROUND_HALF_UP);
+ }
+ catch (Exception e)
+ {
+ // log.severe("Number=" + number + ", Scale=" + " - " + e.getMessage());
+ }
+ }
+ return result.toString();
+ } // TO_NUMBER
+
+
+ /**
+ * Get SQL Commands
+ * @param cmdType CMD_*
+ * @return array of commands to be executed
+ */
+ public String[] getCommands (int cmdType)
+ {
+ if (CMD_CREATE_USER == cmdType)
+ return new String[]
+ {
+ "CREATE USER compiere;",
+ };
+ //
+ if (CMD_CREATE_DATABASE == cmdType)
+ return new String[]
+ {
+ "CREATE DATABASE compiere OWNER compiere;",
+ "GRANT ALL PRIVILEGES ON compiere TO compiere;" ,
+ "CREATE SCHEMA compiere;",
+ "SET search_path TO compiere;"
+ };
+ //
+ if (CMD_DROP_DATABASE == cmdType)
+ return new String[]
+ {
+ "DROP DATABASE compiere;"
+ };
+ //
+ return null;
+ } // getCommands
+
+
+ /**************************************************************************
+ * Get RowSet
+ * @param rs ResultSet
+ * @return RowSet
+ * @throws SQLException
+ */
+ public RowSet getRowSet (java.sql.ResultSet rs) throws SQLException
+ {
+ throw new UnsupportedOperationException("PostgreSQL does not support RowSets");
+ } // getRowSet
+
+
+ /**
+ * Get Cached Connection
+ * @param connection connection
+ * @param autoCommit auto commit
+ * @param transactionIsolation trx isolation
+ * @return Connection
+ * @throws Exception
+ */
+ public Connection getCachedConnection (CConnection connection,
+ boolean autoCommit, int transactionIsolation)
+ throws Exception
+ {
+ if (m_ds == null)
+ getDataSource(connection);
+ //
+ Connection conn = m_ds.getConnection();
+ // Connection conn = getDriverConnection(connection);
+ //
+ conn.setAutoCommit(autoCommit);
+ conn.setTransactionIsolation(transactionIsolation);
+ return conn;
+ } // getCachedConnection
+
+
+ /**
+ * Create DataSource (Client)
+ * @param connection connection
+ * @return data dource
+ */
+ public DataSource getDataSource(CConnection connection)
+ {
+ //throw new UnsupportedOperationException("Not supported/implemented");
+ if (m_ds != null)
+ return m_ds;
+
+ //org.postgresql.ds.PGPoolingDataSource ds = new org.postgresql.ds.PGPoolingDataSource();
+ org.postgresql.jdbc3.Jdbc3PoolingDataSource ds = new org.postgresql.jdbc3.Jdbc3PoolingDataSource();
+ ds.setDataSourceName("CompiereDS");
+ ds.setServerName(connection.getDbHost());
+ ds.setDatabaseName(connection.getDbName());
+ ds.setUser(connection.getDbUid());
+ ds.setPassword(connection.getDbPwd());
+ ds.setPortNumber(connection.getDbPort());
+ ds.setMaxConnections(50);
+ ds.setInitialConnections(20);
+
+ //new InitialContext().rebind("DataSource", source);
+ m_ds = ds;
+
+ return m_ds;
+ }
+
+ /**
+ * Create Pooled DataSource (Server)
+ * @param connection connection
+ * @return data dource
+ */
+ public ConnectionPoolDataSource createPoolDataSource(CConnection connection)
+ {
+ throw new UnsupportedOperationException("Not supported/implemented");
+ }
+
+ /**
+ * Get Connection from Driver
+ * @param connection info
+ * @return connection or null
+ */
+ public Connection getDriverConnection (CConnection connection) throws SQLException
+ {
+ getDriver();
+ return DriverManager.getConnection (getConnectionURL (connection),
+ connection.getDbUid(), connection.getDbPwd());
+ } // getDriverConnection
+
+ /**
+ * Get Driver Connection
+ * @param dbUrl URL
+ * @param dbUid user
+ * @param dbPwd password
+ * @return connection
+ * @throws SQLException
+ */
+ public Connection getDriverConnection (String dbUrl, String dbUid, String dbPwd)
+ throws SQLException
+ {
+ getDriver();
+ return DriverManager.getConnection (dbUrl, dbUid, dbPwd);
+ } // getDriverConnection
+
+
+ /**
+ * Close
+ */
+ public void close()
+ {
+
+ log.config(toString());
+ if (m_ds != null)
+ {
+ try
+ {
+ m_ds.close();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ m_ds = null;
+ } // close
+
+
+ /**
+ * Check and generate an alternative SQL
+ * @reExNo number of re-execution
+ * @msg previous execution error message
+ * @sql previous executed SQL
+ * @return String, the alternative SQL, null if no alternative
+ */
+ public String getAlternativeSQL(int reExNo, String msg, String sql)
+ {
+ return null; //do not do re-execution of alternative SQL
+ }
+
+ /**
+ * Get constraint type associated with the index
+ * @tableName table name
+ * @IXName Index name
+ * @return String[0] = 0: do not know, 1: Primary Key 2: Foreign Key
+ * String[1] - String[n] = Constraint Name
+ */
+ public String getConstraintType(Connection conn, String tableName, String IXName)
+ {
+ if (IXName == null || IXName.length()==0)
+ return "0";
+ if (IXName.endsWith("_KEY"))
+ return "1"+IXName;
+ else
+ return "0";
+ //jz temp, modify later from user.constraints
+ }
+
+ /**
+ * Check if DBMS support the sql statement
+ * @sql SQL statement
+ * @return true: yes
+ */
+ public boolean isSupported(String sql)
+ {
+ return true;
+ //jz temp, modify later
+ }
+
+
+
+ /**
+ * Test
+ * @param args ignored
+ */
+ public static void main(String[] args)
+ {
+ DB_PostgreSQL postgresql = new DB_PostgreSQL();
+ //
+ String databaseName = "adempiere";
+ String uid = "adempiere";
+ String pwd = "adempiere";
+ String jdbcURL = postgresql.getConnectionURL("vpj", DEFAULT_PORT, databaseName, uid);
+ System.out.println(jdbcURL);
+ try
+ {
+ postgresql.getDriver();
+ Connection conn = DriverManager.getConnection (jdbcURL, uid, pwd);
+
+ //CachedRowSetImpl crs = null;
+ //crs = new CachedRowSetImpl();
+ //crs.setSyncProvider("com.sun.rowset.providers.RIOptimisticProvider");
+ //crs.setConcurrency(ResultSet.CONCUR_READ_ONLY);
+ //crs.setType(ResultSet.TYPE_SCROLL_INSENSITIVE);
+ //crs.setCommand("SELECT * FROM AD_Client");
+ //
+ //crs.execute(conn);
+ //
+ conn.close();
+ conn = null;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ } // main
+
+} // DB_PostgreSQL
diff --git a/dbPort/src/org/compiere/db/Database.java b/dbPort/src/org/compiere/db/Database.java
new file mode 100644
index 0000000000..b9f5b285ac
--- /dev/null
+++ b/dbPort/src/org/compiere/db/Database.java
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+/**
+ * General Database Constants and Utilities
+ *
+ * @author Jorg Janke
+ * @version $Id: Database.java,v 1.3 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class Database
+{
+ /** Oracle ID */
+ public static String DB_ORACLE = "Oracle";
+ /** IBM DB/2 ID */
+ public static String DB_DB2 = "DB2";
+ /** Derby ID */
+ public static String DB_DERBY = "Derby";
+ /** Microsoft ID */
+ public static String DB_MSSQLServer = "SQLServer";
+ /** PostgreSQL ID */
+ public static String DB_POSTGRESQL = "PostgreSQL";
+ // begin vpj-c e-evolution 11/30/2005 EDB
+ /** Enterprise DB */
+ //public static String DB_EDB = "EnterpriseDB";
+ // end vpj-c e-evolution 11/30/2005 EDB
+
+
+ /** Supported Databases */
+ public static String[] DB_NAMES = new String[] {
+ DB_ORACLE
+ ,DB_DB2
+ // ,DB_DERBY
+ // ,DB_MSSQLServer
+ // begin vpj-c e-evolution 02/08/205 PostgreSQL
+ ,DB_POSTGRESQL
+ // ,DB_EDB
+ // end e-evolution 02/08/2005 PostgreSQL
+ };
+
+ /** Database Classes */
+ protected static Class[] DB_CLASSES = new Class[] {
+ DB_Oracle.class
+ ,DB_DB2.class
+ // ,DB_Derby.class
+ // ,DB_MSSQLServer.class
+ //begin vpj-c e-evolution 02/08/2005 PostgreSQL
+ ,DB_PostgreSQL.class
+ // ,DB_EDB.class
+ //end e-evolution 02/08/205 PostgreSQL
+ };
+
+ /** Connection Timeout in seconds */
+ public static int CONNECTION_TIMEOUT = 10;
+
+} // Database
diff --git a/dbPort/src/org/compiere/db/Database16.gif b/dbPort/src/org/compiere/db/Database16.gif
new file mode 100644
index 0000000000..6ac0e3fd5d
Binary files /dev/null and b/dbPort/src/org/compiere/db/Database16.gif differ
diff --git a/dbPort/src/org/compiere/db/JDBCInfo.java b/dbPort/src/org/compiere/db/JDBCInfo.java
new file mode 100644
index 0000000000..ba4cc3fbe2
--- /dev/null
+++ b/dbPort/src/org/compiere/db/JDBCInfo.java
@@ -0,0 +1,180 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.sql.*;
+import java.util.logging.*;
+import org.compiere.*;
+import org.compiere.util.*;
+
+/**
+ * JDBC Meta Info
+ *
+ * @author Jorg Janke
+ * @version $Id: JDBCInfo.java,v 1.3 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class JDBCInfo
+{
+ /**
+ * Constructor
+ * @param conn connection
+ * @throws SQLException
+ */
+ public JDBCInfo(Connection conn) throws SQLException
+ {
+ m_md = conn.getMetaData();
+ log.info(m_md.getDatabaseProductName());
+ log.config(m_md.getDatabaseProductVersion());
+ // log.config(m_md.getDatabaseMajorVersion() + "/" + m_md.getDatabaseMinorVersion());
+ //
+ log.info(m_md.getDriverName());
+ log.config(m_md.getDriverVersion());
+ log.config(m_md.getDriverMajorVersion() + "/" + m_md.getDriverMinorVersion());
+ //
+ // log.info("JDBC = " + m_md.getJDBCMajorVersion() + "/" + m_md.getJDBCMinorVersion());
+ } // JDBCInfo
+
+ /** Mata Data */
+ private DatabaseMetaData m_md = null;
+
+ /** Logger */
+ private static CLogger log = CLogger.getCLogger (JDBCInfo.class);
+
+ /**
+ * List All
+ */
+ public void listAll()
+ {
+ try
+ {
+ listSchemas();
+ }
+ catch (Exception e)
+ {
+ log.severe(e.getMessage());
+ }
+ try
+ {
+ listCatalogs();
+ }
+ catch (Exception e)
+ {
+ log.severe(e.getMessage());
+ }
+ try
+ {
+ listTypes();
+ }
+ catch (Exception e)
+ {
+ log.severe(e.getMessage());
+ }
+ } // listAll
+
+ /**
+ * List Catalogs
+ * @throws SQLException
+ */
+ public void listCatalogs() throws SQLException
+ {
+ log.info(m_md.getCatalogTerm() + " -> " + m_md.getCatalogSeparator());
+ ResultSet rs = m_md.getCatalogs();
+ while (rs.next())
+ {
+ dump(rs);
+ }
+ } // listCatalogs
+
+ /**
+ * List Schemas
+ * @throws SQLException
+ */
+ public void listSchemas() throws SQLException
+ {
+ log.info(m_md.getSchemaTerm());
+ ResultSet rs = m_md.getSchemas();
+ while (rs.next())
+ {
+ dump(rs);
+ }
+ } // listSchemas
+
+ /**
+ * List Types
+ * @throws SQLException
+ */
+ public void listTypes() throws SQLException
+ {
+ ResultSet rs = m_md.getTypeInfo();
+ while (rs.next())
+ {
+ log.info("");
+ dump(rs);
+ }
+ } // listTypes
+
+ /**
+ * Dump the current row of a Result Set
+ * @param rs result set
+ * @throws SQLException
+ */
+ public static void dump(ResultSet rs) throws SQLException
+ {
+ ResultSetMetaData md = rs.getMetaData();
+ for (int i = 0; i < md.getColumnCount(); i++)
+ {
+ int index = i + 1;
+ String info = md.getColumnLabel(index);
+ String name = md.getColumnName(index);
+ if (info == null)
+ info = name;
+ else if (name != null && !name.equals(info))
+ info += " (" + name + ")";
+ info += " = "
+ + rs.getString(index);
+ info += " [" + md.getColumnTypeName(index)
+ + "(" + md.getPrecision(index);
+ if (md.getScale(index) != 0)
+ info += "," + md.getScale(index);
+ info += ")]";
+ log.fine(info);
+ }
+ } // dump
+
+ /**************************************************************************
+ * Test
+ * @param args ignored
+ */
+ public static void main (String[] args)
+ {
+ Adempiere.startup(true);
+ CLogMgt.setLevel(Level.ALL);
+ //
+ try
+ {
+ JDBCInfo info = new JDBCInfo(DB.createConnection(true, Connection.TRANSACTION_READ_COMMITTED));
+ info.listCatalogs();
+ info.listSchemas();
+ info.listTypes();
+ }
+ catch (Exception e)
+ {
+ log.log(Level.SEVERE, "", e);
+ }
+ } // main
+
+} // JDBCInfo
diff --git a/dbPort/src/org/compiere/db/LDAP.java b/dbPort/src/org/compiere/db/LDAP.java
new file mode 100644
index 0000000000..2d7d159709
--- /dev/null
+++ b/dbPort/src/org/compiere/db/LDAP.java
@@ -0,0 +1,200 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.util.*;
+import java.util.logging.*;
+
+import javax.naming.*;
+import javax.naming.ldap.*;
+import javax.naming.directory.*;
+
+import org.compiere.util.*;
+
+
+/**
+ * LDAP Management Interface
+ *
+ * @author Jorg Janke
+ * @version $Id: LDAP.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class LDAP
+{
+ /**
+ * Validate User
+ * @param ldapURL provider url - e.g. ldap://dc.adempiere.org
+ * @param domain domain name = e.g. adempiere.org
+ * @param userName user name - e.g. jjanke
+ * @param password password
+ * @return true if validated with ldap
+ */
+ public static boolean validate (String ldapURL, String domain, String userName, String password)
+ {
+ Hashtable env = new Hashtable();
+ env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
+ // ldap://dc.adempiere.org
+ env.put(Context.PROVIDER_URL, ldapURL);
+ env.put(Context.SECURITY_AUTHENTICATION, "simple");
+ // jjanke@adempiere.org
+ StringBuffer principal = new StringBuffer (userName)
+ .append("@").append(domain);
+ env.put(Context.SECURITY_PRINCIPAL, principal.toString());
+ env.put(Context.SECURITY_CREDENTIALS, password);
+ //
+ try
+ {
+ // Create the initial context
+ InitialLdapContext ctx = new InitialLdapContext(env, null);
+ // DirContext ctx = new InitialDirContext(env);
+
+ // Test - Get the attributes
+ Attributes answer = ctx.getAttributes("");
+
+ // Print the answer
+ // dump (answer);
+ }
+ catch (AuthenticationException e)
+ {
+ log.info("Error: " + principal + " - " + e.getLocalizedMessage());
+ return false;
+ }
+ catch (Exception e)
+ {
+ log.log (Level.SEVERE, ldapURL + " - " + principal, e);
+ return false;
+ }
+ log.info("OK: " + principal);
+ return true;
+ } // validate
+
+ /** Logger */
+ private static CLogger log = CLogger.getCLogger (LDAP.class);
+
+
+ /**
+ * Test NT
+ * @throws LoginException
+ *
+ private static void testNT () throws LoginException
+ {
+ try
+ {
+ System.out.println ("NT system ----------------------------");
+ NTSystem ntsystem = new NTSystem ();
+ System.out.println (ntsystem);
+ System.out.println (ntsystem.getDomain ());
+ System.out.println (ntsystem.getDomainSID ());
+ System.out.println (ntsystem.getName ());
+ System.out.println (ntsystem.getUserSID ());
+ System.out.println ("NT login ----------------------------");
+ NTLoginModule ntlogin = new NTLoginModule ();
+ System.out.println (ntlogin);
+ Map map = new HashMap();
+ map.put ("debug", "true");
+ ntlogin.initialize (null, null, null, map);
+ System.out.println (ntlogin.login ());
+ }
+ catch (LoginException le)
+ {
+ System.err.println ("Authentication attempt failed" + le);
+ }
+ } // testNT
+
+
+ /**
+ * testKerberos
+ * @throws LoginException
+ *
+ private static void testKerberos ()
+ throws LoginException
+ {
+ System.out.println ("Krb login ----------------------------");
+ Map map = new HashMap();
+ // map.put("debug", "true");
+ // map.put("debugNative", "true");
+ Krb5LoginModule klogin = new Krb5LoginModule ();
+ System.out.println (klogin);
+ map.put ("principal", "username@adempiere.org");
+ map.put ("credential", "pass");
+ klogin.initialize (null, null, null, map);
+ System.out.println (klogin.login ());
+ /***********************************************************************
+ * ** No krb5.ini file found in entire system Debug is true storeKey
+ * false useTicketCache false useKeyTab false doNotPrompt false
+ * ticketCache is null KeyTab is null refreshKrb5Config is false
+ * principal is jjanke tryFirstPass is false useFirstPass is false
+ * storePass is false clearPass is false [Krb5LoginModule]
+ * authentication failed Could not load configuration file
+ * c:\winnt\krb5.ini (The system cannot find the file specified)
+ * javax.security.auth.login.LoginException: Could not load
+ * configuration file c:\winnt\krb5.ini (The system cannot find the file
+ * specified)
+ *
+ } // testKerbos
+ /**/
+
+ /**
+ * Print Attributes to System.out
+ * @param attrs
+ */
+ private static void dump (Attributes attrs)
+ {
+ if (attrs == null)
+ {
+ System.out.println ("No attributes");
+ }
+ else
+ {
+ /* Print each attribute */
+ try
+ {
+ for (NamingEnumeration ae = attrs.getAll (); ae.hasMore ();)
+ {
+ Attribute attr = (Attribute) ae.next ();
+ System.out.println ("attribute: " + attr.getID ());
+ /* print each value */
+ for (NamingEnumeration e = attr.getAll();
+ e.hasMore ();
+ System.out.println (" value: " + e.next()))
+ ;
+ }
+ }
+ catch (NamingException e)
+ {
+ e.printStackTrace ();
+ }
+ }
+ } // dump
+
+ /**
+ * Test
+ * @param args ignored
+ */
+ public static void main (String[] args)
+ {
+ try
+ {
+ validate("ldap://dc.adempiere.org", "adempiere.org", "red1", "ikeepforgetting");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ } // main
+
+} // LDAP
+
diff --git a/dbPort/src/org/compiere/db/Server16.gif b/dbPort/src/org/compiere/db/Server16.gif
new file mode 100644
index 0000000000..068ffebee2
Binary files /dev/null and b/dbPort/src/org/compiere/db/Server16.gif differ
diff --git a/dbPort/src/org/compiere/db/TestConnection.java b/dbPort/src/org/compiere/db/TestConnection.java
new file mode 100644
index 0000000000..f665577b3f
--- /dev/null
+++ b/dbPort/src/org/compiere/db/TestConnection.java
@@ -0,0 +1,225 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import java.sql.*;
+
+/**
+ * Test Connection (speed)
+ *
+ * @author Jorg Janke
+ * @version $Id: TestConnection.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class TestConnection
+{
+
+ /**
+ * Test Connection
+ *
+ * @param jdbcURL JDBC URL
+ * @param uid user
+ * @param pwd password
+ */
+ public TestConnection (String jdbcURL, String uid, String pwd)
+ {
+ System.out.println("Test Connection for " + jdbcURL);
+ m_jdbcURL = jdbcURL;
+ m_uid = uid;
+ m_pwd = pwd;
+ init();
+ if (m_conn != null)
+ {
+ long time = test();
+ time += test();
+ time += test();
+ time += test();
+ System.out.println("");
+ System.out.println("Total Average (" + m_jdbcURL + ")= " + (time/4) + "ms");
+ }
+ } // TestConnection
+
+ private String m_jdbcURL;
+ private String m_uid = "adempiere";
+ private String m_pwd = "adempiere";
+ private String m_sql = "SELECT * FROM AD_Element";
+ private Connection m_conn;
+
+ /**
+ * Initialize & Open Connection
+ */
+ private void init()
+ {
+ long start = System.currentTimeMillis();
+ Driver driver = null;
+ try
+ {
+ driver = DriverManager.getDriver(m_jdbcURL);
+ }
+ catch (SQLException ex)
+ {
+ // System.err.println("Init - get Driver: " + ex);
+ }
+ if (driver == null)
+ {
+ try
+ {
+ DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
+ }
+ catch (SQLException ex)
+ {
+ System.err.println("Init = register Driver: " + ex);
+ }
+ }
+ long end = System.currentTimeMillis();
+ System.out.println("(1) Driver = " + (end - start) + "ms");
+ //
+ start = System.currentTimeMillis();
+ try
+ {
+ m_conn = DriverManager.getConnection(m_jdbcURL, m_uid, m_pwd);
+ }
+ catch (SQLException ex)
+ {
+ System.err.println("Init = get Connection: " + ex);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("(2) Get Connection = " + (end - start) + "ms");
+ //
+ start = System.currentTimeMillis();
+ try
+ {
+ if (m_conn != null)
+ m_conn.close();
+ }
+ catch (SQLException ex)
+ {
+ System.err.println("Init = close Connection: " + ex);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("(3) Close Connection = " + (end - start) + "ms");
+ } // init
+
+ /**
+ * Test ResultSet
+ * @return time in ms
+ */
+ private long test()
+ {
+ System.out.println("");
+ long totalStart = System.currentTimeMillis();
+ long start = System.currentTimeMillis();
+ try
+ {
+ m_conn = DriverManager.getConnection(m_jdbcURL, m_uid, m_pwd);
+ }
+ catch (SQLException ex)
+ {
+ System.err.println("Test get Connection: " + ex);
+ return -1;
+ }
+ long end = System.currentTimeMillis();
+ System.out.println("(A) Get Connection = " + (end - start) + "ms");
+ //
+ try
+ {
+ start = System.currentTimeMillis();
+ Statement stmt = m_conn.createStatement();
+ end = System.currentTimeMillis();
+ System.out.println("(B) Create Statement = " + (end - start) + "ms");
+ //
+ start = System.currentTimeMillis();
+ ResultSet rs = stmt.executeQuery(m_sql);
+ end = System.currentTimeMillis();
+ System.out.println("(C) Execute Query = " + (end - start) + "ms");
+ //
+ int no = 0;
+ start = System.currentTimeMillis();
+ while (rs.next())
+ {
+ int i = rs.getInt("AD_Client_ID");
+ String s = rs.getString("Name");
+ i += s.length();
+ no++;
+ }
+ end = System.currentTimeMillis();
+ System.out.println("(D) Read ResultSet = " + (end - start) + "ms - per 10 rows " + ((end - start)/(no/10)) + "ms");
+ //
+ start = System.currentTimeMillis();
+ rs.close();
+ end = System.currentTimeMillis();
+ System.out.println("(E) Close ResultSet = " + (end - start) + "ms");
+ //
+ start = System.currentTimeMillis();
+ stmt.close();
+ end = System.currentTimeMillis();
+ System.out.println("(F) Close Statement = " + (end - start) + "ms");
+ }
+ catch (SQLException e)
+ {
+ System.err.println("Test: " + e);
+ }
+ //
+ start = System.currentTimeMillis();
+ try
+ {
+ if (m_conn != null)
+ m_conn.close();
+ }
+ catch (SQLException ex)
+ {
+ System.err.println("Test close Connection: " + ex);
+ }
+ end = System.currentTimeMillis();
+ System.out.println("(G) Close Connection = " + (end - start) + "ms");
+
+ long totalEnd = System.currentTimeMillis();
+ System.out.println("Total Test = " + (totalEnd - totalStart) + "ms");
+ return (totalEnd - totalStart);
+ } // test
+
+ /*************************************************************************/
+
+ /**
+ * Test Connection.
+ * java -cp dbPort.jar;oracle.jar org.compiere.db.TestConnection
+ * @param args arguments optional
+ * Example: jdbc:oracle:thin:@dev:1521:dev adempiere adempiere
+ */
+ public static void main(String[] args)
+ {
+ String url = "jdbc:oracle:thin:@//24.151.26.64:1521/lap11";
+ String uid = "adempiere";
+ String pwd = "adempiere";
+ //
+ if (args.length == 0)
+ {
+ System.out.println("TestConnection ");
+ System.out.println("Example: jdbc:oracle:thin:@//dev:1521/dev adempiere adempiere");
+ System.out.println("Example: jdbc:oracle:oci8:@dev adempiere adempiere");
+ }
+ else if (args.length > 0)
+ url = args[0];
+ else if (args.length > 1)
+ url = args[1];
+ else if (args.length > 2)
+ url = args[2];
+
+ System.out.println("");
+ TestConnection test = new TestConnection(url, uid, pwd);
+ } // main
+
+} // TestConnection
diff --git a/dbPort/src/org/compiere/db/TestEJB.java b/dbPort/src/org/compiere/db/TestEJB.java
new file mode 100644
index 0000000000..95bd82ac46
--- /dev/null
+++ b/dbPort/src/org/compiere/db/TestEJB.java
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.db;
+
+import javax.naming.*;
+import org.compiere.interfaces.*;
+
+/**
+ * Test EJB
+ *
+ * @author Jorg Janke
+ * @version $Id: TestEJB.java,v 1.3 2006/07/30 00:55:13 jjanke Exp $
+ */
+public class TestEJB
+{
+ /**
+ * TestEJB
+ */
+ public TestEJB ()
+ {
+ CConnection cc = CConnection.get(null);
+ cc.setAppsHost("dev1");
+ InitialContext ic = cc.getInitialContext(false);
+ /**/
+ try
+ {
+ System.out.println(ic.getEnvironment());
+ System.out.println("----------------");
+ NamingEnumeration ne = ic.list("");
+ while (ne.hasMore())
+ {
+ System.out.println(ne.next());
+ }
+ }
+ catch (Exception e)
+ {
+ System.err.println("..");
+ e.printStackTrace();
+ System.exit(1);
+ }
+ /**/
+
+ //
+ try
+ {
+ StatusHome statusHome = (StatusHome)ic.lookup ("Status");
+ Status status = statusHome.create ();
+ //
+ }
+ catch (CommunicationException ce) // not a "real" error
+ {
+ System.err.println("=ce=");
+ ce.printStackTrace();
+ }
+ catch (Exception e)
+ {
+ System.err.println("=e=");
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * main
+ * @param args
+ */
+ public static void main (String[] args)
+ {
+ new TestEJB();
+ } // main
+
+} // TestEJB
diff --git a/dbPort/src/org/compiere/db/package.html b/dbPort/src/org/compiere/db/package.html
new file mode 100644
index 0000000000..4cbefaddaf
--- /dev/null
+++ b/dbPort/src/org/compiere/db/package.html
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+Provides for....
+
+
+
+
+
+
+
diff --git a/dbPort/src/org/compiere/dbPort/Convert.java b/dbPort/src/org/compiere/dbPort/Convert.java
new file mode 100644
index 0000000000..84734dc1a6
--- /dev/null
+++ b/dbPort/src/org/compiere/dbPort/Convert.java
@@ -0,0 +1,2301 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.dbPort;
+
+import java.sql.*;
+import java.util.*;
+import java.util.logging.*;
+import java.util.regex.*;
+import org.compiere.db.*;
+import org.compiere.util.*;
+
+/**
+ * Convert SQL to Target DB
+ *
+ * @author Jorg Janke, Victor Perez
+ * @version $Id: Convert.java,v 1.3 2006/07/30 00:55:04 jjanke Exp $
+ */
+public class Convert
+{
+ /**
+ * Cosntructor
+ * @param type Database.DB_
+ */
+ public Convert (String type)
+ {
+ if (Database.DB_ORACLE.equals(type))
+ m_isOracle = true;
+ else if (Database.DB_DERBY.equals(type))
+ m_map = ConvertMap.getDerbyMap();
+ else if (Database.DB_DB2.equals(type))
+ m_map = ConvertMap.getDB2Map();
+ // begin vpj-cd e-evolution 07 Dic 2005
+ else if (Database.DB_POSTGRESQL.equals(type))
+ m_map = ConvertMap.getPostgeSQLMap();
+// else if (Database.DB_EDB.equals(type))
+// m_isOracle = true;
+ // end vpj-cd e-evolution 07 Dic 2005
+ else
+ throw new UnsupportedOperationException ("Unsupported database: " + type);
+ } // Convert
+
+ /** RegEx: insensitive and dot to include line end characters */
+ public static final int REGEX_FLAGS = Pattern.CASE_INSENSITIVE | Pattern.DOTALL;
+
+ /** Is Oracle */
+ private boolean m_isOracle = false;
+ /** Used Resorce Bundle */
+ private TreeMap m_map;
+
+ /** Statement used */
+ private Statement m_stmt = null;
+
+ /** Last Conversion Error */
+ private String m_conversionError = null;
+ /** Last Execution Error */
+ private Exception m_exception = null;
+ /** Verbose Messages */
+ private boolean m_verbose = true;
+
+ /** Logger */
+ private static CLogger log = CLogger.getCLogger (Convert.class);
+
+ /**
+ * Set Verbose
+ * @param verbose
+ */
+ public void setVerbose (boolean verbose)
+ {
+ m_verbose = verbose;
+ } // setVerbose
+
+ /**
+ * Is Oracle DB
+ * @return true if connection is Oracle DB
+ */
+ public boolean isOracle()
+ {
+ return m_isOracle;
+ } // isOracle
+
+
+ /**************************************************************************
+ * Execute SQL Statement (stops at first error).
+ * If an error occured hadError() returns true.
+ * You can get details via getConversionError() or getException()
+ * @param sqlStatements
+ * @param conn connection
+ * @return true if success
+ * @throws IllegalStateException if no connection
+ */
+ public boolean execute (String sqlStatements, Connection conn)
+ {
+ if (conn == null)
+ throw new IllegalStateException ("Require connection");
+ //
+ String[] sql = convert (sqlStatements);
+ m_exception = null;
+ if (m_conversionError != null || sql == null)
+ return false;
+
+ boolean ok = true;
+ int i = 0;
+ String statement = null;
+ try
+ {
+ if (m_stmt == null)
+ m_stmt = conn.createStatement();
+ //
+ for (i = 0; ok && i < sql.length; i++)
+ {
+ statement = sql[i];
+ if (statement.length() == 0)
+ {
+ if (m_verbose)
+ log.finer("Skipping empty (" + i + ")");
+ }
+ else
+ {
+ if (m_verbose)
+ log.info("Executing (" + i + ") <<" + statement + ">>");
+ else
+ log.info("Executing " + i);
+ try
+ {
+ m_stmt.clearWarnings();
+ int no = m_stmt.executeUpdate(statement);
+ SQLWarning warn = m_stmt.getWarnings();
+ if (warn != null)
+ {
+ if (m_verbose)
+ log.info("- " + warn);
+ else
+ {
+ log.info("Executing (" + i + ") <<" + statement + ">>");
+ log.info("- " + warn);
+ }
+ }
+ if (m_verbose)
+ log.fine("- ok " + no);
+ }
+ catch (SQLException ex)
+ {
+ // Ignore Drop Errors
+ if (!statement.startsWith("DROP "))
+ {
+ ok = false;
+ m_exception = ex;
+ }
+ if (!m_verbose)
+ log.info("Executing (" + i + ") <<" + statement + ">>");
+ log.info("Error executing " + i + "/" + sql.length + " = " + ex);
+ }
+ }
+ } // for all statements
+ }
+ catch (SQLException e)
+ {
+ m_exception = e;
+ if (!m_verbose)
+ log.info("Executing (" + i + ") <<" + statement + ">>");
+ log.info("Error executing " + i + "/" + sql.length + " = " + e);
+ return false;
+ }
+ return ok;
+ } // execute
+
+ /**
+ * Return last execution exception
+ * @return execution exception
+ */
+ public Exception getException()
+ {
+ return m_exception;
+ } // getException
+
+ /**
+ * Returns true if a conversion or execution error had occured.
+ * Get more details via getConversionError() or getException()
+ * @return true if error had occured
+ */
+ public boolean hasError()
+ {
+ return (m_exception != null) | (m_conversionError != null);
+ } // hasError
+
+ /**
+ * Convert SQL Statement (stops at first error).
+ * Statements are delimited by /
+ * If an error occured hadError() returns true.
+ * You can get details via getConversionError()
+ * @param sqlStatements
+ * @return converted statement as a string
+ */
+ public String convertAll (String sqlStatements)
+ {
+ String[] sql = convert (sqlStatements);
+ StringBuffer sb = new StringBuffer (sqlStatements.length() + 10);
+ for (int i = 0; i < sql.length; i++)
+ {
+ // line.separator
+ sb.append(sql[i]).append("\n/\n");
+ if (m_verbose)
+ log.info("Statement " + i + ": " + sql[i]);
+ }
+ return sb.toString();
+ } // convertAll
+
+ /**
+ * Convert SQL Statement (stops at first error).
+ * If an error occured hadError() returns true.
+ * You can get details via getConversionError()
+ * @param sqlStatements
+ * @return Array of converted Statements
+ */
+ public String[] convert (String sqlStatements)
+ {
+ m_conversionError = null;
+ if (sqlStatements == null || sqlStatements.length() == 0)
+ {
+ m_conversionError = "SQL_Statement is null or has zero length";
+ log.info(m_conversionError);
+ return null;
+ }
+ //
+ return convertIt (sqlStatements);
+ } // convert
+
+ /**
+ * Return last conversion error or null.
+ * @return lst conversion error
+ */
+ public String getConversionError()
+ {
+ return m_conversionError;
+ } // getConversionError
+
+
+ /**************************************************************************
+ * Conversion routine (stops at first error).
+ *
+ * - mask / in Strings
+ * - break into single statement
+ * - unmask statements
+ * - for each statement: convertStatement
+ * - remove comments
+ * - process FUNCTION/TRIGGER/PROCEDURE
+ * - process Statement: convertSimpleStatement
+ * - based on ConvertMap
+ * - convertComplexStatement
+ * - decode, sequence, exception
+ *
+ * @param sqlStatements
+ * @return array of converted statements
+ */
+ private String[] convertIt (String sqlStatements)
+ {
+ // Need to mask / in SQL Strings !
+ final char MASK = '\u001F'; // Unit Separator
+ StringBuffer masked = new StringBuffer(sqlStatements.length());
+ Matcher m = Pattern.compile("'[^']+'", Pattern.DOTALL).matcher(sqlStatements);
+ while (m.find())
+ {
+ String group = m.group(); // SQL string
+ if (group.indexOf("/") != -1) // / in string
+ group = group.replace('/', MASK);
+ if (group.indexOf('$') != -1) // Group character needs to be escaped
+ group = Util.replace(group, "$", "\\$");
+ m.appendReplacement(masked, group);
+ }
+ m.appendTail(masked);
+ String tempResult = masked.toString();
+ /** @todo Need to mask / in comments */
+
+
+ // Statements ending with /
+ String[] sql = tempResult.split("\\s/\\s"); // ("(;\\s)|(\\s/\\s)");
+ ArrayList result = new ArrayList (sql.length);
+ // process statements
+ for (int i = 0; i < sql.length; i++)
+ {
+ String statement = sql[i];
+ if (statement.indexOf(MASK) != -1)
+ statement = statement.replace(MASK, '/');
+ result.addAll(convertStatement(statement)); // may return more than one target statement
+ }
+ // convert to array
+ sql = new String[result.size()];
+ result.toArray(sql);
+ return sql;
+ } // convertIt
+
+ /**
+ * Convert single Statements.
+ * - remove comments
+ * - process FUNCTION/TRIGGER/PROCEDURE
+ * - process Statement
+ * @param sqlStatement
+ * @return converted statement
+ */
+ private ArrayList convertStatement (String sqlStatement)
+ {
+ ArrayList result = new ArrayList();
+ if (m_isOracle)
+ {
+ result.add(sqlStatement);
+ return result;
+ }
+
+ // remove comments
+ String statement = removeComments (sqlStatement);
+ // log.info("------------------------------------------------------------");
+ // log.info(statement);
+ // log.info("------------------->");
+
+ String cmpString = statement.toUpperCase();
+ boolean isCreate = cmpString.startsWith("CREATE ");
+
+ // Process
+ if (isCreate && cmpString.indexOf(" FUNCTION ") != -1)
+ result.addAll(convertFunction(statement));
+
+ else if (isCreate && cmpString.indexOf(" TRIGGER ") != -1)
+ result.addAll(convertTrigger(statement));
+
+ else if (isCreate && cmpString.indexOf(" PROCEDURE ") != -1)
+ result.addAll(convertProcedure(statement));
+
+ else if (isCreate && cmpString.indexOf(" VIEW ") != -1)
+ result.addAll(convertView(statement));
+//begin vpj-cd e-evolution 02/24/2005 PostgreSQL
+ else if (cmpString.indexOf("ALTER TABLE") != -1)
+ {
+ result.add(convertDDL(statement));
+ }
+ else if (cmpString.indexOf("ROWNUM") != -1)
+ {
+ result.add(convertRowNum(convertAlias(converSimpleStatement(statement))));
+ }
+ else if (cmpString.indexOf("DELETE ") != -1 && cmpString.indexOf("DELETE FROM") == -1)
+ {
+
+ statement = convertDelete(statement);
+ cmpString = statement;
+ //System.out.println("-------------cmpString:"+cmpString);
+ result.add(converSimpleStatement(convertAlias(cmpString)));
+ }
+ else if (cmpString.indexOf("DELETE FROM") != -1)
+ {
+
+ result.add(converSimpleStatement(convertAlias(statement)));
+ }
+ else if (cmpString.indexOf("UPDATE") != -1)
+ {
+ result.add(converSimpleStatement(convertUpdate(convertAlias(statement))));
+ }
+ else
+ {
+ result.add(converSimpleStatement(convertAlias(statement)));
+ }
+ // else
+// result.add(converSimpleStatement(statement));
+ //end vpj-cd e-evolution 02/24/2005 PostgreSQL
+ // Simple Statement
+
+ //
+ // log.info("<-------------------");
+ // for (int i = 0; i < result.size(); i++)
+ // log.info(result.get(i));
+ // log.info("------------------------------------------------------------");
+
+ return result;
+ } // convertStatement
+
+ /**
+ * Convert simple SQL Statement.
+ * Based on ConvertMap
+ *
+ * @param sqlStatement
+ * @return converted Statement
+ */
+ private String converSimpleStatement (String sqlStatement)
+ {
+ // Error Checks
+ if (sqlStatement.toUpperCase().indexOf("EXCEPTION WHEN") != -1)
+ {
+ String error = "Exception clause needs to be converted: " + sqlStatement;
+ log.info (error);
+ m_conversionError = error;
+ return sqlStatement;
+ }
+
+ // Standard Statement
+ String retValue = sqlStatement;
+ Iterator iter = m_map.keySet().iterator();
+ while (iter.hasNext())
+ {
+ //begin e-evolution vpj-cd 26.09.2005
+ // search reserved word ie DATE into 'DATE' and remplace for character temporal <-->
+ Vector retVars = new Vector();
+ Pattern p = Pattern.compile("'[[\\w]*[-:,\\(\\)]*[ ]*]*'");
+ Matcher m = p.matcher(retValue);
+ while(m.find()) {
+ retVars.addElement(new String(retValue.substring(m.start(),m.end())) );
+ }
+ retVars.addElement( new String(m.replaceAll("<-->")) );
+ // end e-evolution vpj-cd 26.09.2005*/
+
+ String regex = (String)iter.next();
+ String replacement = (String)m_map.get(regex);
+ try
+ {
+ //begin e-evolution vpj-cd 29.09.2005
+ //Pattern p = Pattern.compile(regex, REGEX_FLAGS );
+ //Matcher m = p.matcher(retValue);
+ //retValue = m.replaceAll(replacement);
+ // remplace reserved work
+ p = Pattern.compile(regex, REGEX_FLAGS );
+ m = p.matcher((String)retVars.get(retVars.size()-1));
+ retValue=m.replaceAll(replacement);
+
+ p = Pattern.compile("<-->",REGEX_FLAGS);
+ m = p.matcher(retValue);
+ for(int cont=0; cont
+ * /*ORACLE>*/
+ * Oracle Specific Statement
+ * /*<ORACLE*/
+ * /*POSTGRESQL>
+ * PostgreSQL Specicic Statements
+ * <POSTGRESQL*/
+ *
+ * @param statement
+ * @return sql statement
+ */
+ protected String removeComments (String statement)
+ {
+ String clean = statement.trim();
+
+ // Remove /*ORACLE>*/ /*.*
+ m = Pattern.compile("\\/\\*POSTGRESQL>").matcher(clean);
+ clean = m.replaceAll("");
+ // Remove
+ * CREATE OR REPLACE FUNCTION AD_Message_Get
+ * (p_AD_Message IN VARCHAR, p_AD_Language IN VARCHAR)
+ * RETURN VARCHAR AS
+ * ...
+ * END AD_Message_Get;
+ * =>
+ * CREATE FUNCTION AD_Message_Get
+ * (VARCHAR, VARCHAR)
+ * RETURNS VARCHAR AS '
+ * DECLARE
+ * p_AD_Message ALIAS FOR $1;
+ * p_AD_Language ALIAS FOR $2;
+ * ....
+ * END;
+ * ' LANGUAGE 'plpgsql';
+ *
+ * @param sqlStatement
+ * @return CREATE and DROP Function statement
+ */
+ private ArrayList convertFunction (String sqlStatement)
+ {
+ ArrayList result = new ArrayList();
+ // Convert statement - to avoid handling contents of comments
+ String stmt = converSimpleStatement(sqlStatement);
+ // Double quotes '
+ stmt = Pattern.compile("'").matcher(stmt).replaceAll("''");
+ // remove OR REPLACE
+ int orReplacePos = stmt.toUpperCase().indexOf(" OR REPLACE ");
+ if (orReplacePos != -1)
+ stmt = "CREATE" + stmt.substring(orReplacePos+11);
+
+ // Line separators
+ String match =
+ "(\\([^\\)]*\\))" // (.) Parameter
+ + "|(\\bRETURN \\w+ (AS)|(IS))" // RETURN CLAUSE
+ + "|(;)" // Statement End
+ // Nice to have - for readability
+ + "|(\\bBEGIN\\b)" // BEGIN
+ + "|(\\bTHEN\\b)"
+ + "|(\\bELSE\\b)"
+ + "|(\\bELSIF\\b)";
+ Matcher m = Pattern.compile(match, Pattern.CASE_INSENSITIVE).matcher(stmt);
+
+ StringBuffer sb = new StringBuffer();
+ // First group -> ( )
+ // CREATE OR REPLACE FUNCTION AD_Message_Get ( p_AD_Message IN VARCHAR, p_AD_Language IN VARCHAR)
+ // CREATE FUNCTION AD_Message_Get (VARCHAR, VARCHAR)
+ m.find();
+ m.appendReplacement(sb, "");
+ String name = sb.substring(6).trim();
+ StringBuffer signature = new StringBuffer();
+ //
+ String group = m.group().trim();
+ // log.info("Group: " + group);
+ StringBuffer alias = new StringBuffer();
+ // Parameters
+ if (group.startsWith("(") && group.endsWith(")"))
+ {
+ // Default not supported
+ if (group.toUpperCase().indexOf(" DEFAULT ") != -1)
+ {
+ String error = "DEFAULT in Parameter not supported";
+ log.info (error);
+ m_conversionError = error;
+ return result;
+ }
+ signature.append("(");
+ if (group.length() > 2)
+ {
+ group = group.substring(1,group.length()-1);
+ // Paraneters are delimited by ,
+ String[] parameters = group.split(",");
+ for (int i = 0; i < parameters.length; i++)
+ {
+ if (i != 0)
+ signature.append(", ");
+ // name ALIAS FOR $1
+ String p = parameters[i].trim();
+ alias.append(p.substring(0,p.indexOf(" ")))
+ .append(" ALIAS FOR $").append(i+1).append(";\n");
+ // Datatape
+ signature.append(p.substring(p.lastIndexOf(" ")+1));
+ }
+ }
+ signature.append(")");
+ sb.append(signature);
+ // log.info("Alias: " + alias.toString());
+ // log.info("Signature: " + signature.toString());
+ }
+ // No Parameters
+ else
+ {
+ String error = "Missing Parameter ()";
+ log.info (error);
+ m_conversionError = error;
+ return result;
+ }
+ sb.append("\n");
+ // Need to create drop statement
+ if (orReplacePos != -1)
+ {
+ String drop = "DROP " + name + signature.toString();
+ // log.info(drop);
+ result.add(drop);
+ }
+ // log.info("1>" + sb.toString() + "<1");
+
+ // Second Group -> RETURN VARCHAR AS
+ // RETURNS VARCHAR AS
+ m.find();
+ group = m.group();
+ m.appendReplacement(sb, "");
+ if (group.startsWith("RETURN"))
+ sb.append("RETURNS").append(group.substring(group.indexOf(" ")));
+ sb.append(" '\nDECLARE\n")
+ .append(alias); // add aliases here
+ // log.info("2>" + sb.toString() + "<2");
+
+ // remainder statements
+ while (m.find())
+ {
+ String group2 = m.group();
+ if (group2.indexOf('$') != -1) // Group character needs to be escaped
+ group2 = Util.replace(group2, "$", "\\$");
+ m.appendReplacement(sb, group2);
+ sb.append("\n");
+ }
+ m.appendTail(sb);
+
+ // finish
+ sb.append("' LANGUAGE 'plpgsql';");
+ // log.info(">" + sb.toString() + "<");
+ result.add(sb.toString());
+ //
+ return result;
+ } // convertFunction
+
+ /**
+ * Convert Procedure.
+ *
+ * CREATE OR REPLACE PROCEDURE AD_Message_X
+ * (p_AD_Message IN VARCHAR, p_AD_Language IN VARCHAR)
+ * ...
+ * END AD_Message_X;
+ * =>
+ * CREATE FUNCTION AD_Message_X
+ * (VARCHAR, VARCHAR)
+ * RETURNS VARCHAR AS '
+ * DECLARE
+ * p_AD_Message ALIAS FOR $1;
+ * p_AD_Language ALIAS FOR $2;
+ * ....
+ * END;
+ * ' LANGUAGE 'plpgsql';
+ *
+ * @param sqlStatement
+ * @return CREATE and DROP Function statement
+ */
+ private ArrayList convertProcedure (String sqlStatement)
+ {
+ ArrayList result = new ArrayList();
+ // Convert statement - to avoid handling contents of comments
+ String stmt = converSimpleStatement(sqlStatement);
+ // Double quotes '
+ stmt = Pattern.compile("'").matcher(stmt).replaceAll("''");
+ // remove OR REPLACE
+ int orReplacePos = stmt.toUpperCase().indexOf(" OR REPLACE ");
+ if (orReplacePos != -1)
+ stmt = "CREATE" + stmt.substring(orReplacePos+11);
+
+ // Line separators
+ String match =
+ "(\\([^\\)]*\\))" // (.) Parameter
+ + "|(\\bRETURN \\w+ (AS)|(IS))" // RETURN CLAUSE
+ + "|(;)" // Statement End
+ // Nice to have - for readability
+ + "|(\\bBEGIN\\b)" // BEGIN
+ + "|(\\bTHEN\\b)"
+ + "|(\\bELSE\\b)"
+ + "|(\\bELSIF\\b)";
+ Matcher m = Pattern.compile(match, Pattern.CASE_INSENSITIVE).matcher(stmt);
+
+ StringBuffer sb = new StringBuffer();
+ // First group -> ( )
+ // CREATE OR REPLACE FUNCTION AD_Message_Get ( p_AD_Message IN VARCHAR, p_AD_Language IN VARCHAR)
+ // CREATE FUNCTION AD_Message_Get (VARCHAR, VARCHAR)
+ m.find();
+ m.appendReplacement(sb, "");
+ String name = sb.substring(6).trim();
+ StringBuffer signature = new StringBuffer();
+ //
+ String group = m.group().trim();
+ // log.info("Group: " + group);
+ StringBuffer alias = new StringBuffer();
+ // Parameters
+ if (group.startsWith("(") && group.endsWith(")"))
+ {
+ // Default not supported
+ if (group.toUpperCase().indexOf(" DEFAULT ") != -1)
+ {
+ String error = "DEFAULT in Parameter not supported";
+ log.info (error);
+ m_conversionError = error;
+ return result;
+ }
+ signature.append("(");
+ if (group.length() > 2)
+ {
+ group = group.substring(1,group.length()-1);
+ // Paraneters are delimited by ,
+ String[] parameters = group.split(",");
+ for (int i = 0; i < parameters.length; i++)
+ {
+ if (i != 0)
+ signature.append(", ");
+ // name ALIAS FOR $1
+ String p = parameters[i].trim();
+ alias.append(p.substring(0,p.indexOf(" ")))
+ .append(" ALIAS FOR $").append(i+1).append(";\n");
+ // Datatape
+ signature.append(p.substring(p.lastIndexOf(" ")+1));
+ }
+ }
+ signature.append(")");
+ sb.append(signature);
+ // log.info("Alias: " + alias.toString());
+ // log.info("Signature: " + signature.toString());
+ }
+ // No Parameters
+ else
+ {
+ String error = "Missing Parameter ()";
+ log.info (error);
+ m_conversionError = error;
+ return result;
+ }
+ sb.append("\n");
+ // Need to create drop statement
+ if (orReplacePos != -1)
+ {
+ String drop = "DROP " + name + signature.toString();
+ // log.info(drop);
+ result.add(drop);
+ }
+ // log.info("1>" + sb.toString() + "<1");
+
+ // Second Group -> RETURN VARCHAR AS
+ // RETURNS VARCHAR AS
+ m.find();
+ group = m.group();
+ m.appendReplacement(sb, "");
+ if (group.startsWith("RETURN"))
+ sb.append("RETURNS").append(group.substring(group.indexOf(" ")));
+ sb.append(" '\nDECLARE\n")
+ .append(alias); // add aliases here
+ // log.info("2>" + sb.toString() + "<2");
+
+ // remainder statements
+ while (m.find())
+ {
+ String group2 = m.group();
+ if (group2.indexOf('$') != -1) // Group character needs to be escaped
+ group2 = Util.replace(group2, "$", "\\$");
+ m.appendReplacement(sb, group2);
+ sb.append("\n");
+ }
+ m.appendTail(sb);
+
+ // finish
+ sb.append("' LANGUAGE 'plpgsql';");
+ // log.info(">" + sb.toString() + "<");
+ result.add(sb.toString());
+ //
+ return result;
+ } // convertProcedure
+
+ /**
+ * Convert Trigger.
+ *
+ * DROP FUNCTION emp_trgF();
+ * CREATE FUNCTION emp_trg () RETURNS OPAQUE AS '....
+ * RETURN NEW; ...
+ * ' LANGUAGE 'plpgsql';
+ * DROP TRIGGER emp_trg ON emp;
+ * CREATE TRIGGER emp_trg BEFORE INSERT OR UPDATE ON emp
+ * FOR EACH ROW EXECUTE PROCEDURE emp_trgF();
+ *
+ * @param sqlStatement
+ * @return CREATE and DROP TRIGGER and associated Function statement
+ */
+ private ArrayList convertTrigger (String sqlStatement)
+ {
+ ArrayList result = new ArrayList();
+ // Convert statement - to avoid handling contents of comments
+ String stmt = converSimpleStatement(sqlStatement);
+
+ // Trigger specific replacements
+ stmt = Pattern.compile("\\bINSERTING\\b").matcher(stmt).replaceAll("TG_OP='INSERT'");
+ stmt = Pattern.compile("\\bUPDATING\\b").matcher(stmt).replaceAll("TG_OP='UPDATE'");
+ stmt = Pattern.compile("\\bDELETING\\b").matcher(stmt).replaceAll("TG_OP='DELETE'");
+ stmt = Pattern.compile(":new.").matcher(stmt).replaceAll("NEW.");
+ stmt = Pattern.compile(":old.").matcher(stmt).replaceAll("OLD.");
+
+ // Double quotes '
+ stmt = Pattern.compile("'").matcher(stmt).replaceAll("''");
+ // remove OR REPLACE
+ int orReplacePos = stmt.toUpperCase().indexOf(" OR REPLACE ");
+ // trigger Name
+ int triggerPos = stmt.toUpperCase().indexOf(" TRIGGER ") + 9;
+ String triggerName = stmt.substring(triggerPos);
+ triggerName = triggerName.substring(0, triggerName.indexOf(" "));
+ // table name
+ String tableName = stmt.substring(stmt.toUpperCase().indexOf(" ON ")+4);
+ tableName = tableName.substring(0, tableName.indexOf(" "));
+
+ // Function Drop
+ if (orReplacePos != -1)
+ {
+ String drop = "DROP FUNCTION " + triggerName + "F()";
+ // log.info(drop);
+ result.add(drop);
+ }
+
+ // Function & Trigger
+ int pos = stmt.indexOf("DECLARE ");
+ if (pos == -1)
+ pos = stmt.indexOf("BEGIN ");
+ String functionCode = stmt.substring(pos);
+ StringBuffer triggerCode = new StringBuffer ("CREATE TRIGGER ");
+ triggerCode.append(triggerName).append("\n")
+ .append(stmt.substring(triggerPos+triggerName.length(), pos))
+ .append("\nEXECUTE PROCEDURE ").append(triggerName).append("F();");
+
+ // Add NEW to existing Return --> DELETE Trigger ?
+ functionCode = Pattern.compile("\\bRETURN;", Pattern.CASE_INSENSITIVE)
+ .matcher(functionCode)
+ .replaceAll("RETURN NEW;");
+ // Add final return and change name
+ functionCode = Pattern.compile("\\bEND " + triggerName + ";", Pattern.CASE_INSENSITIVE)
+ .matcher(functionCode)
+ .replaceAll("\nRETURN NEW;\nEND " + triggerName + "F;");
+
+ // Line separators
+ String match =
+ "(\\(.*\\))" // (.) Parameter
+ + "|(;)" // Statement End
+ // Nice to have - for readability
+ + "|(\\bBEGIN\\b)" // BEGIN
+ + "|(\\bTHEN\\b)"
+ + "|(\\bELSE\\b)"
+ + "|(\\bELSIF\\b)";
+ Matcher m = Pattern.compile(match, Pattern.CASE_INSENSITIVE).matcher(functionCode);
+
+ // Function Header
+ StringBuffer sb = new StringBuffer("CREATE FUNCTION ");
+ sb.append(triggerName).append("F() RETURNS OPAQUE AS '\n");
+
+ // remainder statements
+ while (m.find())
+ {
+ String group = m.group();
+ if (group.indexOf('$') != -1) // Group character needs to be escaped
+ group = Util.replace(group, "$", "\\$");
+ m.appendReplacement(sb, group);
+ sb.append("\n");
+ }
+ m.appendTail(sb);
+
+ // finish Function
+ sb.append("' LANGUAGE 'plpgsql';");
+ // log.info(">" + sb.toString() + "<");
+ result.add(sb.toString());
+
+ // Trigger Drop
+ if (orReplacePos != -1)
+ {
+ String drop = "DROP TRIGGER " + triggerName.toLowerCase() + " ON " + tableName;
+ // log.info(drop);
+ result.add(drop);
+ }
+
+ // Trigger
+ // Remove Column references OF ... ON
+ String trigger = Pattern.compile("\\sOF.*ON\\s")
+ .matcher(triggerCode)
+ .replaceAll(" ON ");
+ // log.info(trigger);
+ result.add(trigger);
+
+ //
+ return result;
+ } // convertTrigger
+
+ /**
+ * Convert View.
+ * Handle CREATE OR REPLACE
+ * @param sqlStatement
+ * @return converted statement(s)
+ */
+ private ArrayList convertView (String sqlStatement)
+ {
+ ArrayList result = new ArrayList();
+ String stmt = converSimpleStatement(sqlStatement);
+
+ // remove OR REPLACE
+ int orReplacePos = stmt.toUpperCase().indexOf(" OR REPLACE ");
+ if (orReplacePos != -1)
+ {
+ int index = stmt.indexOf(" VIEW ");
+ int space = stmt.indexOf(' ', index+6);
+ String drop = "DROP VIEW " + stmt.substring(index+6, space);
+ result.add(drop);
+ //
+ String create = "CREATE" + stmt.substring(index);
+ result.add(create);
+ }
+ else // simple statement
+ result.add(stmt);
+ return result;
+ } // convertView
+
+
+ /**************************************************************************
+ * Converts Decode, Outer Join and Sequence.
+ *
+ * DECODE (a, 1, 'one', 2, 'two', 'none')
+ * => CASE WHEN a = 1 THEN 'one' WHEN a = 2 THEN 'two' ELSE 'none' END
+ *
+ * AD_Error_Seq.nextval
+ * => nextval('AD_Error_Seq')
+ *
+ * RAISE_APPLICATION_ERROR (-20100, 'Table Sequence not found')
+ * => RAISE EXCEPTION 'Table Sequence not found'
+ *
+ *
+ * DECODE (a, 1, 'one', 2, 'two', 'none')
+ * => CASE WHEN a = 1 THEN 'one' WHEN a = 2 THEN 'two' ELSE 'none' END
+ *
+ * @param sqlStatement
+ * @return converted statement
+ */
+ private String convertDecode(String sqlStatement)
+ {
+ // log.info("DECODE<== " + sqlStatement);
+ String statement = sqlStatement;
+ StringBuffer sb = new StringBuffer("CASE");
+
+ int index = statement.indexOf("DECODE");
+ String firstPart = statement.substring(0,index);
+
+ // find the opening (
+ index = statement.indexOf('(', index);
+ statement = statement.substring(index+1);
+
+ // find the expression "a" - find first , ignoring ()
+ index = Util.findIndexOf (statement, ',');
+ String expression = statement.substring(0, index).trim();
+ // log.info("Expression=" + expression);
+
+ // Pairs "1, 'one',"
+ statement = statement.substring(index+1);
+ index = Util.findIndexOf (statement, ',');
+ while (index != -1)
+ {
+ String first = statement.substring(0, index);
+ char cc = statement.charAt(index);
+ statement = statement.substring(index+1);
+ // log.info("First=" + first + ", Char=" + cc);
+ //
+ boolean error = false;
+ if (cc == ',')
+ {
+ index = Util.findIndexOf (statement, ',',')');
+ if (index == -1)
+ error = true;
+ else
+ {
+ String second = statement.substring(0, index);
+ sb.append(" WHEN ").append(expression).append("=").append(first.trim())
+ .append(" THEN ").append(second.trim());
+ // log.info(">>" + sb.toString());
+ statement = statement.substring(index+1);
+ index = Util.findIndexOf (statement, ',',')');
+ }
+ }
+ else if (cc == ')')
+ {
+ sb.append(" ELSE ").append(first.trim()).append(" END");
+ // log.info(">>" + sb.toString());
+ index = -1;
+ }
+ else
+ error = true;
+ if (error)
+ {
+ log.log(Level.SEVERE, "SQL=(" + sqlStatement
+ + ")\n====Result=(" + sb.toString()
+ + ")\n====Statement=(" + statement
+ + ")\n====First=(" + first
+ + ")\n====Index=" + index);
+ m_conversionError = "Decode conversion error";
+ }
+ }
+ sb.append(statement);
+ sb.insert(0, firstPart);
+ // log.info("DECODE==> " + sb.toString());
+ return sb.toString();
+ } // convertDecode
+
+
+ /**************************************************************************
+ * Convert Outer Join.
+ * Converting joins can ve very complex when multiple tables/keys are involved.
+ * The main scenarios supported are two tables with multiple key columns
+ * and multiple tables with single key columns.
+ *
+ * SELECT a.Col1, b.Col2 FROM tableA a, tableB b WHERE a.ID=b.ID(+)
+ * => SELECT a.Col1, b.Col2 FROM tableA a LEFT OUTER JOIN tableB b ON (a.ID=b.ID)
+ *
+ * SELECT a.Col1, b.Col2 FROM tableA a, tableB b WHERE a.ID(+)=b.ID
+ * => SELECT a.Col1, b.Col2 FROM tableA a RIGHT OUTER JOIN tableB b ON (a.ID=b.ID)
+ * Assumptions:
+ * - No outer joins in sub queries (ignores sub-queries)
+ * - OR condition ignored (not sure what to do, should not happen)
+ * Limitations:
+ * - Parameters for outer joins must be first - as sequence of parameters changes
+ *
+ * @param sqlStatement
+ * @return converted statement
+ */
+ private String convertOuterJoin (String sqlStatement)
+ {
+ boolean trace = false;
+ //
+ int fromIndex = Util.findIndexOf (sqlStatement.toUpperCase(), " FROM ");
+ int whereIndex = Util.findIndexOf(sqlStatement.toUpperCase(), " WHERE ");
+ //begin vpj-cd e-evolution 03/14/2005 PostgreSQL
+ //int endWhereIndex = Util.findIndexOf(sqlStatement.toUpperCase(), " GRPUP BY ");
+ int endWhereIndex = Util.findIndexOf(sqlStatement.toUpperCase(), " GROUP BY ");
+ //end vpj-cd e-evolution 03/14/2005 PostgreSQL
+ if (endWhereIndex == -1)
+ endWhereIndex = Util.findIndexOf(sqlStatement.toUpperCase(), " ORDER BY ");
+ if (endWhereIndex == -1)
+ endWhereIndex = sqlStatement.length();
+ //
+ if (trace)
+ {
+ log.info("OuterJoin<== " + sqlStatement);
+ // log.info("From=" + fromIndex + ", Where=" + whereIndex + ", End=" + endWhereIndex + ", Length=" + sqlStatement.length());
+ }
+ //
+ String selectPart = sqlStatement.substring(0, fromIndex);
+ String fromPart = sqlStatement.substring(fromIndex, whereIndex);
+ String wherePart = sqlStatement.substring(whereIndex, endWhereIndex);
+ String rest = sqlStatement.substring(endWhereIndex);
+
+ // find/remove all (+) from WHERE clase ------------------------------
+ String newWherePart = wherePart;
+ ArrayList joins = new ArrayList();
+ int pos = newWherePart.indexOf("(+)");
+ while (pos != -1)
+ {
+ // find starting point
+ int start = newWherePart.lastIndexOf(" AND ", pos);
+ int startOffset = 5;
+ if (start == -1)
+ {
+ start = newWherePart.lastIndexOf(" OR ", pos);
+ startOffset = 4;
+ }
+ if (start == -1)
+ {
+ start = newWherePart.lastIndexOf("WHERE ", pos);
+ startOffset = 6;
+ }
+ if (start == -1)
+ {
+ String error = "Start point not found in clause " + wherePart;
+ log.severe(error);
+ m_conversionError = error;
+ return sqlStatement;
+ }
+ // find end point
+ int end = newWherePart.indexOf(" AND ", pos);
+ if (end == -1)
+ end = newWherePart.indexOf(" OR ", pos);
+ if (end == -1)
+ end = newWherePart.length();
+ // log.info("<= " + newWherePart + " - Start=" + start + "+" + startOffset + ", End=" + end);
+
+ // extract condition
+ String condition = newWherePart.substring(start+startOffset, end);
+ joins.add(condition);
+ if (trace)
+ log.info("->" + condition);
+ // new WHERE clause
+ newWherePart = newWherePart.substring(0, start) + newWherePart.substring(end);
+ // log.info("=> " + newWherePart);
+ //
+ pos = newWherePart.indexOf("(+)");
+ }
+ // correct beginning
+ newWherePart = newWherePart.trim();
+ if (newWherePart.startsWith("AND "))
+ newWherePart = "WHERE" + newWherePart.substring(3);
+ else if (newWherePart.startsWith("OR "))
+ newWherePart = "WHERE" + newWherePart.substring(2);
+ if (trace)
+ log.info("=> " + newWherePart);
+
+ // Correct FROM clause -----------------------------------------------
+ // Disassemble FROM
+ String[] fromParts = fromPart.trim().substring(4).split(",");
+ HashMap fromAlias = new HashMap(); // tables to be processed
+ HashMap fromLookup = new HashMap(); // used tabled
+ for (int i = 0; i < fromParts.length; i++)
+ {
+ String entry = fromParts[i].trim();
+ String alias = entry; // no alias
+ String table = entry;
+ int aPos = entry.lastIndexOf(' ');
+ if (aPos != -1)
+ {
+ alias = entry.substring(aPos+1);
+ table = entry.substring(0, entry.indexOf(' ')); // may have AS
+ }
+ fromAlias.put(alias, table);
+ fromLookup.put(alias, table);
+ if (trace)
+ log.info("Alias=" + alias + ", Table=" + table);
+ }
+
+ /** Single column
+ SELECT t.TableName, w.Name FROM AD_Table t, AD_Window w
+ WHERE t.AD_Window_ID=w.AD_Window_ID(+)
+ -- 275 rows
+ SELECT t.TableName, w.Name FROM AD_Table t
+ LEFT OUTER JOIN AD_Window w ON (t.AD_Window_ID=w.AD_Window_ID)
+
+ SELECT t.TableName, w.Name FROM AD_Table t, AD_Window w
+ WHERE t.AD_Window_ID(+)=w.AD_Window_ID
+ -- 239 rows
+ SELECT t.TableName, w.Name FROM AD_Table t
+ RIGHT OUTER JOIN AD_Window w ON (t.AD_Window_ID=w.AD_Window_ID)
+
+ ** Multiple columns
+ SELECT tn.Node_ID,tn.Parent_ID,tn.SeqNo,tb.IsActive
+ FROM AD_TreeNode tn, AD_TreeBar tb
+ WHERE tn.AD_Tree_ID=tb.AD_Tree_ID(+) AND tn.Node_ID=tb.Node_ID(+)
+ AND tn.AD_Tree_ID=10
+ -- 235 rows
+ SELECT tn.Node_ID,tn.Parent_ID,tn.SeqNo,tb.IsActive
+ FROM AD_TreeNode tn LEFT OUTER JOIN AD_TreeBar tb
+ ON (tn.Node_ID=tb.Node_ID AND tn.AD_Tree_ID=tb.AD_Tree_ID AND tb.AD_User_ID=0)
+ WHERE tn.AD_Tree_ID=10
+
+ SELECT tn.Node_ID,tn.Parent_ID,tn.SeqNo,tb.IsActive
+ FROM AD_TreeNode tn, AD_TreeBar tb
+ WHERE tn.AD_Tree_ID=tb.AD_Tree_ID(+) AND tn.Node_ID=tb.Node_ID(+)
+ AND tn.AD_Tree_ID=10 AND tb.AD_User_ID(+)=0
+ -- 214 rows
+ SELECT tn.Node_ID,tn.Parent_ID,tn.SeqNo,tb.IsActive
+ FROM AD_TreeNode tn LEFT OUTER JOIN AD_TreeBar tb
+ ON (tn.Node_ID=tb.Node_ID AND tn.AD_Tree_ID=tb.AD_Tree_ID AND tb.AD_User_ID=0)
+ WHERE tn.AD_Tree_ID=10
+
+ */
+ StringBuffer newFrom = new StringBuffer ();
+ for (int i = 0; i < joins.size(); i++)
+ {
+ Join first = new Join ((String)joins.get(i));
+ first.setMainTable((String)fromLookup.get(first.getMainAlias()));
+ fromAlias.remove(first.getMainAlias()); // remove from list
+ first.setJoinTable((String)fromLookup.get(first.getJoinAlias()));
+ fromAlias.remove(first.getJoinAlias()); // remove from list
+ if (trace)
+ log.info("-First: " + first);
+ //
+ if (newFrom.length() == 0)
+ newFrom.append(" FROM ");
+ else
+ newFrom.append(", ");
+ newFrom.append(first.getMainTable()).append(" ").append(first.getMainAlias())
+ .append(first.isLeft() ? " LEFT" : " RIGHT").append(" OUTER JOIN ")
+ .append(first.getJoinTable()).append(" ").append(first.getJoinAlias())
+ .append(" ON (").append(first.getCondition());
+ // keep it open - check for other key comparisons
+ for (int j = i+1; j < joins.size(); j++)
+ {
+ Join second = new Join ((String)joins.get(j));
+ second.setMainTable((String)fromLookup.get(second.getMainAlias()));
+ second.setJoinTable((String)fromLookup.get(second.getJoinAlias()));
+ if ((first.getMainTable().equals(second.getMainTable())
+ && first.getJoinTable().equals(second.getJoinTable()))
+ || second.isConditionOf(first) )
+ {
+ if (trace)
+ log.info("-Second/key: " + second);
+ newFrom.append(" AND ").append(second.getCondition());
+ joins.remove(j); // remove from join list
+ fromAlias.remove(first.getJoinAlias()); // remove from table list
+ //----
+ for (int k = i+1; k < joins.size(); k++)
+ {
+ Join third = new Join ((String)joins.get(k));
+ third.setMainTable((String)fromLookup.get(third.getMainAlias()));
+ third.setJoinTable((String)fromLookup.get(third.getJoinAlias()));
+ if (third.isConditionOf(second))
+ {
+ if (trace)
+ log.info("-Third/key: " + third);
+ newFrom.append(" AND ").append(third.getCondition());
+ joins.remove(k); // remove from join list
+ fromAlias.remove(third.getJoinAlias()); // remove from table list
+ }
+ else if (trace)
+ log.info("-Third/key-skip: " + third);
+ }
+ }
+ else if (trace)
+ log.info("-Second/key-skip: " + second);
+ }
+ newFrom.append(")"); // close ON
+ // check dependency on first table
+ for (int j = i+1; j < joins.size(); j++)
+ {
+ Join second = new Join ((String)joins.get(j));
+ second.setMainTable((String)fromLookup.get(second.getMainAlias()));
+ second.setJoinTable((String)fromLookup.get(second.getJoinAlias()));
+ if (first.getMainTable().equals(second.getMainTable()))
+ {
+ if (trace)
+ log.info("-Second/dep: " + second);
+ // FROM (AD_Field f LEFT OUTER JOIN AD_Column c ON (f.AD_Column_ID = c.AD_Column_ID))
+ // LEFT OUTER JOIN AD_FieldGroup fg ON (f.AD_FieldGroup_ID = fg.AD_FieldGroup_ID),
+ newFrom.insert(6, '('); // _FROM ...
+ newFrom.append(')'); // add parantesis on previous relation
+ //
+ newFrom.append(second.isLeft() ? " LEFT" : " RIGHT").append(" OUTER JOIN ")
+ .append(second.getJoinTable()).append(" ").append(second.getJoinAlias())
+ .append(" ON (").append(second.getCondition());
+ joins.remove(j); // remove from join list
+ fromAlias.remove(second.getJoinAlias()); // remove from table list
+ // additional join colums would come here
+ newFrom.append(")"); // close ON
+ //----
+ for (int k = i+1; k < joins.size(); k++)
+ {
+ Join third = new Join ((String)joins.get(k));
+ third.setMainTable((String)fromLookup.get(third.getMainAlias()));
+ third.setJoinTable((String)fromLookup.get(third.getJoinAlias()));
+ if (second.getJoinTable().equals(third.getMainTable()))
+ {
+ if (trace)
+ log.info("-Third-dep: " + third);
+ // FROM ((C_BPartner p LEFT OUTER JOIN AD_User c ON (p.C_BPartner_ID=c.C_BPartner_ID))
+ // LEFT OUTER JOIN C_BPartner_Location l ON (p.C_BPartner_ID=l.C_BPartner_ID))
+ // LEFT OUTER JOIN C_Location a ON (l.C_Location_ID=a.C_Location_ID)
+ newFrom.insert(6, '('); // _FROM ...
+ newFrom.append(')'); // add parantesis on previous relation
+ //
+ newFrom.append(third.isLeft() ? " LEFT" : " RIGHT").append(" OUTER JOIN ")
+ .append(third.getJoinTable()).append(" ").append(third.getJoinAlias())
+ .append(" ON (").append(third.getCondition());
+ joins.remove(k); // remove from join list
+ fromAlias.remove(third.getJoinAlias()); // remove from table list
+ // additional join colums would come here
+ newFrom.append(")"); // close ON
+ }
+ else if (trace)
+ log.info("-Third-skip: " + third);
+ }
+ }
+ else if (trace)
+ log.info("-Second/dep-skip: " + second);
+ } // dependency on first table
+ }
+ // remaining Tables
+ Iterator it = fromAlias.keySet().iterator();
+ while (it.hasNext())
+ {
+ Object alias = it.next();
+ Object table = fromAlias.get(alias);
+ newFrom.append(", ").append(table);
+ if (!table.equals(alias))
+ newFrom.append(" ").append(alias);
+ }
+ if (trace)
+ log.info(newFrom.toString());
+ //
+ StringBuffer retValue = new StringBuffer (sqlStatement.length()+20);
+ retValue.append(selectPart)
+ .append(newFrom).append(" ")
+ .append(newWherePart).append(rest);
+ //
+ if (trace)
+ log.info("OuterJoin==> " + retValue.toString());
+ return retValue.toString();
+ } // convertOuterJoin
+
+ /**
+ * Convert RowNum.
+ *
+ * SELECT Col1 FROM tableA WHERE ROWNUM=1
+ * => SELECT Col1 FROM tableA LIMIT 1
+ * Assumptions/Limitations:
+ * - RowNum not used in SELECT part
+ *