* remove db2, sqlserver and sybase files and reference

This commit is contained in:
Heng Sin Low 2007-01-14 18:37:35 +00:00
parent 72f7992c90
commit ef9569374d
10 changed files with 18 additions and 1010 deletions

View File

@ -11,7 +11,6 @@
<classpathentry kind="lib" path="/lib/jPDF.jar"/> <classpathentry kind="lib" path="/lib/jPDF.jar"/>
<classpathentry kind="lib" path="/lib/oracle.jar"/> <classpathentry kind="lib" path="/lib/oracle.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/derby"/> <classpathentry combineaccessrules="false" kind="src" path="/derby"/>
<classpathentry kind="lib" path="/lib/db2.jar"/>
<classpathentry kind="lib" path="/tools/lib/postgresql.jar"/> <classpathentry kind="lib" path="/tools/lib/postgresql.jar"/>
<classpathentry kind="lib" path="/lib/fyracle.jar"/> <classpathentry kind="lib" path="/lib/fyracle.jar"/>
<classpathentry kind="lib" path="/tools/lib/ant.jar"/> <classpathentry kind="lib" path="/tools/lib/ant.jar"/>

View File

@ -24,9 +24,6 @@
<pathelement path="${classpath}"/> <pathelement path="${classpath}"/>
<pathelement path="${lib.dir}/oracle.jar"/> <pathelement path="${lib.dir}/oracle.jar"/>
<pathelement path="${lib.dir}/postgresql.jar"/> <pathelement path="${lib.dir}/postgresql.jar"/>
<pathelement path="${lib.dir}/sybase.jar"/>
<pathelement path="${lib.dir}/sqlServer.jar"/>
<pathelement path="${lib.dir}/db2.jar"/>
<pathelement path="${lib.dir}/derby.jar"/> <pathelement path="${lib.dir}/derby.jar"/>
<pathelement path="${lib.dir}/postgresql.jar"/> <pathelement path="${lib.dir}/postgresql.jar"/>
<pathelement path="${lib.dir}/fyracle.jar"/> <pathelement path="${lib.dir}/fyracle.jar"/>

View File

