* remove derby and fyracle from trunk

This commit is contained in:
Heng Sin Low 2007-04-09 14:09:16 +00:00
parent 19d069f326
commit d9c376cc8c
9 changed files with 5 additions and 1240 deletions

View File

@ -9,9 +9,7 @@
<classpathentry kind="lib" path="/interfaces/Interfaces.jar"/>
<classpathentry kind="lib" path="/tools/lib/jnlp.jar"/>
<classpathentry kind="lib" path="/lib/oracle.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/derby"/>
<classpathentry kind="lib" path="/tools/lib/postgresql.jar"/>
<classpathentry kind="lib" path="/lib/fyracle.jar"/>
<classpathentry kind="lib" path="/tools/lib/ant.jar"/>
<classpathentry kind="lib" path="/tools/lib/itext-1.4.8.jar"/>
<classpathentry kind="lib" path="/tools/lib/jpedal.jar"/>

View File

@ -25,19 +25,14 @@
<pathelement path="${classpath}"/>
<pathelement path="${lib.dir}/oracle.jar"/>
<pathelement path="${lib.dir}/postgresql.jar"/>
<pathelement path="${lib.dir}/derby.jar"/>
<pathelement path="${lib.dir}/postgresql.jar"/>
<pathelement path="${lib.dir}/fyracle.jar"/>
<pathelement path="${lib.dir}/jboss.jar"/>
<pathelement path="${lib.dir}/CCTools.jar"/>
<pathelement path="../looks/CLooks.jar"/>
<pathelement path="${lib.dir}/customization.jar"/>
<pathelement path="${lib.dir}/patches.jar"/>
<pathelement path="${toolslib.dir}/junit.jar"/>
<pathelement path="../derby/derbyclient.jar"/>
<pathelement path="../derby/derbynet.jar"/>
<pathelement path="../derby/derbytools.jar"/>
<!-- Recursive relationship: require AppsServer -->
<pathelement path="../base/Base.jar"/>
<!-- <pathelement path="../interfaces/Interfaces.jar"/> -->

View File

