* Improve startup time
* Make validation of application server and database connection on startup optional * Separate the database interface file by database. This will ease concurrent development of multiple database support.
This commit is contained in:
parent
a12fa4bcab
commit
856517415d
|
@ -21,6 +21,8 @@ import java.sql.*;
|
||||||
|
|
||||||
import javax.sql.*;
|
import javax.sql.*;
|
||||||
|
|
||||||
|
import org.compiere.dbPort.Convert;
|
||||||
|
|
||||||
//import org.compiere.util.CPreparedStatement;
|
//import org.compiere.util.CPreparedStatement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -264,6 +266,8 @@ public interface AdempiereDatabase
|
||||||
*/
|
*/
|
||||||
public void close();
|
public void close();
|
||||||
|
|
||||||
|
public Convert getConvert();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Data Type
|
* Get Data Type
|
||||||
* @param DisplayType display type
|
* @param DisplayType display type
|
||||||
|
|
|
@ -210,6 +210,9 @@ public class CConnection implements Serializable
|
||||||
/** DB Info */
|
/** DB Info */
|
||||||
private String m_dbInfo = null;
|
private String m_dbInfo = null;
|
||||||
|
|
||||||
|
/** Had application server been query **/
|
||||||
|
private boolean m_queryAppsServer = false;
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* Get Name
|
* Get Name
|
||||||
|
@ -256,6 +259,7 @@ public class CConnection implements Serializable
|
||||||
m_apps_host = apps_host;
|
m_apps_host = apps_host;
|
||||||
m_name = toString ();
|
m_name = toString ();
|
||||||
m_okApps = false;
|
m_okApps = false;
|
||||||
|
m_queryAppsServer = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -275,6 +279,7 @@ public class CConnection implements Serializable
|
||||||
{
|
{
|
||||||
m_apps_port = apps_port;
|
m_apps_port = apps_port;
|
||||||
m_okApps = false;
|
m_okApps = false;
|
||||||
|
m_queryAppsServer = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -303,9 +308,11 @@ public class CConnection implements Serializable
|
||||||
*/
|
*/
|
||||||
public boolean isAppsServerOK (boolean tryContactAgain)
|
public boolean isAppsServerOK (boolean tryContactAgain)
|
||||||
{
|
{
|
||||||
if (!tryContactAgain)
|
if (!tryContactAgain && m_queryAppsServer)
|
||||||
return m_okApps;
|
return m_okApps;
|
||||||
|
|
||||||
|
m_queryAppsServer = true;
|
||||||
|
|
||||||
// Get Context
|
// Get Context
|
||||||
if (m_iContext == null)
|
if (m_iContext == null)
|
||||||
{
|
{
|
||||||
|
@ -340,8 +347,9 @@ public class CConnection implements Serializable
|
||||||
*/
|
*/
|
||||||
public Exception testAppsServer ()
|
public Exception testAppsServer ()
|
||||||
{
|
{
|
||||||
if (queryAppsServerInfo ())
|
//if (queryAppsServerInfo ())
|
||||||
testDatabase (false);
|
// testDatabase (false);
|
||||||
|
queryAppsServerInfo ();
|
||||||
return getAppsServerException ();
|
return getAppsServerException ();
|
||||||
} // testAppsServer
|
} // testAppsServer
|
||||||
|
|
||||||
|
@ -968,16 +976,7 @@ public class CConnection implements Serializable
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DatabaseMetaData dbmd = conn.getMetaData ();
|
readInfo(conn);
|
||||||
m_info[0] = "Database=" + dbmd.getDatabaseProductName ()
|
|
||||||
+ " - " + dbmd.getDatabaseProductVersion ();
|
|
||||||
m_info[0] = m_info[0].replace ('\n', ' ');
|
|
||||||
m_info[1] = "Driver =" + dbmd.getDriverName ()
|
|
||||||
+ " - " + dbmd.getDriverVersion ();
|
|
||||||
if (isDataSource())
|
|
||||||
m_info[1] += " - via DataSource";
|
|
||||||
m_info[1] = m_info[1].replace ('\n', ' ');
|
|
||||||
log.config(m_info[0] + " - " + m_info[1]);
|
|
||||||
conn.close ();
|
conn.close ();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -989,6 +988,18 @@ public class CConnection implements Serializable
|
||||||
return m_dbException; // from opening
|
return m_dbException; // from opening
|
||||||
} // testDatabase
|
} // testDatabase
|
||||||
|
|
||||||
|
public void readInfo(Connection conn) throws SQLException {
|
||||||
|
DatabaseMetaData dbmd = conn.getMetaData ();
|
||||||
|
m_info[0] = "Database=" + dbmd.getDatabaseProductName ()
|
||||||
|
+ " - " + dbmd.getDatabaseProductVersion ();
|
||||||
|
m_info[0] = m_info[0].replace ('\n', ' ');
|
||||||
|
m_info[1] = "Driver =" + dbmd.getDriverName ()
|
||||||
|
+ " - " + dbmd.getDriverVersion ();
|
||||||
|
if (isDataSource())
|
||||||
|
m_info[1] += " - via DataSource";
|
||||||
|
m_info[1] = m_info[1].replace ('\n', ' ');
|
||||||
|
log.config(m_info[0] + " - " + m_info[1]);
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* Short String representation
|
* Short String representation
|
||||||
|
@ -1200,15 +1211,7 @@ public class CConnection implements Serializable
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Database.DB_NAMES.length; i++)
|
m_db = Database.getDatabase(m_type);
|
||||||
{
|
|
||||||
if (Database.DB_NAMES[i].equals (m_type))
|
|
||||||
{
|
|
||||||
m_db = (AdempiereDatabase)Database.DB_CLASSES[i].
|
|
||||||
newInstance ();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1491,6 +1494,7 @@ public class CConnection implements Serializable
|
||||||
log.finer(getAppsHost());
|
log.finer(getAppsHost());
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
m_okApps = false;
|
m_okApps = false;
|
||||||
|
m_queryAppsServer = true;
|
||||||
m_appsException = null;
|
m_appsException = null;
|
||||||
//
|
//
|
||||||
getInitialContext (false);
|
getInitialContext (false);
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.sql.*;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
import javax.sql.*;
|
import javax.sql.*;
|
||||||
|
|
||||||
|
import org.compiere.dbPort.Convert;
|
||||||
import org.compiere.util.*;
|
import org.compiere.util.*;
|
||||||
|
|
||||||
import com.ibm.db2.jcc.*;
|
import com.ibm.db2.jcc.*;
|
||||||
|
@ -833,4 +834,8 @@ public class DB_DB2
|
||||||
/** **/
|
/** **/
|
||||||
} // main
|
} // main
|
||||||
|
|
||||||
|
public Convert getConvert() {
|
||||||
|
throw new UnsupportedOperationException("Not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
} // DB_DB2
|
} // DB_DB2
|
||||||
|
|
|
@ -24,6 +24,8 @@ import javax.sql.*;
|
||||||
import oracle.jdbc.*;
|
import oracle.jdbc.*;
|
||||||
import oracle.jdbc.pool.*;
|
import oracle.jdbc.pool.*;
|
||||||
import org.compiere.*;
|
import org.compiere.*;
|
||||||
|
import org.compiere.dbPort.Convert;
|
||||||
|
import org.compiere.dbPort.Convert_Oracle;
|
||||||
import org.compiere.util.*;
|
import org.compiere.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,6 +80,8 @@ public class DB_Oracle implements AdempiereDatabase, OracleConnectionCacheCallba
|
||||||
/** Cached User Name */
|
/** Cached User Name */
|
||||||
private String m_userName = null;
|
private String m_userName = null;
|
||||||
|
|
||||||
|
private Convert m_convert = new Convert_Oracle();
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static CLogger log = CLogger.getCLogger (DB_Oracle.class);
|
private static CLogger log = CLogger.getCLogger (DB_Oracle.class);
|
||||||
|
|
||||||
|
@ -1109,4 +1113,8 @@ public class DB_Oracle implements AdempiereDatabase, OracleConnectionCacheCallba
|
||||||
**/
|
**/
|
||||||
} // main
|
} // main
|
||||||
|
|
||||||
|
public Convert getConvert() {
|
||||||
|
return m_convert;
|
||||||
|
}
|
||||||
|
|
||||||
} // DB_Oracle
|
} // DB_Oracle
|
||||||
|
|
|
@ -14,13 +14,21 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.db;
|
package org.compiere.db;
|
||||||
|
|
||||||
import java.math.*;
|
import java.math.BigDecimal;
|
||||||
import java.sql.*;
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Timestamp;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import javax.sql.*;
|
import javax.sql.ConnectionPoolDataSource;
|
||||||
import org.compiere.dbPort.*;
|
import javax.sql.DataSource;
|
||||||
import org.compiere.util.*;
|
import javax.sql.RowSet;
|
||||||
|
|
||||||
|
import org.compiere.dbPort.Convert;
|
||||||
|
import org.compiere.dbPort.Convert_PostgreSQL;
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PostgreSQL Database Port
|
* PostgreSQL Database Port
|
||||||
|
@ -30,6 +38,10 @@ import org.compiere.util.*;
|
||||||
*/
|
*/
|
||||||
public class DB_PostgreSQL implements AdempiereDatabase
|
public class DB_PostgreSQL implements AdempiereDatabase
|
||||||
{
|
{
|
||||||
|
public Convert getConvert() {
|
||||||
|
return m_convert;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PostgreSQL Database
|
* PostgreSQL Database
|
||||||
*/
|
*/
|
||||||
|
@ -47,7 +59,7 @@ public class DB_PostgreSQL implements AdempiereDatabase
|
||||||
private org.postgresql.ds.PGPoolingDataSource m_ds = null;
|
private org.postgresql.ds.PGPoolingDataSource m_ds = null;
|
||||||
|
|
||||||
/** Statement Converter */
|
/** Statement Converter */
|
||||||
private Convert m_convert = new Convert(Database.DB_POSTGRESQL);
|
private Convert_PostgreSQL m_convert = new Convert_PostgreSQL();
|
||||||
/** Connection String */
|
/** Connection String */
|
||||||
private String m_connection;
|
private String m_connection;
|
||||||
/** Cached Database Name */
|
/** Cached Database Name */
|
||||||
|
|
|
@ -67,4 +67,24 @@ public class Database
|
||||||
/** Connection Timeout in seconds */
|
/** Connection Timeout in seconds */
|
||||||
public static int CONNECTION_TIMEOUT = 10;
|
public static int CONNECTION_TIMEOUT = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Database
|
||||||
|
* @return database
|
||||||
|
*/
|
||||||
|
public static AdempiereDatabase getDatabase (String type)
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
AdempiereDatabase db = null;
|
||||||
|
for (int i = 0; i < Database.DB_NAMES.length; i++)
|
||||||
|
{
|
||||||
|
if (Database.DB_NAMES[i].equals (type))
|
||||||
|
{
|
||||||
|
db = (AdempiereDatabase)Database.DB_CLASSES[i].
|
||||||
|
newInstance ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return db;
|
||||||
|
}
|
||||||
|
|
||||||
} // Database
|
} // Database
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -16,14 +16,42 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.dbPort;
|
package org.compiere.dbPort;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.event.*;
|
import java.awt.Color;
|
||||||
import java.io.*;
|
import java.awt.Component;
|
||||||
import java.sql.*;
|
import java.awt.Cursor;
|
||||||
import javax.swing.*;
|
import java.awt.Dimension;
|
||||||
import org.compiere.*;
|
import java.awt.GridBagConstraints;
|
||||||
import org.compiere.db.*;
|
import java.awt.GridBagLayout;
|
||||||
import org.compiere.swing.*;
|
import java.awt.Insets;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.Connection;
|
||||||
|
|
||||||
|
import javax.swing.Box;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
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.Database;
|
||||||
|
import org.compiere.swing.CFrame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Conversion Dialog
|
* Conversion Dialog
|
||||||
|
@ -244,7 +272,7 @@ public class ConvertDialog extends CFrame implements ActionListener
|
||||||
if (fExecute.isSelected())
|
if (fExecute.isSelected())
|
||||||
{
|
{
|
||||||
CConnection cc = (CConnection)fConnect.getValue();
|
CConnection cc = (CConnection)fConnect.getValue();
|
||||||
Convert convert = new Convert (cc.getType());
|
Convert convert = cc.getDatabase().getConvert();
|
||||||
convert.setVerbose(fVerbose.isSelected());
|
convert.setVerbose(fVerbose.isSelected());
|
||||||
//
|
//
|
||||||
Connection conn = cc.getConnection (true, Connection.TRANSACTION_READ_COMMITTED);
|
Connection conn = cc.getConnection (true, Connection.TRANSACTION_READ_COMMITTED);
|
||||||
|
@ -273,7 +301,13 @@ public class ConvertDialog extends CFrame implements ActionListener
|
||||||
infoPane.append("No conversion needed.\n");
|
infoPane.append("No conversion needed.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Convert convert = new Convert (target);
|
Convert convert = null;
|
||||||
|
try {
|
||||||
|
convert = Database.getDatabase(target).getConvert();
|
||||||
|
} catch (Exception e) {
|
||||||
|
infoPane.append("Error: " + e + "\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
String cc = convert.convertAll(sb.toString());
|
String cc = convert.convertAll(sb.toString());
|
||||||
|
|
||||||
|
|
|
@ -1,260 +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
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Return Map for Derby
|
|
||||||
* @return TreeMap with pattern as key and the replacement as value
|
|
||||||
*/
|
|
||||||
public static TreeMap getDerbyMap()
|
|
||||||
{
|
|
||||||
if (s_derby.size() == 0)
|
|
||||||
initDerby();
|
|
||||||
return s_derby;
|
|
||||||
} // getDerbyMap
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return Map for DB/2
|
|
||||||
* @return TreeMap with pattern as key and the replacement as value
|
|
||||||
*/
|
|
||||||
public static TreeMap getDB2Map()
|
|
||||||
{
|
|
||||||
if (s_db2.size() == 0)
|
|
||||||
initDB2();
|
|
||||||
return s_db2;
|
|
||||||
} // getDB2Map
|
|
||||||
// begin e-evolution PostgreSQL
|
|
||||||
/**
|
|
||||||
* Return Map for PostgreSQL
|
|
||||||
* @return TreeMap with pattern as key and the replacement as value
|
|
||||||
*/
|
|
||||||
public static TreeMap getPostgeSQLMap()
|
|
||||||
{
|
|
||||||
if (s_pg.size() == 0)
|
|
||||||
initPostgreSQL();
|
|
||||||
return s_pg;
|
|
||||||
} // getPostgreSQLMap
|
|
||||||
// end e-evolution PostgreSQL
|
|
||||||
|
|
||||||
/** Tree Map for Derby */
|
|
||||||
private static TreeMap<String,String> s_derby = new TreeMap<String,String>();
|
|
||||||
/** Tree Map for PostgreSQL */
|
|
||||||
private static TreeMap<String,String> s_db2 = new TreeMap<String,String>();
|
|
||||||
// begin e-evolution PostgreSQL
|
|
||||||
/** Tree Map for PostgreSQL */
|
|
||||||
private static TreeMap<String,String> s_pg = new TreeMap<String,String>();
|
|
||||||
// end e-evolution PostgreSQL
|
|
||||||
/**
|
|
||||||
* Derby Init
|
|
||||||
*/
|
|
||||||
static private void initDerby()
|
|
||||||
{ // 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
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DB/2 Init
|
|
||||||
*/
|
|
||||||
static private void initDB2()
|
|
||||||
{
|
|
||||||
// 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
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PostgreSQL Init
|
|
||||||
*/
|
|
||||||
static private void initPostgreSQL()
|
|
||||||
{
|
|
||||||
// Oracle Pattern Replacement
|
|
||||||
|
|
||||||
// Data Types
|
|
||||||
s_pg.put("\\bNUMBER\\b", "NUMERIC");
|
|
||||||
s_pg.put("\\bDATE\\b", "TIMESTAMP");
|
|
||||||
s_pg.put("\\bVARCHAR2\\b", "VARCHAR");
|
|
||||||
s_pg.put("\\bNVARCHAR2\\b", "VARCHAR");
|
|
||||||
s_pg.put("\\bNCHAR\\b", "CHAR");
|
|
||||||
//begin vpj-cd e-evolution 03/11/2005 PostgreSQL
|
|
||||||
s_pg.put("\\bBLOB\\b", "BYTEA"); // BLOB not directly supported
|
|
||||||
s_pg.put("\\bCLOB\\b", "BYTEA"); // CLOB not directly supported
|
|
||||||
s_pg.put("\\bLIMIT\\b","\"limit\"");
|
|
||||||
s_pg.put("\\bACTION\\b","\"action\"");
|
|
||||||
//s_pg.put("\\bBLOB\\b", "OID"); // BLOB not directly supported
|
|
||||||
//s_pg.put("\\bCLOB\\b", "OID"); // CLOB not directly supported
|
|
||||||
//end vpj-cd e-evolution 03/11/2005 PostgreSQL
|
|
||||||
|
|
||||||
// Storage
|
|
||||||
s_pg.put("\\bCACHE\\b", "");
|
|
||||||
s_pg.put("\\bUSING INDEX\\b", "");
|
|
||||||
s_pg.put("\\bTABLESPACE\\s\\w+\\b", "");
|
|
||||||
s_pg.put("\\bSTORAGE\\([\\w\\s]+\\)", "");
|
|
||||||
//
|
|
||||||
s_pg.put("\\bBITMAP INDEX\\b", "INDEX");
|
|
||||||
|
|
||||||
// Functions
|
|
||||||
s_pg.put("\\bSYSDATE\\b", "CURRENT_TIMESTAMP"); // alternative: NOW()
|
|
||||||
//Bug fix, Gunther Hoppe 08.07.2005 e-evolution
|
|
||||||
//Begin ----------------------------------------------------------------------------------------
|
|
||||||
s_pg.put("\\bSysDate\\b", "CURRENT_TIMESTAMP");
|
|
||||||
s_pg.put("SysDate", "CURRENT_TIMESTAMP");
|
|
||||||
//end ----------------------------------------------------------------------------------------
|
|
||||||
//begin vpj-cd e-evolution 03/11/2005 PostgreSQL
|
|
||||||
s_pg.put("\\bDUMP\\b", "MD5");
|
|
||||||
s_pg.put("END CASE", "END");
|
|
||||||
s_pg.put("\\bgetDate()\\b", "CURRENT_TIMESTAMP"); // alternative: NOW()
|
|
||||||
//end vpj-cd e-evolution 03/11/2005 PostgreSQL
|
|
||||||
s_pg.put("\\bNVL\\b", "COALESCE");
|
|
||||||
s_pg.put("\\bTO_DATE\\b", "TO_TIMESTAMP");
|
|
||||||
//
|
|
||||||
s_pg.put("\\bDBMS_OUTPUT.PUT_LINE\\b", "RAISE NOTICE");
|
|
||||||
|
|
||||||
// Temporary
|
|
||||||
s_pg.put("\\bGLOBAL TEMPORARY\\b", "TEMPORARY");
|
|
||||||
s_pg.put("\\bON COMMIT DELETE ROWS\\b", "");
|
|
||||||
s_pg.put("\\bON COMMIT PRESERVE ROWS\\b", "");
|
|
||||||
|
|
||||||
//DDL
|
|
||||||
|
|
||||||
// begin vpj-cd e-evolution 08/02/2005 PostgreSQL
|
|
||||||
//s_pg.put("\\bMODIFY\\b","ALTER COLUMN");
|
|
||||||
//s_pg.put("\\bDEFAULT\\b","SET DEFAULT");
|
|
||||||
// end vpj-cd e-evolution 08/02/2005 PostgreSQL
|
|
||||||
|
|
||||||
// DROP TABLE x CASCADE CONSTRAINTS
|
|
||||||
s_pg.put("\\bCASCADE CONSTRAINTS\\b", "");
|
|
||||||
|
|
||||||
// Select
|
|
||||||
s_pg.put("\\sFROM\\s+DUAL\\b", "");
|
|
||||||
|
|
||||||
// Statements
|
|
||||||
s_pg.put("\\bELSIF\\b", "ELSE IF");
|
|
||||||
// begin vpj-cd e-evolution 03/11/2005 PostgreSQL
|
|
||||||
s_pg.put("\\bREC \\b", "AS REC ");
|
|
||||||
//s_pg.put("\\bAND\\sROWNUM=\\b", "LIMIT ");
|
|
||||||
// end vpj-cd e-evolution 03/11/2005 PostgreSQL
|
|
||||||
|
|
||||||
// Sequences
|
|
||||||
s_pg.put("\\bSTART WITH\\b", "START");
|
|
||||||
s_pg.put("\\bINCREMENT BY\\b", "INCREMENT");
|
|
||||||
|
|
||||||
} // initPostgreSQL
|
|
||||||
|
|
||||||
} // ConvertMap
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* 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
|
|
@ -0,0 +1,78 @@
|
||||||
|
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
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
package org.compiere.dbPort;
|
||||||
|
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
public final class ConvertMap_PostgreSQL {
|
||||||
|
private static TreeMap<String,String> s_pg = new TreeMap<String,String>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return Map for PostgreSQL
|
||||||
|
* @return TreeMap with pattern as key and the replacement as value
|
||||||
|
*/
|
||||||
|
public static TreeMap getConvertMap()
|
||||||
|
{
|
||||||
|
if (s_pg.size() == 0)
|
||||||
|
initConvertMap();
|
||||||
|
return s_pg;
|
||||||
|
} // getConvertMap
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PostgreSQL Init
|
||||||
|
*/
|
||||||
|
static private void initConvertMap()
|
||||||
|
{
|
||||||
|
// Oracle Pattern Replacement
|
||||||
|
|
||||||
|
// Data Types
|
||||||
|
s_pg.put("\\bNUMBER\\b", "NUMERIC");
|
||||||
|
s_pg.put("\\bDATE\\b", "TIMESTAMP");
|
||||||
|
s_pg.put("\\bVARCHAR2\\b", "VARCHAR");
|
||||||
|
s_pg.put("\\bNVARCHAR2\\b", "VARCHAR");
|
||||||
|
s_pg.put("\\bNCHAR\\b", "CHAR");
|
||||||
|
//begin vpj-cd e-evolution 03/11/2005 PostgreSQL
|
||||||
|
s_pg.put("\\bBLOB\\b", "BYTEA"); // BLOB not directly supported
|
||||||
|
s_pg.put("\\bCLOB\\b", "BYTEA"); // CLOB not directly supported
|
||||||
|
s_pg.put("\\bLIMIT\\b","\"limit\"");
|
||||||
|
s_pg.put("\\bACTION\\b","\"action\"");
|
||||||
|
//s_pg.put("\\bBLOB\\b", "OID"); // BLOB not directly supported
|
||||||
|
//s_pg.put("\\bCLOB\\b", "OID"); // CLOB not directly supported
|
||||||
|
//end vpj-cd e-evolution 03/11/2005 PostgreSQL
|
||||||
|
|
||||||
|
// Storage
|
||||||
|
s_pg.put("\\bCACHE\\b", "");
|
||||||
|
s_pg.put("\\bUSING INDEX\\b", "");
|
||||||
|
s_pg.put("\\bTABLESPACE\\s\\w+\\b", "");
|
||||||
|
s_pg.put("\\bSTORAGE\\([\\w\\s]+\\)", "");
|
||||||
|
//
|
||||||
|
s_pg.put("\\bBITMAP INDEX\\b", "INDEX");
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
s_pg.put("\\bSYSDATE\\b", "CURRENT_TIMESTAMP"); // alternative: NOW()
|
||||||
|
//Bug fix, Gunther Hoppe 08.07.2005 e-evolution
|
||||||
|
//Begin ----------------------------------------------------------------------------------------
|
||||||
|
s_pg.put("\\bSysDate\\b", "CURRENT_TIMESTAMP");
|
||||||
|
s_pg.put("SysDate", "CURRENT_TIMESTAMP");
|
||||||
|
//end ----------------------------------------------------------------------------------------
|
||||||
|
//begin vpj-cd e-evolution 03/11/2005 PostgreSQL
|
||||||
|
s_pg.put("\\bDUMP\\b", "MD5");
|
||||||
|
s_pg.put("END CASE", "END");
|
||||||
|
s_pg.put("\\bgetDate()\\b", "CURRENT_TIMESTAMP"); // alternative: NOW()
|
||||||
|
//end vpj-cd e-evolution 03/11/2005 PostgreSQL
|
||||||
|
s_pg.put("\\bNVL\\b", "COALESCE");
|
||||||
|
s_pg.put("\\bTO_DATE\\b", "TO_TIMESTAMP");
|
||||||
|
//
|
||||||
|
s_pg.put("\\bDBMS_OUTPUT.PUT_LINE\\b", "RAISE NOTICE");
|
||||||
|
|
||||||
|
// Temporary
|
||||||
|
s_pg.put("\\bGLOBAL TEMPORARY\\b", "TEMPORARY");
|
||||||
|
s_pg.put("\\bON COMMIT DELETE ROWS\\b", "");
|
||||||
|
s_pg.put("\\bON COMMIT PRESERVE ROWS\\b", "");
|
||||||
|
|
||||||
|
//DDL
|
||||||
|
|
||||||
|
// begin vpj-cd e-evolution 08/02/2005 PostgreSQL
|
||||||
|
//s_pg.put("\\bMODIFY\\b","ALTER COLUMN");
|
||||||
|
//s_pg.put("\\bDEFAULT\\b","SET DEFAULT");
|
||||||
|
// end vpj-cd e-evolution 08/02/2005 PostgreSQL
|
||||||
|
|
||||||
|
// DROP TABLE x CASCADE CONSTRAINTS
|
||||||
|
s_pg.put("\\bCASCADE CONSTRAINTS\\b", "");
|
||||||
|
|
||||||
|
// Select
|
||||||
|
s_pg.put("\\sFROM\\s+DUAL\\b", "");
|
||||||
|
|
||||||
|
// Statements
|
||||||
|
s_pg.put("\\bELSIF\\b", "ELSE IF");
|
||||||
|
// begin vpj-cd e-evolution 03/11/2005 PostgreSQL
|
||||||
|
s_pg.put("\\bREC \\b", "AS REC ");
|
||||||
|
//s_pg.put("\\bAND\\sROWNUM=\\b", "LIMIT ");
|
||||||
|
// end vpj-cd e-evolution 03/11/2005 PostgreSQL
|
||||||
|
|
||||||
|
// Sequences
|
||||||
|
s_pg.put("\\bSTART WITH\\b", "START");
|
||||||
|
s_pg.put("\\bINCREMENT BY\\b", "INCREMENT");
|
||||||
|
|
||||||
|
} // initPostgreSQL
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package org.compiere.dbPort;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Convert_Oracle extends Convert {
|
||||||
|
|
||||||
|
public Convert_Oracle() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ArrayList<String> convertStatement(String sqlStatement) {
|
||||||
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
result.add(sqlStatement);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOracle() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,382 @@
|
||||||
|
package org.compiere.dbPort;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.Util;
|
||||||
|
|
||||||
|
public abstract class Convert_SQL92 extends Convert {
|
||||||
|
|
||||||
|
/** Logger */
|
||||||
|
private static CLogger log = CLogger.getCLogger (Convert_SQL92.class);
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Convert Outer Join.
|
||||||
|
* Converting joins can ve very complex when multiple tables/keys are involved.
|
||||||
|
* The main scenarios supported are two tables with multiple key columns
|
||||||
|
* and multiple tables with single key columns.
|
||||||
|
* <pre>
|
||||||
|
* SELECT a.Col1, b.Col2 FROM tableA a, tableB b WHERE a.ID=b.ID(+)
|
||||||
|
* => SELECT a.Col1, b.Col2 FROM tableA a LEFT OUTER JOIN tableB b ON (a.ID=b.ID)
|
||||||
|
*
|
||||||
|
* SELECT a.Col1, b.Col2 FROM tableA a, tableB b WHERE a.ID(+)=b.ID
|
||||||
|
* => SELECT a.Col1, b.Col2 FROM tableA a RIGHT OUTER JOIN tableB b ON (a.ID=b.ID)
|
||||||
|
* Assumptions:
|
||||||
|
* - No outer joins in sub queries (ignores sub-queries)
|
||||||
|
* - OR condition ignored (not sure what to do, should not happen)
|
||||||
|
* Limitations:
|
||||||
|
* - Parameters for outer joins must be first - as sequence of parameters changes
|
||||||
|
* </pre>
|
||||||
|
* @param sqlStatement
|
||||||
|
* @return converted statement
|
||||||
|
*/
|
||||||
|
protected String convertOuterJoin (String sqlStatement)
|
||||||
|
{
|
||||||
|
boolean trace = false;
|
||||||
|
//
|
||||||
|
int fromIndex = Util.findIndexOf (sqlStatement.toUpperCase(), " FROM ");
|
||||||
|
int whereIndex = Util.findIndexOf(sqlStatement.toUpperCase(), " WHERE ");
|
||||||
|
//begin vpj-cd e-evolution 03/14/2005 PostgreSQL
|
||||||
|
//int endWhereIndex = Util.findIndexOf(sqlStatement.toUpperCase(), " GRPUP BY ");
|
||||||
|
int endWhereIndex = Util.findIndexOf(sqlStatement.toUpperCase(), " GROUP BY ");
|
||||||
|
//end vpj-cd e-evolution 03/14/2005 PostgreSQL
|
||||||
|
if (endWhereIndex == -1)
|
||||||
|
endWhereIndex = Util.findIndexOf(sqlStatement.toUpperCase(), " ORDER BY ");
|
||||||
|
if (endWhereIndex == -1)
|
||||||
|
endWhereIndex = sqlStatement.length();
|
||||||
|
//
|
||||||
|
if (trace)
|
||||||
|
{
|
||||||
|
log.info("OuterJoin<== " + sqlStatement);
|
||||||
|
// log.info("From=" + fromIndex + ", Where=" + whereIndex + ", End=" + endWhereIndex + ", Length=" + sqlStatement.length());
|
||||||
|
}
|
||||||
|
//
|
||||||
|
String selectPart = sqlStatement.substring(0, fromIndex);
|
||||||
|
String fromPart = sqlStatement.substring(fromIndex, whereIndex);
|
||||||
|
String wherePart = sqlStatement.substring(whereIndex, endWhereIndex);
|
||||||
|
String rest = sqlStatement.substring(endWhereIndex);
|
||||||
|
|
||||||
|
// find/remove all (+) from WHERE clase ------------------------------
|
||||||
|
String newWherePart = wherePart;
|
||||||
|
ArrayList<String> joins = new ArrayList<String>();
|
||||||
|
int pos = newWherePart.indexOf("(+)");
|
||||||
|
while (pos != -1)
|
||||||
|
{
|
||||||
|
// find starting point
|
||||||
|
int start = newWherePart.lastIndexOf(" AND ", pos);
|
||||||
|
int startOffset = 5;
|
||||||
|
if (start == -1)
|
||||||
|
{
|
||||||
|
start = newWherePart.lastIndexOf(" OR ", pos);
|
||||||
|
startOffset = 4;
|
||||||
|
}
|
||||||
|
if (start == -1)
|
||||||
|
{
|
||||||
|
start = newWherePart.lastIndexOf("WHERE ", pos);
|
||||||
|
startOffset = 6;
|
||||||
|
}
|
||||||
|
if (start == -1)
|
||||||
|
{
|
||||||
|
String error = "Start point not found in clause " + wherePart;
|
||||||
|
log.severe(error);
|
||||||
|
m_conversionError = error;
|
||||||
|
return sqlStatement;
|
||||||
|
}
|
||||||
|
// find end point
|
||||||
|
int end = newWherePart.indexOf(" AND ", pos);
|
||||||
|
if (end == -1)
|
||||||
|
end = newWherePart.indexOf(" OR ", pos);
|
||||||
|
if (end == -1)
|
||||||
|
end = newWherePart.length();
|
||||||
|
// log.info("<= " + newWherePart + " - Start=" + start + "+" + startOffset + ", End=" + end);
|
||||||
|
|
||||||
|
// extract condition
|
||||||
|
String condition = newWherePart.substring(start+startOffset, end);
|
||||||
|
joins.add(condition);
|
||||||
|
if (trace)
|
||||||
|
log.info("->" + condition);
|
||||||
|
// new WHERE clause
|
||||||
|
newWherePart = newWherePart.substring(0, start) + newWherePart.substring(end);
|
||||||
|
// log.info("=> " + newWherePart);
|
||||||
|
//
|
||||||
|
pos = newWherePart.indexOf("(+)");
|
||||||
|
}
|
||||||
|
// correct beginning
|
||||||
|
newWherePart = newWherePart.trim();
|
||||||
|
if (newWherePart.startsWith("AND "))
|
||||||
|
newWherePart = "WHERE" + newWherePart.substring(3);
|
||||||
|
else if (newWherePart.startsWith("OR "))
|
||||||
|
newWherePart = "WHERE" + newWherePart.substring(2);
|
||||||
|
if (trace)
|
||||||
|
log.info("=> " + newWherePart);
|
||||||
|
|
||||||
|
// Correct FROM clause -----------------------------------------------
|
||||||
|
// Disassemble FROM
|
||||||
|
String[] fromParts = fromPart.trim().substring(4).split(",");
|
||||||
|
HashMap<String,String> fromAlias = new HashMap<String,String>(); // tables to be processed
|
||||||
|
HashMap<String,String> fromLookup = new HashMap<String,String>(); // used tabled
|
||||||
|
for (int i = 0; i < fromParts.length; i++)
|
||||||
|
{
|
||||||
|
String entry = fromParts[i].trim();
|
||||||
|
String alias = entry; // no alias
|
||||||
|
String table = entry;
|
||||||
|
int aPos = entry.lastIndexOf(' ');
|
||||||
|
if (aPos != -1)
|
||||||
|
{
|
||||||
|
alias = entry.substring(aPos+1);
|
||||||
|
table = entry.substring(0, entry.indexOf(' ')); // may have AS
|
||||||
|
}
|
||||||
|
fromAlias.put(alias, table);
|
||||||
|
fromLookup.put(alias, table);
|
||||||
|
if (trace)
|
||||||
|
log.info("Alias=" + alias + ", Table=" + table);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Single column
|
||||||
|
SELECT t.TableName, w.Name FROM AD_Table t, AD_Window w
|
||||||
|
WHERE t.AD_Window_ID=w.AD_Window_ID(+)
|
||||||
|
-- 275 rows
|
||||||
|
SELECT t.TableName, w.Name FROM AD_Table t
|
||||||
|
LEFT OUTER JOIN AD_Window w ON (t.AD_Window_ID=w.AD_Window_ID)
|
||||||
|
|
||||||
|
SELECT t.TableName, w.Name FROM AD_Table t, AD_Window w
|
||||||
|
WHERE t.AD_Window_ID(+)=w.AD_Window_ID
|
||||||
|
-- 239 rows
|
||||||
|
SELECT t.TableName, w.Name FROM AD_Table t
|
||||||
|
RIGHT OUTER JOIN AD_Window w ON (t.AD_Window_ID=w.AD_Window_ID)
|
||||||
|
|
||||||
|
** Multiple columns
|
||||||
|
SELECT tn.Node_ID,tn.Parent_ID,tn.SeqNo,tb.IsActive
|
||||||
|
FROM AD_TreeNode tn, AD_TreeBar tb
|
||||||
|
WHERE tn.AD_Tree_ID=tb.AD_Tree_ID(+) AND tn.Node_ID=tb.Node_ID(+)
|
||||||
|
AND tn.AD_Tree_ID=10
|
||||||
|
-- 235 rows
|
||||||
|
SELECT tn.Node_ID,tn.Parent_ID,tn.SeqNo,tb.IsActive
|
||||||
|
FROM AD_TreeNode tn LEFT OUTER JOIN AD_TreeBar tb
|
||||||
|
ON (tn.Node_ID=tb.Node_ID AND tn.AD_Tree_ID=tb.AD_Tree_ID AND tb.AD_User_ID=0)
|
||||||
|
WHERE tn.AD_Tree_ID=10
|
||||||
|
|
||||||
|
SELECT tn.Node_ID,tn.Parent_ID,tn.SeqNo,tb.IsActive
|
||||||
|
FROM AD_TreeNode tn, AD_TreeBar tb
|
||||||
|
WHERE tn.AD_Tree_ID=tb.AD_Tree_ID(+) AND tn.Node_ID=tb.Node_ID(+)
|
||||||
|
AND tn.AD_Tree_ID=10 AND tb.AD_User_ID(+)=0
|
||||||
|
-- 214 rows
|
||||||
|
SELECT tn.Node_ID,tn.Parent_ID,tn.SeqNo,tb.IsActive
|
||||||
|
FROM AD_TreeNode tn LEFT OUTER JOIN AD_TreeBar tb
|
||||||
|
ON (tn.Node_ID=tb.Node_ID AND tn.AD_Tree_ID=tb.AD_Tree_ID AND tb.AD_User_ID=0)
|
||||||
|
WHERE tn.AD_Tree_ID=10
|
||||||
|
|
||||||
|
*/
|
||||||
|
StringBuffer newFrom = new StringBuffer ();
|
||||||
|
for (int i = 0; i < joins.size(); i++)
|
||||||
|
{
|
||||||
|
Join first = new Join ((String)joins.get(i));
|
||||||
|
first.setMainTable((String)fromLookup.get(first.getMainAlias()));
|
||||||
|
fromAlias.remove(first.getMainAlias()); // remove from list
|
||||||
|
first.setJoinTable((String)fromLookup.get(first.getJoinAlias()));
|
||||||
|
fromAlias.remove(first.getJoinAlias()); // remove from list
|
||||||
|
if (trace)
|
||||||
|
log.info("-First: " + first);
|
||||||
|
//
|
||||||
|
if (newFrom.length() == 0)
|
||||||
|
newFrom.append(" FROM ");
|
||||||
|
else
|
||||||
|
newFrom.append(", ");
|
||||||
|
newFrom.append(first.getMainTable()).append(" ").append(first.getMainAlias())
|
||||||
|
.append(first.isLeft() ? " LEFT" : " RIGHT").append(" OUTER JOIN ")
|
||||||
|
.append(first.getJoinTable()).append(" ").append(first.getJoinAlias())
|
||||||
|
.append(" ON (").append(first.getCondition());
|
||||||
|
// keep it open - check for other key comparisons
|
||||||
|
for (int j = i+1; j < joins.size(); j++)
|
||||||
|
{
|
||||||
|
Join second = new Join ((String)joins.get(j));
|
||||||
|
second.setMainTable((String)fromLookup.get(second.getMainAlias()));
|
||||||
|
second.setJoinTable((String)fromLookup.get(second.getJoinAlias()));
|
||||||
|
if ((first.getMainTable().equals(second.getMainTable())
|
||||||
|
&& first.getJoinTable().equals(second.getJoinTable()))
|
||||||
|
|| second.isConditionOf(first) )
|
||||||
|
{
|
||||||
|
if (trace)
|
||||||
|
log.info("-Second/key: " + second);
|
||||||
|
newFrom.append(" AND ").append(second.getCondition());
|
||||||
|
joins.remove(j); // remove from join list
|
||||||
|
fromAlias.remove(first.getJoinAlias()); // remove from table list
|
||||||
|
//----
|
||||||
|
for (int k = i+1; k < joins.size(); k++)
|
||||||
|
{
|
||||||
|
Join third = new Join ((String)joins.get(k));
|
||||||
|
third.setMainTable((String)fromLookup.get(third.getMainAlias()));
|
||||||
|
third.setJoinTable((String)fromLookup.get(third.getJoinAlias()));
|
||||||
|
if (third.isConditionOf(second))
|
||||||
|
{
|
||||||
|
if (trace)
|
||||||
|
log.info("-Third/key: " + third);
|
||||||
|
newFrom.append(" AND ").append(third.getCondition());
|
||||||
|
joins.remove(k); // remove from join list
|
||||||
|
fromAlias.remove(third.getJoinAlias()); // remove from table list
|
||||||
|
}
|
||||||
|
else if (trace)
|
||||||
|
log.info("-Third/key-skip: " + third);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (trace)
|
||||||
|
log.info("-Second/key-skip: " + second);
|
||||||
|
}
|
||||||
|
newFrom.append(")"); // close ON
|
||||||
|
// check dependency on first table
|
||||||
|
for (int j = i+1; j < joins.size(); j++)
|
||||||
|
{
|
||||||
|
Join second = new Join ((String)joins.get(j));
|
||||||
|
second.setMainTable((String)fromLookup.get(second.getMainAlias()));
|
||||||
|
second.setJoinTable((String)fromLookup.get(second.getJoinAlias()));
|
||||||
|
if (first.getMainTable().equals(second.getMainTable()))
|
||||||
|
{
|
||||||
|
if (trace)
|
||||||
|
log.info("-Second/dep: " + second);
|
||||||
|
// FROM (AD_Field f LEFT OUTER JOIN AD_Column c ON (f.AD_Column_ID = c.AD_Column_ID))
|
||||||
|
// LEFT OUTER JOIN AD_FieldGroup fg ON (f.AD_FieldGroup_ID = fg.AD_FieldGroup_ID),
|
||||||
|
newFrom.insert(6, '('); // _FROM ...
|
||||||
|
newFrom.append(')'); // add parantesis on previous relation
|
||||||
|
//
|
||||||
|
newFrom.append(second.isLeft() ? " LEFT" : " RIGHT").append(" OUTER JOIN ")
|
||||||
|
.append(second.getJoinTable()).append(" ").append(second.getJoinAlias())
|
||||||
|
.append(" ON (").append(second.getCondition());
|
||||||
|
joins.remove(j); // remove from join list
|
||||||
|
fromAlias.remove(second.getJoinAlias()); // remove from table list
|
||||||
|
// additional join colums would come here
|
||||||
|
newFrom.append(")"); // close ON
|
||||||
|
//----
|
||||||
|
for (int k = i+1; k < joins.size(); k++)
|
||||||
|
{
|
||||||
|
Join third = new Join ((String)joins.get(k));
|
||||||
|
third.setMainTable((String)fromLookup.get(third.getMainAlias()));
|
||||||
|
third.setJoinTable((String)fromLookup.get(third.getJoinAlias()));
|
||||||
|
if (second.getJoinTable().equals(third.getMainTable()))
|
||||||
|
{
|
||||||
|
if (trace)
|
||||||
|
log.info("-Third-dep: " + third);
|
||||||
|
// FROM ((C_BPartner p LEFT OUTER JOIN AD_User c ON (p.C_BPartner_ID=c.C_BPartner_ID))
|
||||||
|
// LEFT OUTER JOIN C_BPartner_Location l ON (p.C_BPartner_ID=l.C_BPartner_ID))
|
||||||
|
// LEFT OUTER JOIN C_Location a ON (l.C_Location_ID=a.C_Location_ID)
|
||||||
|
newFrom.insert(6, '('); // _FROM ...
|
||||||
|
newFrom.append(')'); // add parantesis on previous relation
|
||||||
|
//
|
||||||
|
newFrom.append(third.isLeft() ? " LEFT" : " RIGHT").append(" OUTER JOIN ")
|
||||||
|
.append(third.getJoinTable()).append(" ").append(third.getJoinAlias())
|
||||||
|
.append(" ON (").append(third.getCondition());
|
||||||
|
joins.remove(k); // remove from join list
|
||||||
|
fromAlias.remove(third.getJoinAlias()); // remove from table list
|
||||||
|
// additional join colums would come here
|
||||||
|
newFrom.append(")"); // close ON
|
||||||
|
}
|
||||||
|
else if (trace)
|
||||||
|
log.info("-Third-skip: " + third);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (trace)
|
||||||
|
log.info("-Second/dep-skip: " + second);
|
||||||
|
} // dependency on first table
|
||||||
|
}
|
||||||
|
// remaining Tables
|
||||||
|
Iterator it = fromAlias.keySet().iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
Object alias = it.next();
|
||||||
|
Object table = fromAlias.get(alias);
|
||||||
|
newFrom.append(", ").append(table);
|
||||||
|
if (!table.equals(alias))
|
||||||
|
newFrom.append(" ").append(alias);
|
||||||
|
}
|
||||||
|
if (trace)
|
||||||
|
log.info(newFrom.toString());
|
||||||
|
//
|
||||||
|
StringBuffer retValue = new StringBuffer (sqlStatement.length()+20);
|
||||||
|
retValue.append(selectPart)
|
||||||
|
.append(newFrom).append(" ")
|
||||||
|
.append(newWherePart).append(rest);
|
||||||
|
//
|
||||||
|
if (trace)
|
||||||
|
log.info("OuterJoin==> " + retValue.toString());
|
||||||
|
return retValue.toString();
|
||||||
|
} // convertOuterJoin
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Converts Decode.
|
||||||
|
* <pre>
|
||||||
|
* DECODE (a, 1, 'one', 2, 'two', 'none')
|
||||||
|
* => CASE WHEN a = 1 THEN 'one' WHEN a = 2 THEN 'two' ELSE 'none' END
|
||||||
|
* </pre>
|
||||||
|
* @param sqlStatement
|
||||||
|
* @return converted statement
|
||||||
|
*/
|
||||||
|
protected String convertDecode(String sqlStatement)
|
||||||
|
{
|
||||||
|
// log.info("DECODE<== " + sqlStatement);
|
||||||
|
String statement = sqlStatement;
|
||||||
|
StringBuffer sb = new StringBuffer("CASE");
|
||||||
|
|
||||||
|
int index = statement.indexOf("DECODE");
|
||||||
|
String firstPart = statement.substring(0,index);
|
||||||
|
|
||||||
|
// find the opening (
|
||||||
|
index = statement.indexOf('(', index);
|
||||||
|
statement = statement.substring(index+1);
|
||||||
|
|
||||||
|
// find the expression "a" - find first , ignoring ()
|
||||||
|
index = Util.findIndexOf (statement, ',');
|
||||||
|
String expression = statement.substring(0, index).trim();
|
||||||
|
// log.info("Expression=" + expression);
|
||||||
|
|
||||||
|
// Pairs "1, 'one',"
|
||||||
|
statement = statement.substring(index+1);
|
||||||
|
index = Util.findIndexOf (statement, ',');
|
||||||
|
while (index != -1)
|
||||||
|
{
|
||||||
|
String first = statement.substring(0, index);
|
||||||
|
char cc = statement.charAt(index);
|
||||||
|
statement = statement.substring(index+1);
|
||||||
|
// log.info("First=" + first + ", Char=" + cc);
|
||||||
|
//
|
||||||
|
boolean error = false;
|
||||||
|
if (cc == ',')
|
||||||
|
{
|
||||||
|
index = Util.findIndexOf (statement, ',',')');
|
||||||
|
if (index == -1)
|
||||||
|
error = true;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String second = statement.substring(0, index);
|
||||||
|
sb.append(" WHEN ").append(expression).append("=").append(first.trim())
|
||||||
|
.append(" THEN ").append(second.trim());
|
||||||
|
// log.info(">>" + sb.toString());
|
||||||
|
statement = statement.substring(index+1);
|
||||||
|
index = Util.findIndexOf (statement, ',',')');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cc == ')')
|
||||||
|
{
|
||||||
|
sb.append(" ELSE ").append(first.trim()).append(" END");
|
||||||
|
// log.info(">>" + sb.toString());
|
||||||
|
index = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
error = true;
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "SQL=(" + sqlStatement
|
||||||
|
+ ")\n====Result=(" + sb.toString()
|
||||||
|
+ ")\n====Statement=(" + statement
|
||||||
|
+ ")\n====First=(" + first
|
||||||
|
+ ")\n====Index=" + index);
|
||||||
|
m_conversionError = "Decode conversion error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sb.append(statement);
|
||||||
|
sb.insert(0, firstPart);
|
||||||
|
// log.info("DECODE==> " + sb.toString());
|
||||||
|
return sb.toString();
|
||||||
|
} // convertDecode
|
||||||
|
}
|
|
@ -47,7 +47,7 @@ public final class DB
|
||||||
/** Connection Cache r/o */
|
/** Connection Cache r/o */
|
||||||
private static Connection[] s_connections = null;
|
private static Connection[] s_connections = null;
|
||||||
/** Connection Cache Size */
|
/** Connection Cache Size */
|
||||||
private static int s_conCacheSize = Ini.isClient() ? 3 : 3;
|
private static int s_conCacheSize = Ini.isClient() ? 1 : 3;
|
||||||
/** Connection counter */
|
/** Connection counter */
|
||||||
private static int s_conCount = 0;
|
private static int s_conCount = 0;
|
||||||
/** Connection r/w */
|
/** Connection r/w */
|
||||||
|
@ -231,12 +231,28 @@ public final class DB
|
||||||
s_cc = cc;
|
s_cc = cc;
|
||||||
s_connections = null;
|
s_connections = null;
|
||||||
s_connectionRW = null;
|
s_connectionRW = null;
|
||||||
|
s_connectionID = null;
|
||||||
}
|
}
|
||||||
s_cc.setDataSource();
|
s_cc.setDataSource();
|
||||||
log.config(s_cc + " - DS=" + s_cc.isDataSource());
|
log.config(s_cc + " - DS=" + s_cc.isDataSource());
|
||||||
// Trace.printStack();
|
// Trace.printStack();
|
||||||
} // setDBTarget
|
} // setDBTarget
|
||||||
|
|
||||||
|
public static boolean connect() {
|
||||||
|
boolean success =false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
success = getConnectionRW() != null;
|
||||||
|
if (success) success = getConnectionRO() != null;
|
||||||
|
if (success) success = getConnectionID() != null;
|
||||||
|
s_cc.readInfo(getConnectionRW());
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is there a connection to the database ?
|
* Is there a connection to the database ?
|
||||||
* @return true, if connected to database
|
* @return true, if connected to database
|
||||||
|
@ -661,6 +677,20 @@ public final class DB
|
||||||
log.log(Level.SEVERE, "R/W", e);
|
log.log(Level.SEVERE, "R/W", e);
|
||||||
}
|
}
|
||||||
s_connectionRW = null;
|
s_connectionRW = null;
|
||||||
|
|
||||||
|
//ID Connection
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (s_connectionID != null)
|
||||||
|
{
|
||||||
|
s_connectionID.close();
|
||||||
|
}
|
||||||
|
} catch (SQLException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "Id", e);
|
||||||
|
}
|
||||||
|
s_connectionID = null;
|
||||||
|
|
||||||
// CConnection
|
// CConnection
|
||||||
if (s_cc != null)
|
if (s_cc != null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue