From ef9569374da150afbd9a08dfc6c9f4a86c5bbe6e Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Sun, 14 Jan 2007 18:37:35 +0000 Subject: [PATCH] * remove db2, sqlserver and sybase files and reference --- dbPort/.classpath | 1 - dbPort/build.xml | 3 - dbPort/src/org/compiere/db/CConnection.java | 35 +- dbPort/src/org/compiere/db/DB_DB2.java | 841 ------------------ dbPort/src/org/compiere/db/Database.java | 12 +- .../org/compiere/dbPort/ConvertDialog.java | 8 +- .../org/compiere/dbPort/ConvertMap_DB2.java | 106 --- dbPort/src/org/compiere/model/MSequence.java | 8 +- dbPort/src/org/compiere/model/MSystem.java | 6 +- dbPort/src/org/compiere/util/DB.java | 8 +- 10 files changed, 18 insertions(+), 1010 deletions(-) delete mode 100644 dbPort/src/org/compiere/db/DB_DB2.java delete mode 100644 dbPort/src/org/compiere/dbPort/ConvertMap_DB2.java diff --git a/dbPort/.classpath b/dbPort/.classpath index ecb51bca4a..77cabcabe2 100644 --- a/dbPort/.classpath +++ b/dbPort/.classpath @@ -11,7 +11,6 @@ - diff --git a/dbPort/build.xml b/dbPort/build.xml index b4c31e440f..0a9dd63396 100644 --- a/dbPort/build.xml +++ b/dbPort/build.xml @@ -24,9 +24,6 @@ - - - diff --git a/dbPort/src/org/compiere/db/CConnection.java b/dbPort/src/org/compiere/db/CConnection.java index cc03c60949..3d3e0d1bdb 100644 --- a/dbPort/src/org/compiere/db/CConnection.java +++ b/dbPort/src/org/compiere/db/CConnection.java @@ -813,18 +813,13 @@ public class CConnection implements Serializable setViaFirewall (false); } - // DB2 - if (isDB2()) + /* + if (isDerby()) { - 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 + if (getDbPort () != DB_Derby.DEFAULT_PORT) + setDbPort (DB_Derby.DEFAULT_PORT); + }*/ + // begin vpj-cd e-evolution 09 ene 2006 // PostgreSQL if (isPostgreSQL ()) { @@ -858,32 +853,16 @@ public class CConnection implements Serializable 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 /** diff --git a/dbPort/src/org/compiere/db/DB_DB2.java b/dbPort/src/org/compiere/db/DB_DB2.java deleted file mode 100644 index 9c5a1fc4f5..0000000000 --- a/dbPort/src/org/compiere/db/DB_DB2.java +++ /dev/null @@ -1,841 +0,0 @@ -/****************************************************************************** - * 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.dbPort.Convert; -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 - - public Convert getConvert() { - throw new UnsupportedOperationException("Not implemented."); - } - -} // DB_DB2 diff --git a/dbPort/src/org/compiere/db/Database.java b/dbPort/src/org/compiere/db/Database.java index 5cf15eb7ca..4ad961f231 100644 --- a/dbPort/src/org/compiere/db/Database.java +++ b/dbPort/src/org/compiere/db/Database.java @@ -31,13 +31,9 @@ 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 */ + /** PostgreSQL ID */ public static String DB_POSTGRESQL = "PostgreSQL"; /** Enterprise DB */ //public static String DB_EDB = "EnterpriseDB"; @@ -48,9 +44,7 @@ public class Database /** Supported Databases */ public static String[] DB_NAMES = new String[] { DB_ORACLE - ,DB_DB2 // ,DB_DERBY - // ,DB_MSSQLServer ,DB_POSTGRESQL ,DB_FYRACLE // ,DB_EDB @@ -59,9 +53,7 @@ public class Database /** Database Classes */ protected static Class[] DB_CLASSES = new Class[] { DB_Oracle.class - ,DB_DB2.class // ,DB_Derby.class - // ,DB_MSSQLServer.class ,DB_PostgreSQL.class ,DB_Fyracle.class // ,DB_EDB.class @@ -107,8 +99,6 @@ public class Database return new DB_Oracle(); // if (URL.indexOf("derby") != -1) // return new DB_Derby(); - if (url.indexOf("db2") != -1) - return new DB_DB2(); if (url.indexOf("postgresql") != -1) return new DB_PostgreSQL(); if (url.indexOf("firebirdsql") != -1) diff --git a/dbPort/src/org/compiere/dbPort/ConvertDialog.java b/dbPort/src/org/compiere/dbPort/ConvertDialog.java index 960f50ead4..329eace2b4 100644 --- a/dbPort/src/org/compiere/dbPort/ConvertDialog.java +++ b/dbPort/src/org/compiere/dbPort/ConvertDialog.java @@ -49,7 +49,7 @@ import javax.swing.JTextArea; import org.compiere.Adempiere; import org.compiere.db.CConnection; import org.compiere.db.CConnectionEditor; -import org.compiere.db.DB_DB2; +import org.compiere.db.DB_PostgreSQL; import org.compiere.db.Database; import org.compiere.swing.CFrame; @@ -75,9 +75,9 @@ public class ConvertDialog extends CFrame implements ActionListener fSelectFile.addItem("D:\\adempiere\\db\\database\\create\\sequences.sql"); fSelectFile.addItem("D:\\adempiere\\db\\database\\create\\adempiere.sql"); // Set up environment - fConnect.setValue(CConnection.get(Database.DB_DB2, - "linux", DB_DB2.DEFAULT_PORT, "adempiere")); - fTarget.setSelectedItem(Database.DB_DB2); + fConnect.setValue(CConnection.get(Database.DB_POSTGRESQL, + "linux", DB_PostgreSQL.DEFAULT_PORT, "adempiere")); + fTarget.setSelectedItem(Database.DB_POSTGRESQL); fExecute.setSelected(true); cmd_execute(); // set UI diff --git a/dbPort/src/org/compiere/dbPort/ConvertMap_DB2.java b/dbPort/src/org/compiere/dbPort/ConvertMap_DB2.java deleted file mode 100644 index 0b266c8c89..0000000000 --- a/dbPort/src/org/compiere/dbPort/ConvertMap_DB2.java +++ /dev/null @@ -1,106 +0,0 @@ -/****************************************************************************** - * 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.util.*; - -/** - * Database Syntax Conversion Map. - * - * - * @author Jorg Janke & Victor Perez - * @version $Id: ConvertMap.java,v 1.6 2006/09/22 23:35:19 jjanke Exp $ - */ -public class ConvertMap_DB2 -{ - - /** - * Return Map for DB/2 - * @return TreeMap with pattern as key and the replacement as value - */ - public static TreeMap getConvertMap() - { - if (s_db2.size() == 0) - initConvertMap(); - return s_db2; - } // getDB2Map -// begin e-evolution PostgreSQL - -// end e-evolution PostgreSQL - - - /** Tree Map for PostgreSQL */ - private static TreeMap s_db2 = new TreeMap(); - // begin e-evolution PostgreSQL - /** Tree Map for PostgreSQL */ - - // end e-evolution PostgreSQL - - - /** - * DB/2 Init - */ - static private void initConvertMap() - { - // Oracle Pattern Replacement - - // Data Types - s_db2.put("\\bNUMBER\\b", "NUMERIC"); - s_db2.put("\\bDATE\\b", "TIMESTAMP"); - s_db2.put("\\bVARCHAR2\\b", "VARCHAR"); - s_db2.put("\\bNVARCHAR2\\b", "VARCHAR"); - s_db2.put("\\bNCHAR\\b", "CHAR"); - s_db2.put("\\bBLOB\\b", "OID"); // BLOB not directly supported - s_db2.put("\\bCLOB\\b", "TEXT"); // CLOB not directly supported - - // Storage - s_db2.put("\\bCACHE\\b", ""); - s_db2.put("\\bUSING INDEX\\b", ""); - s_db2.put("\\bTABLESPACE\\s\\w+\\b", ""); - s_db2.put("\\bSTORAGE\\([\\w\\s]+\\)", ""); - // - s_db2.put("\\bBITMAP INDEX\\b", "INDEX"); - - // Functions - s_db2.put("\\bSYSDATE\\b", "CURRENT_TIMESTAMP"); // alternative: NOW() - s_db2.put("\\bNVL\\b", "COALESCE"); - s_db2.put("\\bTO_DATE\\b", "TO_TIMESTAMP"); - // - s_db2.put("\\bDBMS_OUTPUT.PUT_LINE\\b", "RAISE NOTICE"); - - // Temporary - s_db2.put("\\bGLOBAL TEMPORARY\\b", "TEMPORARY"); - s_db2.put("\\bON COMMIT DELETE ROWS\\b", ""); - s_db2.put("\\bON COMMIT PRESERVE ROWS\\b", ""); - - - // DROP TABLE x CASCADE CONSTRAINTS - s_db2.put("\\bCASCADE CONSTRAINTS\\b", ""); - - // Select - s_db2.put("\\sFROM\\s+DUAL\\b", ""); - - // Statements - s_db2.put("\\bELSIF\\b", "ELSE IF"); - - // Sequences - s_db2.put("\\bSTART WITH\\b", "START"); - s_db2.put("\\bINCREMENT BY\\b", "INCREMENT"); - - } // initPostgreSQL - -} // ConvertMap diff --git a/dbPort/src/org/compiere/model/MSequence.java b/dbPort/src/org/compiere/model/MSequence.java index a0e10f8809..3896ca238c 100644 --- a/dbPort/src/org/compiere/model/MSequence.java +++ b/dbPort/src/org/compiere/model/MSequence.java @@ -269,12 +269,8 @@ public class MSequence extends X_AD_Sequence + "FROM AD_Sequence " + "WHERE Name=?" + " AND AD_Client_ID IN (0,?)" - + " AND IsActive='Y' AND IsTableID='N' AND IsAutoSequence='Y' "; - if (!DB.isDerby()&&!DB.isDB2()) - selectSQL += " ORDER BY AD_Client_ID DESC "; - else - // selectSQL += " FOR UPDATE OF CurrentNext, CurrentNextSys "; //jz for update , no order by, 10.216 no need - selectSQL += "FOR UPDATE"; + + " AND IsActive='Y' AND IsTableID='N' AND IsAutoSequence='Y' " + + " ORDER BY AD_Client_ID DESC "; USE_PROCEDURE = true; } Connection conn = null; diff --git a/dbPort/src/org/compiere/model/MSystem.java b/dbPort/src/org/compiere/model/MSystem.java index dc0e634b48..eab62f356a 100644 --- a/dbPort/src/org/compiere/model/MSystem.java +++ b/dbPort/src/org/compiere/model/MSystem.java @@ -167,9 +167,9 @@ public class MSystem extends X_AD_System recalc = false; } */ - if (DB.isDB2() || DB.isDerby()) - {//jz Derby/DB2 time out, fix it later - s = "NO Compiere statistics for DB2 or Derby."; + if (DB.isDerby()) + {//jz Derby time out, fix it later + s = "NO Compiere statistics for Derby."; recalc = false; } diff --git a/dbPort/src/org/compiere/util/DB.java b/dbPort/src/org/compiere/util/DB.java index 1e4e51dd18..3eb71f3689 100644 --- a/dbPort/src/org/compiere/util/DB.java +++ b/dbPort/src/org/compiere/util/DB.java @@ -569,6 +569,7 @@ public final class DB * Do we have a Derby DB ? * @return true if connected to Derby */ + public static boolean isDerby() { if (s_cc != null) @@ -591,13 +592,6 @@ public final class DB } // isPostgreSQL //begin vpj-cd e-evolution 02/07/2005 PostgreSQL - public static boolean isDB2() - { - if (s_cc != null) - return s_cc.isDB2(); - log.severe("No Database"); - return false; - } public static boolean isFyracle() { if (s_cc != null)