@ -834,12 +834,6 @@ public class CConnection implements Serializable
setViaFirewall (false);
}
/*
if (isDerby())
{
if (getDbPort () != DB_Derby.DEFAULT_PORT)
setDbPort (DB_Derby.DEFAULT_PORT);
}*/
// begin vpj-cd e-evolution 09 ene 2006
// PostgreSQL
if (isPostgreSQL ())
@ -848,11 +842,6 @@ public class CConnection implements Serializable
setDbPort (DB_PostgreSQL.DEFAULT_PORT);
}
//end vpj-cd e-evolution 09 ene 2006
if (isFyracle())
{
if (getDbPort () != DB_Fyracle.DEFAULT_PORT)
setDbPort (DB_Fyracle.DEFAULT_PORT);
}
} // setType
/**
@ -874,26 +863,6 @@ public class CConnection implements Serializable
return Database.DB_ORACLE.equals (m_type);
} // isOracle
/**
* Is Apache Derby
* @return true if Derby
*/
public boolean isDerby ()
{
return Database.DB_DERBY.equals (m_type);
} // isDerby
//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
@ -902,16 +871,7 @@ public class CConnection implements Serializable
{
return Database.DB_POSTGRESQL.equals (m_type);
} // isPostgreSQL
//end
/**
* Is Fyracle DB
* @return true if PostgreSQL
*/
public boolean isFyracle ()
{
return Database.DB_FYRACLE.equals (m_type);
} // isPostgreSQL
//end
/**
* Is Database Connection OK
* @return true if database connection is OK

View File

@ -828,10 +828,7 @@ public class CreateAdempiere
//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");
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

View File

@ -1,630 +0,0 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.compiere.db;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.logging.Level;
import javax.sql.DataSource;
import org.compiere.dbPort.Convert;
import org.compiere.dbPort.Convert_Oracle;
import org.compiere.util.CLogger;
import org.compiere.util.DisplayType;
import org.compiere.util.Language;
import org.firebirdsql.pool.DriverConnectionPoolDataSource;
import org.firebirdsql.pool.FBWrappingDataSource;
/**
* Firebird Database Port
*
* @author Paul Ruizendaal
* @author Marek Mosiewicz http://www.jotel.com.pl (port to Compiere 2.5.1g)
* @version $Id: DB_Firebird.java,v 1.13 2003/08/16 19:09:21 pnr Exp $
*/
public class DB_Fyracle implements AdempiereDatabase {
/** Statement Cache */
private static final int MAX_STATEMENTS = 20;
/**
* Firebird Database
*/
public DB_Fyracle() {
} // DB_Firebird
/** Driver */
private org.firebirdsql.jdbc.FBDriver s_driver = null;
/** Default Port */
public static final int DEFAULT_PORT = 3050;
/** Connection String */
private String m_connection;
private FBWrappingDataSource m_ds;
private static CLogger log = CLogger.getCLogger(DB_Fyracle.class);
private Convert m_convert = new Convert_Oracle();
private String m_userName;
private String m_connectionURL;
/**
* Get Database Name
*
* @return database short name
*/
public String getName() {
return Database.DB_FYRACLE;
} // getName
/**
* Get Database Description
*
* @return database long name and version
*/
public String getDescription() {
return s_driver.toString();
} // getDescription
/**
* Get Standard JDBC Port
*
* @return standard port
*/
public int getStandardPort() {
return DEFAULT_PORT;
} // getStandardPort
/**
* Get Database Driver
*
* @return Driver
*/
public java.sql.Driver getDriver() {
if (s_driver == null)
s_driver = new org.firebirdsql.jdbc.FBDriver();
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) {
StringBuffer sb = new StringBuffer("jdbc:firebirdsql:oracle:");
sb.append(connection.getDbHost()).append("/").append(
connection.getDbPort()).append(":").append(
connection.getDbName());
m_connection = sb.toString();
m_userName = connection.getDbUid();
return m_connection;
} // getConnectionString
/**
* 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) {
StringBuffer sb = new StringBuffer("jdbc:firebirdsql:oracle:");
sb.append(dbHost).append("/").append(dbPort).append(":").append(dbName);
m_connection = sb.toString();
m_userName = userName;
return m_connection;
} // getConnectionURL
/**
* 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_Firebird[");
sb.append(m_connection).append("]");
return sb.toString();
} // toString
/** ********************************************************************** */
/**
* Convert an individual Oracle Style statements to target database
* statement syntax
*
* @param oraStatement
* @return converted Statement
* @throws Exception
*/
public String convertStatement(String oraStatement) {
return oraStatement;
} // convertStatement
/** ********************************************************************** */
/**
* Set the RowID
*
* @param pstmt
* @param pos
* @param rowID
* @throws SQLException
*/
public void setRowID(PreparedStatement pstmt, int pos, Object rowID)
throws SQLException {
pstmt.setString(pos, (String) rowID);
} // setRowID
/**
* Get the RowID
*
* @param rs
* @param pos
* @return rowID
* @throws SQLException
*/
public Object getRowID(java.sql.ResultSet rs, int pos) throws SQLException {
return rs.getString(pos);
} // getRowID
/*
* (non-Javadoc)
*
* @see org.compiere.db.CompiereDatabase#getCachedConnection(org.compiere.db.CConnection,
* boolean, int)
*/
public Connection getCachedConnection(CConnection connection,
boolean autoCommit, int transactionIsolation) throws Exception {
if (m_ds == null)
getDataSource(connection);
Connection conn = null;
// @TODO FYRACLE PooledConnection ignore setAutoCommit
// conn = m_ds.getConnection();
conn = getDriverConnection(connection);
if (conn != null) {
if (conn.getTransactionIsolation() != transactionIsolation)
conn.setTransactionIsolation(transactionIsolation);
if (conn.getAutoCommit() != autoCommit)
conn.setAutoCommit(autoCommit);
} else {
throw new RuntimeException("Cann't connect to database");
}
return conn;
}
/**
* 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
/**
* 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
/**
* 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
/*
* (non-Javadoc)
*
* @see org.compiere.db.CompiereDatabase#getDataSource(org.compiere.db.CConnection)
*/
public DataSource getDataSource(CConnection connection) {
if (m_ds != null)
return m_ds;
try {
m_ds = new FBWrappingDataSource();
StringBuffer db = new StringBuffer().append(connection.getDbHost())
.append("/").append(connection.getDbPort()).append(":")
.append(connection.getDbName());
m_ds.setDatabase(db.toString());
m_ds.setUserName(connection.getDbUid());
m_ds.setPassword(connection.getDbPwd());
m_ds.setDescription("Compiere DS");
m_ds.setType("ORACLE_MODE");
m_ds.setLoginTimeout(10);
m_ds.setMaxStatements(MAX_STATEMENTS);
m_ds.setLoginTimeout(10);
m_ds.setMaxStatements(MAX_STATEMENTS);
return m_ds;
} catch (Exception e) {
log.log(Level.SEVERE, toString(), e);
// throw new RuntimeException(e);
}
return null;
}
/*
* (non-Javadoc)
*
* @see org.compiere.db.CompiereDatabase#getStatus()
*/
public String getStatus() {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see org.compiere.db.CompiereDatabase#close()
*/
public void close() {
m_ds = null;
}
public static void main(String[] a) {
try {
FBWrappingDataSource m_ds = new FBWrappingDataSource();
m_ds
.setDatabase("localhost/3050:c:/devspace/apps/fyracle/data/compiere.fdb");
m_ds.setUserName("sysdba");
m_ds.setPassword("masterkey");
m_ds.setDescription("Compiere DS");
m_ds.setLoginTimeout(10);
//
m_ds.setMaxStatements(MAX_STATEMENTS);
//
m_ds.setType("ORACLE_MODE");
Connection c = null;
c = m_ds.getConnection();
c
.createStatement()
.executeQuery(
"SELECT * FROM ad_CLIENT WHERE created>TO_DATE('2001-01-01')");
new DB_Fyracle().getDriver();
c = DriverManager
.getConnection(
"jdbc:firebirdsql:oracle:localhost/3050:c:/devspace/apps/fyracle/data/compiere.fdb",
"SYSDBA", "masterkey");
c
.createStatement()
.executeQuery(
"SELECT * FROM ad_CLIENT WHERE created>TO_DATE('2001-01-01')");
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
/**
* Get JDBC Catalog
*
* @return null - not used
*/
public String getCatalog() {
return null;
} // getCatalog
/**
* Get SQL Commands. The following variables are resolved:
*
* @SystemPassword@,
* @CompiereUser@,
* @CompierePassword@
* @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 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,'999G999G999G990D00','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(",'999G999G999G990D00'");
else
retValue.append(",'TM9'");
// TO_CHAR(GrandTotal,'999G999G999G990D00','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 Name of System User
*
* @return system
*/
public String getSystemUser() {
return "sysdba";
} // 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
public String getAlternativeSQL(int reExNo, String msg, String sql) {
return null;
}
public String getConnectionURL(String connectionURL, String userName) {
m_userName = userName;
m_connectionURL = connectionURL;
return m_connectionURL;
}
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";
}
public Convert getConvert() {
return m_convert;
}
public boolean isSupported(String sql) {
return true;
}
} // DB_Firebird
class DataSourceImpl implements DataSource {
DriverConnectionPoolDataSource impl;
public DataSourceImpl() {
impl = new DriverConnectionPoolDataSource();
impl.setPooling(true);
impl.setStatementPooling(true);
impl.setDriverClassName("org.firebirdsql.jdbc.FBDriver");
}
public Connection getConnection() throws SQLException {
return impl.getPooledConnection("SYSDBA", "masterkey").getConnection();
}
public void setJdbcUrl(String url) throws SQLException {
impl.setJdbcUrl(url);
}
public Connection getConnection(String username, String password)
throws SQLException {
return impl.getPooledConnection(username, password).getConnection();
}
public PrintWriter getLogWriter() throws SQLException {
return impl.getLogWriter();
}
public int getLoginTimeout() throws SQLException {
return impl.getLoginTimeout();
}
public void setLogWriter(PrintWriter out) throws SQLException {
impl.setLogWriter(out);
}
public void setLoginTimeout(int seconds) throws SQLException {
impl.setLoginTimeout(seconds);
}
public boolean equals(Object obj) {
return impl.equals(obj);
}
public void setMaxConnections(int arg0) {
impl.setMaxPoolSize(arg0);
}
public void setMaxIdleTime(int arg0) {
impl.setMaxIdleTime(arg0);
}
public void setMaxPoolSize(int arg0) {
impl.setMaxPoolSize(arg0);
}
public void setMaxStatements(int arg0) {
impl.setMaxStatements(arg0);
}
public void setProperty(String arg0, String arg1) {
impl.setProperty(arg0, arg1);
}
public void setTransactionIsolationLevel(int arg0) {
impl.setTransactionIsolationLevel(arg0);
}
public String toString() {
return impl.toString();
}
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException
{
return false;
}
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException{return null;}
}

View File

@ -31,32 +31,19 @@ public class Database
/** Oracle ID */
public static String DB_ORACLE = "Oracle";
/** Derby ID */
public static String DB_DERBY = "Derby";
/** PostgreSQL ID */
public static String DB_POSTGRESQL = "PostgreSQL";
/** Enterprise DB */
//public static String DB_EDB = "EnterpriseDB";
public static String DB_FYRACLE = "Fyracle(beta)";
/** Supported Databases */
public static String[] DB_NAMES = new String[] {
DB_ORACLE
// ,DB_DERBY
,DB_POSTGRESQL
,DB_FYRACLE
// ,DB_EDB
};
/** Database Classes */
protected static Class[] DB_CLASSES = new Class[] {
DB_Oracle.class
// ,DB_Derby.class
,DB_PostgreSQL.class
,DB_Fyracle.class
// ,DB_EDB.class
};
/** Connection Timeout in seconds */
@ -97,12 +84,8 @@ public class Database
}
if (url.indexOf("oracle") != -1)
return new DB_Oracle();
// if (URL.indexOf("derby") != -1)
// return new DB_Derby();
if (url.indexOf("postgresql") != -1)
return new DB_PostgreSQL();
if (url.indexOf("firebirdsql") != -1)
return new DB_Fyracle();
log.severe("No Database for " + url);
return null;

View File

@ -1,426 +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.
* You may reach us at: ComPiere, Inc. - http://www.compiere.org/license.html
* 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@compiere.org
*****************************************************************************/
package org.compiere.db;
import java.io.*;
import java.net.*;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import org.apache.derby.drda.*;
import org.apache.derby.impl.drda.*;
import org.apache.derby.jdbc.*;
import org.compiere.util.*;
/**
* Derby DB Server
*
* @author Jorg Janke
* @version $Id: DerbyServer.java,v 1.5 2006/07/30 00:55:13 jjanke Exp $
*/
public class DerbyServer extends Thread
{
/**
* Get/Create Derby Server
* @return server
*/
public static synchronized DerbyServer get()
{
if (s_server == null)
{
InetAddress address = null;
int port = PORT;
try
{
address = InetAddress.getByAddress(new byte[] {0,0,0,0}); // all ports
s_server = new DerbyServer(address, port);
s_server.start();
}
catch (Exception e)
{
String msg = null;
if (address == null)
msg = "";
else
msg = address.toString();
msg += ":" + port;
log.log(Level.SEVERE, msg, e);
}
}
return s_server;
} // get
/**
* Start Server
* @return true if started
*/
public static boolean startServer()
{
if (get() == null)
return false;
return s_server.isServerStarted();
} // startServer
/**
* Stop Server
* @return true if stopped / not running
*/
public static boolean stopServer()
{
if (s_server == null)
return true;
try
{
s_server.shutdown();
s_server = null;
return true;
}
catch (Exception e)
{
log.log(Level.SEVERE, e.getMessage(), e);
}
return false;
} // stopServer
/** Singleton */
private static DerbyServer s_server = null;
/** Default Port 1527 */
public static final int PORT = NetworkServerControl.DEFAULT_PORTNUMBER;
/** Logger */
private static CLogger log = CLogger.getCLogger (DerbyServer.class);
/**************************************************************************
* Derby Server
* @param address server address
* @param port port
* @throws Exception
*/
private DerbyServer (InetAddress address, int port) throws Exception
{
super("CompiereDerby");
if (s_impl != null)
throw new IllegalStateException("Derby Server already started");
//
String compiereHome = Ini.getAdempiereHome();
s_derbyHome = compiereHome + File.separator + "derby";
File dir = new File(s_derbyHome);
if (!dir.exists())
dir.mkdir();
//
System.setProperty("derby.system.home", s_derbyHome);
System.setProperty("derby.drda.traceDirectory", s_derbyHome);
//
String logIt = "false";
if (CLogMgt.isLevelFiner())
logIt = "true";
System.setProperty("derby.drda.logConnections", logIt);
System.setProperty("derby.drda.traceAll", logIt);
//
System.setProperty("derby.connection.requireAuthentication", "true");
System.setProperty("derby.authentication.provider", "BUILTIN");
addUser("compiere", "compiere");
//
s_address = address;
s_port = port;
s_impl = new NetworkServerControlImpl (s_address, s_port);
} // DerbyServer
/** Singleton */
private static NetworkServerControlImpl s_impl = null;
/** Derby Home */
private static String s_derbyHome = "";
/** Address */
private static InetAddress s_address = null;
/** Port */
private static int s_port = 0;
/**
* Run
*/
public void run()
{
log.info("starting ...");
PrintWriter consoleWriter = new PrintWriter(System.out, true); // flush
try
{
s_impl.blockingStart(consoleWriter);
}
catch (Exception e)
{
log.log(Level.SEVERE, e.getMessage(), e);
s_impl = null;
}
log.info("done");
} // run
/**
* Interrupt - shutdown
*/
public void interrupt ()
{
super.interrupt ();
shutdown();
} // interrupt
/**
* Is Server Started
* @return server started
*/
public boolean isServerStarted()
{
if (s_impl == null)
return false;
try
{
s_impl.ping();
}
catch (Exception e)
{
return false;
}
return true;
} // isServerStarted
/**
* Shutdown
* @return true if shut down
*/
public boolean shutdown()
{
if (s_impl != null)
{
try
{
log.info("shutting down ...");
s_impl.shutdown();
log.info("shutdown");
return true;
}
catch (Exception e)
{
return false;
}
}
return true;
} // shutdown
/**
* String Representation
* @return info
*/
public String toString ()
{
StringBuffer sb = new StringBuffer ("DerbyServer[");
sb.append (s_derbyHome)
.append(";").append(s_address)
.append(":").append(s_port)
.append(";Alive=").append(isAlive())
.append(";Started=").append(isServerStarted());
sb.append ("]");
return sb.toString ();
} // toString
/**
* Get Derby Home
* @return home
*/
public String getDerbyHome()
{
return s_derbyHome;
} // getDerbyHome
/**
* Get Runtime Info
* @return info
*/
public String getRuntimeInfo()
{
try
{
if (s_impl != null)
return s_impl.runtimeInfo();
}
catch (Exception e)
{
return e.getMessage();
}
return "";
} // getRuntimeInfo
/**
* Get System Info
* @return info
*/
public String getSysInfo()
{
try
{
if (s_impl != null)
return s_impl.sysinfo();
}
catch (Exception e)
{
return e.getMessage();
}
return "";
} // getSysInfo
/**
* Get current Network server properties.
* @return Properties object containing Network server properties
* @exception Exception throws an exception if an error occurs
*/
public Properties getCurrentProperties() throws Exception
{
return s_impl.getCurrentProperties();
} // getCurrentProperties
/**
* Add User
* @param dbUid user id
* @param dbPwd user password
*/
public void addUser (String dbUid, String dbPwd)
{
System.setProperty("derby.user." + dbUid, dbPwd);
Properties dp = new Properties();
} // addUser
/**
* Create Database
* @param dbName database name
* @param dbUid user id
* @param dbPwd user password
* @return true if exists or created
*/
public boolean createDatabase (String dbName,
String dbUid, String dbPwd)
{
addUser (dbUid, dbPwd);
// Embedded Driver
try
{
EmbeddedDriver driver = new EmbeddedDriver();
DriverManager.registerDriver (driver);
}
catch (Exception e)
{
log.log(Level.SEVERE, "DriverIssue", e);
return false;
}
// Connection
String dbUrl = "jdbc:derby:" + dbName;
Connection conn = null;
try
{
String urlAttributes = ";create=true"
// + "dataEncryption=true;bootPassword=cLo4u922sc23aPe"
// + ";territory=en_US"
+ ";user=" + dbUid
+ ";password=" + dbPwd;
conn = DriverManager.getConnection(dbUrl + urlAttributes);
log.info("Created DB: " + dbName);
// new JDBCInfo(conn);
}
catch (Exception e)
{
log.severe(e.getMessage());
}
try
{
if (conn != null)
conn.close();
conn = null;
}
catch (Exception e)
{
}
// Connection test
try
{
conn = DriverManager.getConnection(dbUrl, dbUid, dbPwd);
log.info("Connected to DB: " + dbName);
// new JDBCInfo(conn);
}
catch (Exception e)
{
log.severe(e.getMessage());
conn = null;
return false;
}
// Connection test
Statement stmt = null;
try
{
stmt = conn.createStatement();
stmt.executeUpdate("CREATE TABLE XX (XX VARCHAR(5))");
stmt.executeUpdate("INSERT INTO XX (XX) VALUES ('A')");
}
catch (Exception e)
{
log.info(e.getMessage());
}
try
{
if (stmt != null)
stmt.close();
if (conn != null)
conn.close();
conn = null;
}
catch (Exception e)
{
}
return true;
} // createDatabase
/**************************************************************************
* Start Derby Server
* @param args
*/
public static void main (String[] args)
{
CLogMgt.setLevel(Level.FINE);
DerbyServer server = DerbyServer.get();
startServer();
server.createDatabase("compiere", "compiere", "compiere");
// log.info(server.getRuntimeInfo());
// log.info(server.getSysInfo());
try
{
// log.info(server.getCurrentProperties().toString());
//
log.info("Sleeping " + get());
Thread.sleep(5000);
}
catch (Exception e)
{
}
// stopServer();
} // main
} // DerbyServer

View File

@ -1,78 +0,0 @@
package org.compiere.dbPort;
import java.util.TreeMap;
public final class ConvertMap_Derby {
/** Tree Map for Derby */
private static TreeMap<String,String> s_derby = new TreeMap<String,String>();
/**
* Return Map for Derby
* @return TreeMap with pattern as key and the replacement as value
*/
public static TreeMap getConvertMap()
{
if (s_derby.size() == 0)
initConvertMap();
return s_derby;
} // getDerbyMap
/**
* Derby Init
*/
static private void initConvertMap()
{ // C:\Sources\db-derby-10.1.2.1-bin\docs\html\ref\index.html
// Oracle Pattern Replacement
// Data Types
s_derby.put("\\bNUMBER\\b", "DECIMAL(31,6)"); //jz: changed from decimal to decimal(31,6)
s_derby.put("\\bDATE\\b", "TIMESTAMP");
s_derby.put("\\bVARCHAR2\\b", "VARCHAR");
s_derby.put("\\bNVARCHAR2\\b", "VARCHAR");
s_derby.put("\\bNCHAR\\b", "CHAR");
// Storage
s_derby.put("\\bCACHE\\b", "");
s_derby.put("\\bUSING INDEX\\b", "");
s_derby.put("\\bTABLESPACE\\s\\w+\\b", "");
s_derby.put("\\bSTORAGE\\([\\w\\s]+\\)", "");
//
s_derby.put("\\bBITMAP INDEX\\b", "INDEX");
// Select
s_derby.put("\\bFOR UPDATE\\b", "");
s_derby.put("\\bTRUNC\\(", "convert(date,");
// Functions
s_derby.put("\\bSysDate\\b", "CURRENT_TIMESTAMP");
s_derby.put("\\bSYSDATE\\b", "CURRENT_TIMESTAMP");
s_derby.put("\\bNVL\\b", "NULLIF");
s_derby.put("\\bCOALESCE\\b", "NULLIF");
s_derby.put("\\bTO_DATE\\b", "TO_TIMESTAMP");
//
// s_derby.put("\\bDBMS_OUTPUT.PUT_LINE\\b", "RAISE NOTICE");
// Temporary
s_derby.put("\\bGLOBAL TEMPORARY\\b", "TEMPORARY");
s_derby.put("\\bON COMMIT DELETE ROWS\\b", "");
s_derby.put("\\bON COMMIT PRESERVE ROWS\\b", "");
// DROP TABLE x CASCADE CONSTRAINTS
// s_derby.put("\\bCASCADE CONSTRAINTS\\b", "");
// Select
s_derby.put("\\sFROM\\s+DUAL\\b", "");
// Statements
s_derby.put("\\bELSIF\\b", "ELSE IF");
// Sequences
s_derby.put("\\bSTART WITH\\b", "START");
s_derby.put("\\bINCREMENT BY\\b", "INCREMENT");
} // initDerby
}

View File

@ -585,20 +585,7 @@ public final class DB
return false;
} // isOracle
/**
* Do we have a Derby DB ?
* @return true if connected to Derby
*/
public static boolean isDerby()
{
if (s_cc != null)
return s_cc.isDerby();
log.severe("No Database Connection");
return false;
} // isDerby
//begin vpj-cd e-evolution 02/07/2005 PostgreSQL
//begin vpj-cd e-evolution 02/07/2005 PostgreSQL
/**
* Do we have a Postgre DB ?
* @return true if connected to PostgreSQL
@ -610,29 +597,8 @@ public final class DB
log.severe("No Database");
return false;
} // isPostgreSQL
//begin vpj-cd e-evolution 02/07/2005 PostgreSQL
//begin vpj-cd e-evolution 02/07/2005 PostgreSQL
public static boolean isFyracle()
{
if (s_cc != null)
return s_cc.isFyracle();
log.severe("No Database");
return false;
} // isFyracle
/**
* Do we have a Postgre DB ?
* @return true if connected to PostgreSQL
*/
// public static boolean isEDB()
// {
// if (s_cc != null)
// return s_cc.isEDB();
// log.severe("No Database");
// return false;
// } // isPostgreSQL
//end vpj-cd e-evolution 02/07/2005 PostgreSQL
/**
* Get Database Info
* @return info