@ -813,17 +813,12 @@ public class CConnection implements Serializable
setViaFirewall (false); setViaFirewall (false);
} }
// DB2 /*
if (isDB2()) if (isDerby())
{ {
if (getDbPort () != DB_DB2.DEFAULT_PORT) if (getDbPort () != DB_Derby.DEFAULT_PORT)
setDbPort (DB_DB2.DEFAULT_PORT); setDbPort (DB_Derby.DEFAULT_PORT);
} }*/
else if (isDerby())
{
// if (getDbPort () != DB_Derby.DEFAULT_PORT)
// setDbPort (DB_Derby.DEFAULT_PORT);
}
// begin vpj-cd e-evolution 09 ene 2006 // begin vpj-cd e-evolution 09 ene 2006
// PostgreSQL // PostgreSQL
if (isPostgreSQL ()) if (isPostgreSQL ())
@ -858,32 +853,16 @@ public class CConnection implements Serializable
return Database.DB_ORACLE.equals (m_type); return Database.DB_ORACLE.equals (m_type);
} // isOracle } // isOracle
/**
* Is IBM DB/2
* @return true if DB/2
*/
public boolean isDB2 ()
{
return Database.DB_DB2.equals (m_type);
} // isDB2
/** /**
* Is Apache Derby * Is Apache Derby
* @return true if Derby * @return true if Derby
*/ */
public boolean isDerby () public boolean isDerby ()
{ {
return Database.DB_DERBY.equals (m_type); return Database.DB_DERBY.equals (m_type);
} // isDerby } // 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 //begin e-evolution vpj-cd 30 nov 2005
/** /**

View File

@ -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.
* <pre>
* Timing:
* </pre>
* @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

View File

@ -31,12 +31,8 @@ public class Database
/** Oracle ID */ /** Oracle ID */
public static String DB_ORACLE = "Oracle"; public static String DB_ORACLE = "Oracle";
/** IBM DB/2 ID */
public static String DB_DB2 = "DB2";
/** Derby ID */ /** Derby ID */
public static String DB_DERBY = "Derby"; public static String DB_DERBY = "Derby";
/** Microsoft ID */
public static String DB_MSSQLServer = "SQLServer";
/** PostgreSQL ID */ /** PostgreSQL ID */
public static String DB_POSTGRESQL = "PostgreSQL"; public static String DB_POSTGRESQL = "PostgreSQL";
/** Enterprise DB */ /** Enterprise DB */
@ -48,9 +44,7 @@ public class Database
/** Supported Databases */ /** Supported Databases */
public static String[] DB_NAMES = new String[] { public static String[] DB_NAMES = new String[] {
DB_ORACLE DB_ORACLE
,DB_DB2
// ,DB_DERBY // ,DB_DERBY
// ,DB_MSSQLServer
,DB_POSTGRESQL ,DB_POSTGRESQL
,DB_FYRACLE ,DB_FYRACLE
// ,DB_EDB // ,DB_EDB
@ -59,9 +53,7 @@ public class Database
/** Database Classes */ /** Database Classes */
protected static Class[] DB_CLASSES = new Class[] { protected static Class[] DB_CLASSES = new Class[] {
DB_Oracle.class DB_Oracle.class
,DB_DB2.class
// ,DB_Derby.class // ,DB_Derby.class
// ,DB_MSSQLServer.class
,DB_PostgreSQL.class ,DB_PostgreSQL.class
,DB_Fyracle.class ,DB_Fyracle.class
// ,DB_EDB.class // ,DB_EDB.class
@ -107,8 +99,6 @@ public class Database
return new DB_Oracle(); return new DB_Oracle();
// if (URL.indexOf("derby") != -1) // if (URL.indexOf("derby") != -1)
// return new DB_Derby(); // return new DB_Derby();
if (url.indexOf("db2") != -1)
return new DB_DB2();
if (url.indexOf("postgresql") != -1) if (url.indexOf("postgresql") != -1)
return new DB_PostgreSQL(); return new DB_PostgreSQL();
if (url.indexOf("firebirdsql") != -1) if (url.indexOf("firebirdsql") != -1)

View File

@ -49,7 +49,7 @@ import javax.swing.JTextArea;
import org.compiere.Adempiere; import org.compiere.Adempiere;
import org.compiere.db.CConnection; import org.compiere.db.CConnection;
import org.compiere.db.CConnectionEditor; 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.db.Database;
import org.compiere.swing.CFrame; 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\\sequences.sql");
fSelectFile.addItem("D:\\adempiere\\db\\database\\create\\adempiere.sql"); fSelectFile.addItem("D:\\adempiere\\db\\database\\create\\adempiere.sql");
// Set up environment // Set up environment
fConnect.setValue(CConnection.get(Database.DB_DB2, fConnect.setValue(CConnection.get(Database.DB_POSTGRESQL,
"linux", DB_DB2.DEFAULT_PORT, "adempiere")); "linux", DB_PostgreSQL.DEFAULT_PORT, "adempiere"));
fTarget.setSelectedItem(Database.DB_DB2); fTarget.setSelectedItem(Database.DB_POSTGRESQL);
fExecute.setSelected(true); fExecute.setSelected(true);
cmd_execute(); // set UI cmd_execute(); // set UI

View File

@ -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<String,String> s_db2 = new TreeMap<String,String>();
// 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

View File

@ -269,12 +269,8 @@ public class MSequence extends X_AD_Sequence
+ "FROM AD_Sequence " + "FROM AD_Sequence "
+ "WHERE Name=?" + "WHERE Name=?"
+ " AND AD_Client_ID IN (0,?)" + " AND AD_Client_ID IN (0,?)"
+ " AND IsActive='Y' AND IsTableID='N' AND IsAutoSequence='Y' "; + " AND IsActive='Y' AND IsTableID='N' AND IsAutoSequence='Y' "
if (!DB.isDerby()&&!DB.isDB2()) + " ORDER BY AD_Client_ID DESC ";
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";
USE_PROCEDURE = true; USE_PROCEDURE = true;
} }
Connection conn = null; Connection conn = null;

View File

@ -167,9 +167,9 @@ public class MSystem extends X_AD_System
recalc = false; recalc = false;
} }
*/ */
if (DB.isDB2() || DB.isDerby()) if (DB.isDerby())
{//jz Derby/DB2 time out, fix it later {//jz Derby time out, fix it later
s = "NO Compiere statistics for DB2 or Derby."; s = "NO Compiere statistics for Derby.";
recalc = false; recalc = false;
} }

View File

@ -569,6 +569,7 @@ public final class DB
* Do we have a Derby DB ? * Do we have a Derby DB ?
* @return true if connected to Derby * @return true if connected to Derby
*/ */
public static boolean isDerby() public static boolean isDerby()
{ {
if (s_cc != null) if (s_cc != null)
@ -591,13 +592,6 @@ public final class DB
} // isPostgreSQL } // isPostgreSQL
//begin vpj-cd e-evolution 02/07/2005 PostgreSQL //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() public static boolean isFyracle()
{ {
if (s_cc != null) if (s_cc != null)