Author: shawkins
Date: 2009-04-02 21:38:17 -0400 (Thu, 02 Apr 2009)
New Revision: 698
Removed:
trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCPlatformFactory.java
trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCURL.java
Modified:
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/ExtensionModuleManager.java
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleReader.java
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleTranslator.java
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleUtil.java
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleWriter.java
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/DBIDResourceTransaction.java
trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCPlatform.java
trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCConnector.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCRuntimeMetadataReader.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCTranslator.java
trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/ExtensionModuleConnection.java
trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataHelper.java
Log:
TEIID-456 removing db platform code
Modified:
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/ExtensionModuleManager.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/ExtensionModuleManager.java 2009-04-03
01:31:23 UTC (rev 697)
+++
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/ExtensionModuleManager.java 2009-04-03
01:38:17 UTC (rev 698)
@@ -815,7 +815,7 @@
/**
* Retrieves a checksum value for the contents of an extension module
*/
- private long getChecksum(byte[] data){
+ public static long getChecksum(byte[] data){
Checksum algorithm = new CRC32();
algorithm.update(data, 0, data.length);
return algorithm.getValue();
Modified:
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleReader.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleReader.java 2009-04-03
01:31:23 UTC (rev 697)
+++
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleReader.java 2009-04-03
01:38:17 UTC (rev 698)
@@ -37,7 +37,6 @@
import com.metamatrix.common.extensionmodule.ExtensionModuleDescriptor;
import com.metamatrix.common.extensionmodule.exception.ExtensionModuleNotFoundException;
import com.metamatrix.common.jdbc.JDBCPlatform;
-import com.metamatrix.common.jdbc.JDBCPlatformFactory;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.CommonPropertyNames;
import com.metamatrix.common.util.ErrorMessageKeys;
@@ -125,65 +124,9 @@
public static byte[] getSource(String sourceName, Connection jdbcConnection)
throws ExtensionModuleNotFoundException, MetaMatrixComponentException, SQLException
{
- //NOTE: DO NOT PUT LOGGING IN THIS METHOD
- // Because configuration initializes by getting the source
- // from the database prior to configuration properties being
- // available
-
- if (JDBCExtensionModuleUtil.isConfigurationModel(sourceName)) {
- return getConfigContent(sourceName, jdbcConnection);
- }
return getFileContent(sourceName, jdbcConnection);
}
-
-
- private static byte[] getConfigContent(String sourceName, Connection jdbcConnection)
- throws MetaMatrixComponentException, SQLException {
-
- String sql = null;
- PreparedStatement statement = null;
- ResultSet results = null;
- sql = JDBCExtensionModuleTranslator.SELECT_CONFIG_FILE_DATA_BY_NAME;
- JDBCPlatform platform = getPlatform(jdbcConnection);
-
- byte[] data = null;
-
- try{
-
-
- statement = jdbcConnection.prepareStatement(sql);
- statement.setString(1, sourceName);
-
- if ( ! statement.execute() ) {
- throw new MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0046,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0046, sql));
- }
- results = statement.getResultSet();
- try {
- if (results.next()) {
- data = platform.convertClobToByteArray(results,
JDBCNames.ExtensionFilesTable.ColumnName.CONFIG_CONTENTS);
- } else {
- throw new ExtensionModuleNotFoundException(sourceName);
- }
- } catch( Throwable e) {
- throw new MetaMatrixComponentException(e.getMessage());
- }
-
- } catch (SQLException se){
- throw se;
- } catch ( MetaMatrixComponentException e ) {
- throw e;
- } catch (Exception e) {
- throw new MetaMatrixComponentException(e, ErrorMessageKeys.EXTENSION_0047,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0047, sql));
- } finally {
- close(results);
- close(statement);
- }
-
- return data;
- }
-
-
/**
* Get file resource. Caches files in memory. Checks memory cache by checksum.
* If it's not in the cache or the checksum has changed, load from the DB.
@@ -203,16 +146,20 @@
CheckSumAndType csat = loadChecksumAndType(sourceName, jdbcConnection);
long checksum = csat.getChecksum();
String type = csat.getType();
- long cachedChecksum = fileCache.getChecksum(sourceName);
-
byte[] bytes = null;
- if (cachedChecksum == checksum) {
- bytes = fileCache.getBytes(sourceName);
- }
+ if (fileCache != null) {
+ long cachedChecksum = fileCache.getChecksum(sourceName);
+
+ if (cachedChecksum == checksum) {
+ bytes = fileCache.getBytes(sourceName);
+ }
+ }
if (bytes == null) {
bytes = loadBytes(sourceName, jdbcConnection);
- fileCache.put(sourceName, checksum, bytes, type);
+ if (fileCache != null) {
+ fileCache.put(sourceName, checksum, bytes, type);
+ }
}
return bytes;
@@ -304,9 +251,7 @@
byte[] data = null;
try{
- JDBCPlatform platform = JDBCPlatformFactory.getPlatform(jdbcConnection);
-
- data = platform.convertToByteArray(dataObj);
+ data = JDBCPlatform.convertToByteArray(dataObj);
} catch (Exception e) {
throw new MetaMatrixComponentException(e, ErrorMessageKeys.EXTENSION_0049,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0049));
@@ -528,22 +473,6 @@
}
}
- /**
- * Get the Platform for JDBC that is representive of the type of
- * connection.
- *
- * @since 4.2
- */
- private static JDBCPlatform getPlatform(Connection jdbcConnection) throws
MetaMatrixComponentException {
- try {
- return JDBCPlatformFactory.getPlatform(jdbcConnection);
-
- } catch(Exception e) {
- throw new MetaMatrixComponentException(e, ErrorMessageKeys.EXTENSION_0067,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0067));
- }
- }
-
-
public static ExtensionModuleDescriptor buildExtensionDescriptor (ResultSet
resultSet) throws MetaMatrixComponentException {
try{
ExtensionModuleDescriptor module = new ExtensionModuleDescriptor(
Modified:
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleTranslator.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleTranslator.java 2009-04-03
01:31:23 UTC (rev 697)
+++
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleTranslator.java 2009-04-03
01:38:17 UTC (rev 698)
@@ -108,16 +108,6 @@
+ JDBCNames.ExtensionFilesTable.ColumnName.FILE_NAME
+ PARAM
;
- public static final String SELECT_CONFIG_FILE_DATA_BY_NAME
- = SELECT
- +
JDBCNames.ExtensionFilesTable.ColumnName.CONFIG_CONTENTS
- + FROM
- + JDBCNames.ExtensionFilesTable.TABLE_NAME
- + WHERE
- + JDBCNames.ExtensionFilesTable.ColumnName.FILE_NAME
+ PARAM
- ;
-
-
public static final String SELECT_MAX_SEARCH_POSITION
= SELECT
+ MAX + OPEN_PAREN
@@ -231,23 +221,6 @@
+ VALUES
;
-
- public static final String ADD_CONFIG_FILE_DATA
- = INSERT + INTO +
JDBCNames.ExtensionFilesTable.TABLE_NAME + OPEN_PAREN
- + JDBCNames.ExtensionFilesTable.ColumnName.UID +
"," //$NON-NLS-1$
- +
JDBCNames.ExtensionFilesTable.ColumnName.CHECKSUM + "," //$NON-NLS-1$
- +
JDBCNames.ExtensionFilesTable.ColumnName.FILE_NAME + "," //$NON-NLS-1$
- +
JDBCNames.ExtensionFilesTable.ColumnName.SEARCH_POSITION + "," //$NON-NLS-1$
- +
JDBCNames.ExtensionFilesTable.ColumnName.IS_ENABLED + "," //$NON-NLS-1$
- +
JDBCNames.ExtensionFilesTable.ColumnName.FILE_DESCRIPTION + "," //$NON-NLS-1$
- +
JDBCNames.ExtensionFilesTable.ColumnName.CREATED_BY + "," //$NON-NLS-1$
- +
JDBCNames.ExtensionFilesTable.ColumnName.CREATION_DATE + "," //$NON-NLS-1$
- +
JDBCNames.ExtensionFilesTable.ColumnName.UPDATED_BY + "," //$NON-NLS-1$
- +
JDBCNames.ExtensionFilesTable.ColumnName.UPDATED + "," //$NON-NLS-1$
- +
JDBCNames.ExtensionFilesTable.ColumnName.FILE_TYPE + CLOSED_PAREN
- //+
JDBCNames.ExtensionFilesTable.ColumnName.CONFIG_CONTENTS + CLOSED_PAREN
- + VALUES
- ;
public static final String ADD_SOURCE_FILE_DATA_PARAMS
= "(?,?,?,?,?,?,?,?,?,?,?)";
//$NON-NLS-1$
public static final String ADD_SOURCE_FILE_DATA_ORACLE_PARAMS
@@ -264,42 +237,17 @@
+ WHERE
+
JDBCNames.ExtensionFilesTable.ColumnName.FILE_NAME + "= ? "; //$NON-NLS-1$
- public static final String UPDATE_SOURCE_CONFIG_DATA_DEFAULT
+ public static final String UPDATE_SOURCE_FILE_DATA_ORACLE
= UPDATE
+ JDBCNames.ExtensionFilesTable.TABLE_NAME + "
" //$NON-NLS-1$
+ SET
+
JDBCNames.ExtensionFilesTable.ColumnName.UPDATED_BY + "= ?, " //$NON-NLS-1$
+ JDBCNames.ExtensionFilesTable.ColumnName.UPDATED
+ "= ?, " //$NON-NLS-1$
+ JDBCNames.ExtensionFilesTable.ColumnName.CHECKSUM
+ "= ?, " //$NON-NLS-1$
- +
JDBCNames.ExtensionFilesTable.ColumnName.CONFIG_CONTENTS + "= ? " //$NON-NLS-1$
- + WHERE
- +
JDBCNames.ExtensionFilesTable.ColumnName.FILE_NAME + "= ? "; //$NON-NLS-1$
-
-
- public static final String UPDATE_SOURCE_CONFIG_DATA_ORACLE
- = UPDATE
- + JDBCNames.ExtensionFilesTable.TABLE_NAME + "
" //$NON-NLS-1$
- + SET
- +
JDBCNames.ExtensionFilesTable.ColumnName.UPDATED_BY + "= ?, " //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.UPDATED
+ "= ?, " //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.CHECKSUM
+ "= ?, " //$NON-NLS-1$
- +
JDBCNames.ExtensionFilesTable.ColumnName.CONFIG_CONTENTS + "= empty_clob() "
//$NON-NLS-1$
- + WHERE
- +
JDBCNames.ExtensionFilesTable.ColumnName.FILE_NAME + "= ? "; //$NON-NLS-1$
-
-
-
- public static final String UPDATE_SOURCE_FILE_DATA_ORACLE
- = UPDATE
- + JDBCNames.ExtensionFilesTable.TABLE_NAME + "
" //$NON-NLS-1$
- + SET
- +
JDBCNames.ExtensionFilesTable.ColumnName.UPDATED_BY + "= ?, " //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.UPDATED
+ "= ?, " //$NON-NLS-1$
- + JDBCNames.ExtensionFilesTable.ColumnName.CHECKSUM
+ "= ?, " //$NON-NLS-1$
+
JDBCNames.ExtensionFilesTable.ColumnName.FILE_CONTENTS + "= empty_blob() "
//$NON-NLS-1$
+ WHERE
+
JDBCNames.ExtensionFilesTable.ColumnName.FILE_NAME + "= ? "; //$NON-NLS-1$
-
+
public static final String UPDATE_SOURCE_NAME
= UPDATE
+ JDBCNames.ExtensionFilesTable.TABLE_NAME + "
" //$NON-NLS-1$
@@ -347,19 +295,5 @@
-//*******************************
-//
-// I N S E R T S Q L
-//
-//*******************************
-
-
-
- // ---------------------------------------------------------------------------------
- // TRANSLATE RESULT SETS
- // ---------------------------------------------------------------------------------
-
-
-
}
Modified:
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleUtil.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleUtil.java 2009-04-03
01:31:23 UTC (rev 697)
+++
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleUtil.java 2009-04-03
01:38:17 UTC (rev 698)
@@ -33,19 +33,15 @@
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Properties;
-import java.util.Set;
-import java.util.zip.CRC32;
-import java.util.zip.Checksum;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.CommonPlugin;
import com.metamatrix.common.config.JDBCConnectionPoolHelper;
-import com.metamatrix.common.config.api.Configuration;
import com.metamatrix.common.extensionmodule.ExtensionModuleDescriptor;
+import com.metamatrix.common.extensionmodule.ExtensionModuleManager;
import
com.metamatrix.common.extensionmodule.exception.DuplicateExtensionModuleException;
import com.metamatrix.common.extensionmodule.exception.ExtensionModuleNotFoundException;
import com.metamatrix.common.util.ByteArrayHelper;
@@ -56,14 +52,6 @@
private static final String PRINCIPAL = "JDBCExtensionUtil"; //$NON-NLS-1$
- private static Set configurationNames;
-
- static {
- configurationNames = new HashSet();
- configurationNames.add(Configuration.NEXT_STARTUP);
- }
-
-
private Properties properties;
/**
* Instantiates this class with any Properties that need to override
@@ -221,9 +209,9 @@
}
if (inuse) {
- JDBCExtensionModuleWriter.setSource(PRINCIPAL, extName, data,
getChecksum(data), connection);
+ JDBCExtensionModuleWriter.setSource(PRINCIPAL, extName, data,
ExtensionModuleManager.getChecksum(data), connection);
} else {
- JDBCExtensionModuleWriter.addSource(PRINCIPAL, extType, extName,
data, getChecksum(data), extDesc, true, connection);
+ JDBCExtensionModuleWriter.addSource(PRINCIPAL, extType, extName,
data, ExtensionModuleManager.getChecksum(data), extDesc, true, connection);
}
} catch (MetaMatrixComponentException mce) {
@@ -251,32 +239,6 @@
}
- public static boolean isConfigurationModel(String sourceName) {
- return configurationNames.contains(sourceName);
- }
-
- /**
- * Adds an element to the list of filenames considered to be configuration models
- * (and therefore stored as clobs).
- *
- * @since 4.2
- */
- static void addConfigurationModelName(String sourceName) {
- configurationNames.add(sourceName);
- }
-
- /**
- * Removes an element from the list of filenames considered to be configuration
models
- * (and therefore stored as clobs).
- *
- * @since 4.2
- */
- static void removeConfigurationModelName(String sourceName) {
- configurationNames.remove(sourceName);
- }
-
-
-
public void importExtensionModule(String importFileName, String extName, String
extType, String extDesc, String position)
throws ExtensionModuleNotFoundException, DuplicateExtensionModuleException,
MetaMatrixComponentException{
importExtensionModule(importFileName, extName, extType, extDesc);
@@ -388,22 +350,4 @@
}
-
-
-
- /**
- * this checksum method is the same as the one in ExtensionMangaer
- *
- * @param data
- * @return
- */
- private long getChecksum(byte[] data){
- Checksum algorithm = new CRC32();
- algorithm.update(data, 0, data.length);
- return algorithm.getValue();
- }
-
-
-
-
}
Modified:
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleWriter.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleWriter.java 2009-04-03
01:31:23 UTC (rev 697)
+++
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleWriter.java 2009-04-03
01:38:17 UTC (rev 698)
@@ -22,7 +22,7 @@
package com.metamatrix.common.extensionmodule.spi.jdbc;
-import java.io.IOException;
+import java.io.ByteArrayInputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -39,8 +39,6 @@
import com.metamatrix.common.extensionmodule.exception.ExtensionModuleNotFoundException;
import com.metamatrix.common.extensionmodule.exception.ExtensionModuleOrderingException;
import com.metamatrix.common.id.dbid.DBIDGenerator;
-import com.metamatrix.common.jdbc.JDBCPlatform;
-import com.metamatrix.common.jdbc.JDBCPlatformFactory;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.ErrorMessageKeys;
import com.metamatrix.common.util.LogCommonConstants;
@@ -134,23 +132,16 @@
PreparedStatement statement = null;
- String sql = null;
+ String sql = JDBCExtensionModuleTranslator.ADD_SOURCE_FILE_DATA;
ExtensionModuleDescriptor descriptor = null;
description = StringUtil.truncString(description, MAX_DESC_LEN);
int position = getNextPosition(jdbcConnection);
- boolean isConfigModel =
JDBCExtensionModuleUtil.isConfigurationModel(sourceName);
boolean orignalAutocommit=true;
boolean firstException = false;
try{
- if (isConfigModel) {
- sql = JDBCExtensionModuleTranslator.ADD_CONFIG_FILE_DATA;
- } else {
- sql = JDBCExtensionModuleTranslator.ADD_SOURCE_FILE_DATA;
- }
-
long longUID =
DBIDGenerator.getInstance().getID(JDBCNames.ExtensionFilesTable.TABLE_NAME);
orignalAutocommit=jdbcConnection.getAutoCommit();
@@ -185,13 +176,8 @@
throw new
MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0054,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0054, sourceName,sql));
}
- if (isConfigModel) {
- updateConfig(updatedBy, sourceName, data, checksum, jdbcConnection,
JDBCExtensionModuleTranslator.UPDATE_SOURCE_CONFIG_DATA_DEFAULT);
- } else {
- updateFile(updatedBy, sourceName, data, checksum, jdbcConnection,
JDBCExtensionModuleTranslator.UPDATE_SOURCE_FILE_DATA_ORACLE);
- }
+ updateFile(updatedBy, sourceName, data, checksum, jdbcConnection,
JDBCExtensionModuleTranslator.UPDATE_SOURCE_FILE_DATA_ORACLE);
-
jdbcConnection.commit();
} catch (SQLException se){
@@ -246,243 +232,36 @@
public static void setSource(String principalName, String sourceName, byte[] data,
long checksum, Connection jdbcConnection)
throws ExtensionModuleNotFoundException, MetaMatrixComponentException{
-
- if (JDBCExtensionModuleUtil.isConfigurationModel(sourceName)) {
- updateConfig(principalName, sourceName, data, checksum, jdbcConnection,
JDBCExtensionModuleTranslator.UPDATE_SOURCE_CONFIG_DATA_DEFAULT);
- } else {
- updateFile(principalName, sourceName, data, checksum, jdbcConnection,
JDBCExtensionModuleTranslator.UPDATE_SOURCE_FILE_DATA_ORACLE);
- }
-
+ updateFile(principalName, sourceName, data, checksum, jdbcConnection,
JDBCExtensionModuleTranslator.UPDATE_SOURCE_FILE_DATA_ORACLE);
}
- private static void updateConfig(String principalName, String sourceName, byte[]
data, long checksum, Connection jdbcConnection, String sql)
- throws ExtensionModuleNotFoundException, MetaMatrixComponentException{
-
-
- LogManager.logTrace(CONTEXT, "setting extension module file " +
sourceName + " containing # bytes: " + data.length); //$NON-NLS-1$
//$NON-NLS-2$
- JDBCPlatform platform = getPlatform(jdbcConnection);
-
- PreparedStatement statement = null;
- boolean original_autocommit = true;
- try{
- original_autocommit = jdbcConnection.getAutoCommit();
- // Oracle specific handling
- if(platform.usesStreamsForClobBinding()) {
-
- jdbcConnection.setAutoCommit(false);
-
-
- sql = JDBCExtensionModuleTranslator.UPDATE_SOURCE_CONFIG_DATA_ORACLE;
- statement = jdbcConnection.prepareStatement(sql);
-
- statement.setString(1, principalName);
- statement.setString(2, DateUtil.getCurrentDateAsString());
- statement.setLong(3, checksum);
- statement.setString(4, sourceName);
-
-
- if (statement.executeUpdate() != 1){
- if (!JDBCExtensionModuleReader.isNameInUse(sourceName,
jdbcConnection)){
- throw new
ExtensionModuleNotFoundException(CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0059,
sourceName));
- }
- throw new
MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0065,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0065, sql));
- }
-
- statement.close();
-
- sql = JDBCExtensionModuleTranslator.SELECT_CONFIG_FILE_DATA_BY_NAME;
- sql = sql + " FOR UPDATE"; //$NON-NLS-1$
-
- statement = jdbcConnection.prepareStatement(sql);
-
- statement.setString(1, sourceName);
-
- if ( ! statement.execute() ) {
- //already checked if name wasn't in use above, shouldn't be a
problem here
- throw new
MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0072,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0072, sourceName,sql));
- }
-
- ResultSet results = statement.getResultSet();
- try {
- if ( results.next() ) {
- // the inputstream is closed in the oracle implementation
- platform.setClob(results, data,
JDBCNames.ExtensionFilesTable.ColumnName.CONFIG_CONTENTS);
-
- jdbcConnection.commit();
- } else {
- throw new
MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0064,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0064,sourceName));
- }
- } catch (SQLException se){
- try {
- jdbcConnection.rollback();
- } catch (SQLException sr) {
- // do nothing
- }
- throw se;
- } finally {
- if( results != null) {
- try {
- results.close();
- } catch(SQLException e) {
- LogManager.logWarning(CONTEXT, e,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0073));
- }
- }
-
- try {
- jdbcConnection.setAutoCommit(original_autocommit);
- } catch (SQLException sr) {
- // do nothing
- }
-
- }
-
-
-
- } else {
- statement = jdbcConnection.prepareStatement(sql);
-
- statement.setString(1, principalName);
- statement.setString(2, DateUtil.getCurrentDateAsString());
- statement.setLong(3, checksum);
-
- platform.setClob(statement, data, 4);
-
- statement.setString(5, sourceName);
- int r = statement.executeUpdate();
-
- if (r != 1){
- if (!JDBCExtensionModuleReader.isNameInUse(sourceName,
jdbcConnection)){
- throw new
ExtensionModuleNotFoundException(CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0059,
sourceName));
- }
- throw new
MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0065,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0065, sql));
- }
-
- }
- } catch (SQLException se){
-
- //check if name is in use
- if (!JDBCExtensionModuleReader.isNameInUse(sourceName, jdbcConnection)){
- throw new ExtensionModuleNotFoundException(sourceName);
- }
- throw new MetaMatrixComponentException(se, ErrorMessageKeys.EXTENSION_0065,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0065, sql));
-
- } catch (IOException e) {
- throw new MetaMatrixComponentException(e, ErrorMessageKeys.EXTENSION_0065,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0065, sql));
- } finally {
- if ( statement != null ) {
- try {
- statement.close();
- statement = null;
- } catch ( SQLException e ) {
- LogManager.logWarning(CONTEXT, e,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0048));
- }
- }
-
- }
-
- }
-
private static void updateFile(String principalName, String sourceName, byte[] data,
long checksum, Connection jdbcConnection, String sql)
throws ExtensionModuleNotFoundException, MetaMatrixComponentException{
LogManager.logTrace(CONTEXT, "setting extension module file " +
sourceName + " containing # bytes: " + data.length); //$NON-NLS-1$
//$NON-NLS-2$
- JDBCPlatform platform = getPlatform(jdbcConnection);
PreparedStatement statement = null;
ResultSet results = null;
- boolean original_autocommit = true;
try{
- original_autocommit = jdbcConnection.getAutoCommit();
- // Oracle specific handling
- if(platform.usesStreamsForClobBinding()) {
-
- jdbcConnection.setAutoCommit(false);
-
- statement = jdbcConnection.prepareStatement(sql);
+ sql = JDBCExtensionModuleTranslator.UPDATE_SOURCE_FILE_DATA_DEFAULT;
+ statement = jdbcConnection.prepareStatement(sql);
- statement.setString(1, principalName);
- statement.setString(2, DateUtil.getCurrentDateAsString());
- statement.setLong(3, checksum);
- statement.setString(4, sourceName);
-
- if (statement.executeUpdate() != 1) {
- if (!JDBCExtensionModuleReader.isNameInUse(sourceName,
jdbcConnection)){
- throw new
ExtensionModuleNotFoundException(CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0059,
sourceName));
- }
- throw new
MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0060,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0060, sourceName,sql));
- }
- LogManager.logTrace(CONTEXT, "SUCCESS-reset Blob: " + sql);
//$NON-NLS-1$
+ statement.setString(1, principalName);
+ statement.setString(2, DateUtil.getCurrentDateAsString());
+ statement.setLong(3, checksum);
+
+ statement.setBinaryStream(4, new ByteArrayInputStream(data), data.length);
+
+ // DBstatement.setBytes(4, data);
+ statement.setString(5, sourceName);
- statement.close();
-
- sql = JDBCExtensionModuleTranslator.SELECT_SOURCE_FILE_DATA_BY_NAME;
- sql = sql + " FOR UPDATE"; //$NON-NLS-1$
- statement = jdbcConnection.prepareStatement(sql);
-
- statement.setString(1, sourceName);
-
- if ( ! statement.execute() ) {
- //already checked if name wasn't in use above, shouldn't be a
problem here
- throw new
MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0062,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0062, sourceName,sql));
+ if (statement.executeUpdate() != 1){
+ if (!JDBCExtensionModuleReader.isNameInUse(sourceName, jdbcConnection)){
+ throw new
ExtensionModuleNotFoundException(CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0059,
sourceName));
}
-
- try {
-
- results = statement.getResultSet();
- if ( results.next() ) {
-
- platform.setBlob(results, data,
JDBCNames.ExtensionFilesTable.ColumnName.FILE_CONTENTS);
- jdbcConnection.commit();
-
- } else {
- throw new
MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0064,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0064,sourceName));
- }
- } catch (SQLException se){
- try {
- jdbcConnection.rollback();
- } catch (SQLException sr) {
- // do nothing
- }
- throw se;
- } finally {
- if( results != null) {
- try {
- results.close();
- } catch(SQLException e) {
- LogManager.logWarning(CONTEXT, e,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0073));
- }
- }
-
- try {
- jdbcConnection.setAutoCommit(original_autocommit);
- } catch (SQLException sr) {
- // do nothing
- }
-
- }
-
-
- } else {
- sql = JDBCExtensionModuleTranslator.UPDATE_SOURCE_FILE_DATA_DEFAULT;
- statement = jdbcConnection.prepareStatement(sql);
-
- statement.setString(1, principalName);
- statement.setString(2, DateUtil.getCurrentDateAsString());
- statement.setLong(3, checksum);
-
- platform.setBlob(statement, data, 4);
-
- // DBstatement.setBytes(4, data);
- statement.setString(5, sourceName);
-
- if (statement.executeUpdate() != 1){
- if (!JDBCExtensionModuleReader.isNameInUse(sourceName,
jdbcConnection)){
- throw new
ExtensionModuleNotFoundException(CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0059,
sourceName));
- }
- throw new
MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0065,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0065, sql));
- }
- }
+ throw new MetaMatrixComponentException(ErrorMessageKeys.EXTENSION_0065,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0065, sql));
+ }
} catch (SQLException se){
//check if name is in use
@@ -491,8 +270,6 @@
}
throw new MetaMatrixComponentException(se, ErrorMessageKeys.EXTENSION_0065,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0065, sql));
- } catch (IOException e) {
- throw new MetaMatrixComponentException(e, ErrorMessageKeys.EXTENSION_0065,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0065, sql));
} finally {
if ( statement != null ) {
try {
@@ -716,19 +493,6 @@
}
-
-
-
- private static JDBCPlatform getPlatform(Connection jdbcConnection) throws
MetaMatrixComponentException {
- try {
- return JDBCPlatformFactory.getPlatform(jdbcConnection);
-
- } catch(Exception e) {
- throw new MetaMatrixComponentException(e, ErrorMessageKeys.EXTENSION_0067,
CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0067));
- }
- }
-
-
/**
* Deletes a module from the list of modules
* @param principalName name of principal requesting this addition
Modified:
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/DBIDResourceTransaction.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/DBIDResourceTransaction.java 2009-04-03
01:31:23 UTC (rev 697)
+++
trunk/server/src/main/java/com/metamatrix/common/id/dbid/spi/jdbc/DBIDResourceTransaction.java 2009-04-03
01:38:17 UTC (rev 698)
@@ -36,7 +36,6 @@
import com.metamatrix.common.id.dbid.ReservedIDBlock;
import com.metamatrix.common.id.dbid.spi.DBIDSourceTransaction;
import com.metamatrix.common.jdbc.JDBCPlatform;
-import com.metamatrix.common.jdbc.JDBCPlatformFactory;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.ErrorMessageKeys;
import com.metamatrix.common.util.LogCommonConstants;
@@ -47,8 +46,6 @@
public class DBIDResourceTransaction extends BaseTransaction implements
DBIDSourceTransaction {
private Connection jdbcConnection;
- private JDBCPlatform platform=null;
-
// private static long columnMax=-1;
private static long columnMax=999999999;
@@ -74,8 +71,6 @@
JDBCMgdResourceConnection jdbcManagedConnection = (JDBCMgdResourceConnection)
connection;
jdbcConnection = jdbcManagedConnection.getConnection();
- platform = JDBCPlatformFactory.getPlatform(jdbcConnection);
-
} catch ( Exception e ) {
throw new ManagedConnectionException(e,ErrorMessageKeys.ID_ERR_0016,
CommonPlugin.Util.getString(ErrorMessageKeys.ID_ERR_0016));
}
@@ -261,7 +256,7 @@
if (columnMax > -1) return;
- int s = platform.getDatabaseColumnSize(JDBCNames.IDTable.TABLE_NAME,
+ int s = JDBCPlatform.getDatabaseColumnSize(JDBCNames.IDTable.TABLE_NAME,
JDBCNames.IDTable.ColumnName.NEXT_ID,
jdbcConnection);
// Map columns = platform.getDatabaseColumns(JDBCNames.IDTable.TABLE_NAME,
jdbcConnection);
Modified: trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCPlatform.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCPlatform.java 2009-04-03
01:31:23 UTC (rev 697)
+++ trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCPlatform.java 2009-04-03
01:38:17 UTC (rev 698)
@@ -22,1072 +22,220 @@
package com.metamatrix.common.jdbc;
-import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.sql.Blob;
-import java.sql.Clob;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.jdbc.metadata.Column;
-import com.metamatrix.common.jdbc.metadata.Table;
-import com.metamatrix.common.jdbc.metadata.UniqueKey;
-import com.metamatrix.common.jdbc.syntax.ExpressionOperator;
import com.metamatrix.common.types.TransformationException;
import com.metamatrix.common.util.ErrorMessageKeys;
-import com.metamatrix.core.util.ReflectionHelper;
-/**
-* The JDBCPlatform represents a single datasource connection. The
-* default platform is that of MetaMatrix. Use the JDBCPlatformFactory
-* to create a JDBCPlatform that is representive of the type of
-* connection.
-*/
+public class JDBCPlatform {
-public class JDBCPlatform implements Serializable, Cloneable {
-
- // temporarily stored so that other methods can be initialized
- private DatabaseMetaData metadata;
-
- /** Indicates that streams will be used to store BLOB data. NOTE: does not work
with ODBC */
- protected boolean usesStreamsForBlobBinding;
- protected boolean usesStreamsForClobBinding;
- protected boolean isSecure=false;
-
- // this is the product name from the metedata, if it can be determined;
- private String platformName;
-
- /** Holds a hashtable of values used to map JAVA types to database types for table
creation */
- protected transient Map fieldTypes;
-
- protected transient String[] tableTypes;
-
- /** Operators specific to this platform */
- protected transient Map platformOperators;
- protected transient Map classTypes;
- protected transient Map minimumValues;
- protected transient Map maximumValues;
-
- protected static final String SPACE = " "; //$NON-NLS-1$
- protected static final String COMMA = ", "; //$NON-NLS-1$
- protected static final String PARAM = "?"; //$NON-NLS-1$
- protected static final String PERIOD = "."; //$NON-NLS-1$
-
- protected static final String INSERT_INTO = JDBCReservedWords.INSERT + SPACE +
JDBCReservedWords.INTO + SPACE;
- protected static final String DELETE_FROM = JDBCReservedWords.DELETE + SPACE +
JDBCReservedWords.FROM + SPACE;
- protected static final String UPDATE = JDBCReservedWords.UPDATE + SPACE;
- protected static final String SELECT = JDBCReservedWords.SELECT + SPACE;
- protected static final String EQUAL = " = "; //$NON-NLS-1$
- protected static final String FROM = SPACE + JDBCReservedWords.FROM + SPACE;
- protected static final String WHERE = SPACE + JDBCReservedWords.WHERE + SPACE;
- protected static final String ORDER_BY = SPACE + JDBCReservedWords.ORDER_BY +
SPACE;
- protected static final String GROUP_BY = SPACE + "GROUP BY" + SPACE;
//$NON-NLS-1$
- protected static final String SET = SPACE + JDBCReservedWords.SET + SPACE;
- protected static final String ON = SPACE + JDBCReservedWords.ON + SPACE;
- protected static final String INTO = SPACE + JDBCReservedWords.INTO + SPACE;
- protected static final String IN = SPACE + JDBCReservedWords.IN + SPACE;
-// protected static final String INNER_JOIN = SPACE + JDBCReservedWords.INNER_JOIN +
SPACE;
- protected static final String DISTINCT = SPACE + JDBCReservedWords.DISTINCT +
SPACE;
- protected static final String VALUES = SPACE + JDBCReservedWords.VALUES +
SPACE;
- protected static final String AND = SPACE + JDBCReservedWords.AND + SPACE;
- protected static final String LENGTH = SPACE + "LEN"; //$NON-NLS-1$
-
- public interface TableTypes {
- public static final String TABLE = "TABLE"; //$NON-NLS-1$
- public static final String VIEW = "VIEW"; //$NON-NLS-1$
- public static final String SYSTEM_TABLE = "SYSTEM TABLE";
//$NON-NLS-1$
- public static final String GLOBAL_TEMPORARY = "GLOBAL TEMPORARY";
//$NON-NLS-1$
- public static final String LOCAL_TEMPORARY = "LOCAL TEMPORARY";
//$NON-NLS-1$
- public static final String ALIAS = "ALIAS"; //$NON-NLS-1$
- public static final String SYNONYM = "SYNONYM"; //$NON-NLS-1$
- }
-
- protected JDBCPlatform () {
- usesStreamsForBlobBinding = false;
- tableTypes = null;
- }
-
- public void setConnection(Connection conn) throws MetaMatrixException {
-
- try {
- metadata = conn.getMetaData();
- getTableTypes();
- metadata = null;
- } catch (SQLException sqle){
- throw new MetaMatrixException(sqle);
- }
- }
-
- public boolean isClosed(Connection connection) {
- try {
- return connection.isClosed();
- } catch(SQLException e) {
- return true;
- }
- }
-
- public void setIsSecure(boolean secure) {
- this.isSecure = secure;
- }
-
- public void setPlatformName(String platformName) {
- this.platformName = platformName;
- }
-
- public String getPlatformName() {
- return platformName;
- }
-
- public boolean isOracle() {
- return false;
- }
-
- public boolean isDefault() {
- return true;
- }
-
- public boolean isMetaMatrix() {
- return false;
- }
-
- public boolean isDB2() {
- return false;
- }
-
- public boolean isSybase() {
- return false;
- }
-
- public boolean isMSSQL() {
- return false;
- }
-
- public boolean isMYSQL() {
- return false;
- }
-
- public boolean isInformix() {
- return false;
- }
-
- public boolean isDerby() {
- return false;
- }
-
- public boolean isPostgres() {
- return false;
- }
-
- public boolean isSecure() {
- return isSecure;
- }
-
- public boolean usesStreamsForBlobBinding() {
- return usesStreamsForBlobBinding;
- }
-
- public boolean usesStreamsForClobBinding() {
- return usesStreamsForClobBinding;
- }
-
- public int setBlob(ResultSet results, byte[] data, String columnName) throws
SQLException, IOException {
- Blob blob = results.getBlob(columnName);
- OutputStream l_blobOutputStream = null;
-
- ByteArrayInputStream bais = new ByteArrayInputStream(data);
- InputStream is = new BufferedInputStream(bais);
-
- try {
- ReflectionHelper helper = new ReflectionHelper(blob.getClass());
- final Object[] args = new Object[]{};
- final Method m =
helper.findBestMethodOnTarget("getBinaryOutputStream",args); //$NON-NLS-1$
-
- l_blobOutputStream = (OutputStream) m.invoke(blob,args);
- byte[] l_buffer = new byte[10* 1024];
-
- int cnt = is.available();
-
- int l_nread = 0; // Number of bytes read
- while ((l_nread= is.read(l_buffer)) != -1) { // Read from file
- l_blobOutputStream.write(l_buffer,0,l_nread); // Write to BLOB
- }
-
- return cnt;
- } catch (Exception nsme) {
- throw new IOException(nsme.getMessage());
- } finally {
- // Close both streams
- if( is != null) {
- is.close();
- is = null;
- }
- if( l_blobOutputStream != null) {
- l_blobOutputStream.close();
- l_blobOutputStream = null;
- }
- }
- }
-
- public void setBlob(PreparedStatement statement, byte[] data, int column) throws
SQLException, IOException {
-
- statement.setBytes(column, data);
- }
-
- public void setClob(ResultSet results, byte[] data, String columnName) throws
SQLException, IOException {
- ByteArrayInputStream bais = new ByteArrayInputStream(data);
- BufferedInputStream is = new BufferedInputStream(bais);
-
- setClob(results, is, columnName);
- }
-
- public void setClob(ResultSet results, InputStream is, String columnName) throws
SQLException, IOException {
-
- OutputStream l_clobOutputStream = null;
-
- Clob clob = results.getClob(columnName);
- try {
- ReflectionHelper helper = new ReflectionHelper(clob.getClass());
- final Object[] args = new Object[]{};
- final Method m =
helper.findBestMethodOnTarget("getAsciiOutputStream",args); //$NON-NLS-1$
-
- l_clobOutputStream = (OutputStream) m.invoke(clob,args);
-
- byte[] l_buffer = new byte[10* 1024];
-
-// int cnt = is.available();
-
- int l_nread = 0; // Number of bytes read
- while ((l_nread= is.read(l_buffer)) != -1) { // Read from file
- l_clobOutputStream.write(l_buffer,0,l_nread); // Write to BLOB
-
- }
- return;
-// return cnt;
- } catch (Exception nsme) {
- nsme.printStackTrace();
- throw new IOException(nsme.getMessage());
- } finally {
- // Close both streams
- if( is != null) {
- is.close();
- is = null;
- }
- if( l_clobOutputStream != null) {
- l_clobOutputStream.close();
- l_clobOutputStream = null;
- }
- }
- }
-
-
-
- public void setClob(PreparedStatement statement, byte[] data, int column) throws
SQLException, IOException {
-
- ByteArrayInputStream bais = new ByteArrayInputStream(data);
- BufferedInputStream is = new BufferedInputStream(bais);
-
- statement.setAsciiStream(column, is, is.available());
- }
-
-
-
- /**
- * This will create an select statement that can be used
- * to select rows.
- * @param tableMetadata the definition of the table in which
- * columns will be used to create the select statement.
- */
-
- public String createSelectStatement( Table tableMetadata) {
- return createSelectStatement(tableMetadata, null);
-
- }
-
- public String createSelectStatement( Table tableMetadata, String tablePrefix) {
- return createSelectStatement(tableMetadata, tablePrefix, null);
- }
-
- /**
- * Create the select SQL string based on the table metadata. If the
- * table prefix is passed, then prefix the table with this value.
- * Also, if the where columns are passed the sql will build a
- * WHERE clause containing parameters for each column
- * @param tabelMetadata is the table that drives the sql statement
- * @param tablePrefix is a prefix to add to the table; optional and nullable
- * @param whereColumns are columns to use in the where clause; optional and nullable
- */
- public String createSelectStatement(Table tableMetadata, String tablePrefix, Column[]
whereColumns) {
- StringBuffer sql = new StringBuffer();
- sql.append(SELECT);
-
- Collection columns = tableMetadata.getColumns();
-
- String columnString = buildCommaSeperatedColumns(columns);
- sql.append(columnString);
- sql.append(FROM);
-
- if (tablePrefix != null && tablePrefix.length() > 0) {
- sql.append(tablePrefix);
- sql.append("."); //$NON-NLS-1$
- } else {
- sql.append(" "); //$NON-NLS-1$
- }
-
- sql.append(tableMetadata.getFullName());
-
- if (whereColumns != null) {
- String whereClause = buildWhereParameterClause(whereColumns);
- sql.append(SPACE);
- sql.append(whereClause);
- }
-
- return sql.toString();
- }
-
- /**
- * This will create an insert statement that can be used
- * to insert rows using a PreparedStatement.
- * @param tableMetadata the definition of the table in which
- * records are to be updated; may not be null;
- */
- public String createInsertStatement( Table tableMetadata ) {
- return createInsertStatement(tableMetadata, ""); //$NON-NLS-1$
- }
-
- public String createInsertStatement( Table tableMetadata, String tablePrefix) {
-
- StringBuffer sql = new StringBuffer();
- sql.append(INSERT_INTO);
-
- if (tablePrefix != null && tablePrefix.length() > 0) {
- sql.append(tablePrefix);
- sql.append("."); //$NON-NLS-1$
- }
- sql.append(tableMetadata.getFullName());
- sql.append(" " + JDBCReservedWords.LEFT_PAREN); //$NON-NLS-1$
- Collection columns = tableMetadata.getColumns();
-
- String columnString = buildCommaSeperatedColumns(columns);
-/*
- for (Iterator cit=columns.iterator(); cit.hasNext(); i++) {
- Column column = (Column) cit.next();
- sql.append(column.getFullName());
- if (i < size) {
- sql.append(COMMA);
- }
- }
-*/
- sql.append(columnString);
- int size = columns.size();
- sql.append(JDBCReservedWords.RIGHT_PAREN);
- sql.append(VALUES);
- sql.append(JDBCReservedWords.LEFT_PAREN);
- for(int k=1;k<=size;k++){
- sql.append(PARAM);
- if(k < size){
- sql.append(COMMA);
- }
- }
- sql.append(JDBCReservedWords.RIGHT_PAREN);
- return sql.toString();
- }
-
- /**
- * This will create an insert statement that will contain the actual values to
- * be inserted into the table.
- * @param tableMetadata the definition of the table in which
- * records are to be updated; may not be null;
- * @param values to be inserted
- */
- public String createInsertStatement( Table tableMetadata, String[] values ) {
- return ""; //$NON-NLS-1$
- }
-
/**
- * Obtain the statement that can be used to update records
- * in a table using a PreparedStatement.
- * @param tableMetadata the definition of the table in which
- * records are to be updated; may not be null;
+ * These are the platforms supported
*/
- public String createUpdateStatement( Table tableMetadata ) {
- return createUpdateStatement(tableMetadata, null);
- }
+ public enum Supported {
+ ORACLE,
+ SYBASE,
+ DB2,
+ MSSQL,
+ INFORMIX,
+ METAMATRIX,
+ MM_ORACLE,
+ MYSQL,
+ POSTGRES,
+ DEFAULT,
+ DERBY
+ }
- /**
- * Obtain the statement which will contain the actual data values
- * to update records in a table.
- * @param tableMetadata the definition of the table in which
- * records are to be updated; may not be null;
- * @param values to be inserted
- */
- public String createUpdateStatement( Table tableMetadata, String[] values ) {
- StringBuffer sql = new StringBuffer();
- sql.append(UPDATE);
-
- sql.append(tableMetadata.getFullName());
-
- if (values == null) {
- String setClause =
buildSetParmClause(tableMetadata.getColumns().toArray());
- sql.append(setClause);
- } else {
- //TODO Not coded yet to build the set clause with the
- // values.
- return "NEED TO UPDATE method createUpdateStatement";
//$NON-NLS-1$
- }
-
- if (!tableMetadata.getUniqueKeys().isEmpty()) {
- String whereClause =
buildWhereUsingUiqueKeys(tableMetadata.getUniqueKeys());
- sql.append(SPACE);
- sql.append(whereClause);
-
- }
-
- return sql.toString();
-
- }
-
-
- protected String buildSetParmClause(Object[] setColumns) {
-
- StringBuffer sql = new StringBuffer();
- sql.append(SET);
-
- int size = setColumns.length;
-
- for(int k=0;k<size;k++){
- Column col = (Column) setColumns[k];
- sql.append(col.getName());
- sql.append(EQUAL);
- sql.append(PARAM);
- if(k < size - 1){
- sql.append(COMMA);
- }
- }
-
- return sql.toString();
-
- }
-
-
- protected String buildWhereUsingUiqueKeys(Collection uniqueKeys) {
-
- StringBuffer sql = new StringBuffer();
- sql.append(WHERE);
-
- int size = uniqueKeys.size();
- int k=0;
- for (Iterator it=uniqueKeys.iterator(); it.hasNext(); k++) {
- UniqueKey key = (UniqueKey) it.next();
- sql.append(key.getName());
- sql.append(EQUAL);
- sql.append(PARAM);
- if(k < size - 1){
- sql.append(AND);
- }
- }
-
- return sql.toString();
-
- }
-
/**
- * Obtain the statement that may be used to delete records
- * from a table with the specified metadata.
- * @param tableMetadata the definition of the table from which
- * records are to be deleted; may not be null;
+ * The use of platforms is a secondary search option in case the supported
+ * platforms don't match to the product name
*/
- public String createDeleteStatement( Table table ) {
- return createDeleteStatement(table, null);
- }
+ protected interface Protocol {
+ public static final String MSSQL = "mssql"; //$NON-NLS-1$
+ public static final String SQLSERVER = "sqlserver"; //$NON-NLS-1$
+ public static final String ORACLE = "oracle"; //$NON-NLS-1$
+ public static final String DB2 = "db2"; //$NON-NLS-1$
+ public static final String SYBASE = "sybase"; //$NON-NLS-1$
+ public static final String INFORMIX = "informix-sqli"; //$NON-NLS-1$
+ public static final String METAMATRIX = "metamatrix"; //$NON-NLS-1$
+ public static final String MM_ORACLE = "mmx:oracle"; //$NON-NLS-1$
+ public static final String DERBY = "derby"; //$NON-NLS-1$
+ public static final String MYSQL = "mysql"; //$NON-NLS-1$
+ public static final String POSTGRES = "postgres"; //$NON-NLS-1$
- public String createDeleteStatement( Table table, String tablePrefix) {
- if (tablePrefix != null && tablePrefix.length() > 0) {
- return DELETE_FROM + tablePrefix + "." + table.getName();
//$NON-NLS-1$
- }
- return DELETE_FROM+ table.getName();
- }
+ }
- public String createDeleteStatement( Table table, Column[] whereColumns, String
tablePrefix) {
- String prefix;
- if (tablePrefix != null && tablePrefix.length() > 0) {
- prefix = DELETE_FROM + tablePrefix + "." + table.getName();
//$NON-NLS-1$
- } else {
- prefix = DELETE_FROM+ table.getName();
- }
+ public static Supported getSupportedByProtocol(String value) {
+ // System.out.println("==== Look for platform by product " + value);
+ String lower = value.toLowerCase();
- StringBuffer sql = new StringBuffer(prefix);
+ if (lower.indexOf(Protocol.METAMATRIX) >= 0) {
+ return Supported.METAMATRIX;
+ } else if (lower.indexOf(Protocol.MM_ORACLE) >= 0) {
+ return Supported.MM_ORACLE;
+ } else if (lower.indexOf(Protocol.MSSQL) >= 0
+ || lower.indexOf(Protocol.SQLSERVER) >= 0) {
+ return Supported.MSSQL;
+ } else if (lower.indexOf(Protocol.DB2) >= 0) {
+ return Supported.DB2;
+ } else if (lower.indexOf(Protocol.ORACLE) >= 0) {
+ return Supported.ORACLE;
+ } else if (lower.indexOf(Protocol.SYBASE) >= 0) {
+ return Supported.SYBASE;
+ } else if (lower.indexOf(Protocol.INFORMIX) >= 0) {
+ return Supported.INFORMIX;
+ } else if (lower.indexOf(Protocol.DERBY) >= 0) {
+ return Supported.DERBY;
+ } else if (lower.indexOf(Protocol.MYSQL) >= 0) {
+ return Supported.MYSQL;
+ } else if (lower.indexOf(Protocol.POSTGRES) >= 0) {
+ return Supported.POSTGRES;
+ }
- if (whereColumns != null) {
- String whereClause = buildWhereParameterClause(whereColumns);
- sql.append(SPACE);
- sql.append(whereClause);
- }
+ return null;
+ }
- return sql.toString();
- }
+ public static byte[] convertToByteArray(Object sourceObject)
+ throws TransformationException {
+ if (sourceObject instanceof byte[]) {
+ return (byte[]) sourceObject;
+ } else if (sourceObject instanceof java.sql.Clob) {
+ return convertToByteArray((java.sql.Clob) sourceObject);
+ } else if (sourceObject instanceof java.sql.Blob) {
+ return convertToByteArray((java.sql.Blob) sourceObject);
+ } else {
+ throw new TransformationException(ErrorMessageKeys.JDBC_ERR_0001,
+ CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0001,
+ sourceObject.getClass().getName()));
+ }
+ }
+ protected static byte[] convertToByteArray(java.sql.Blob sourceObject)
+ throws TransformationException {
- public String createTruncateStatement( String tablename ) {
- return createTruncateStatement(tablename, null);
- }
+ try {
- public String createTruncateStatement( String tablename , String tablePrefix) {
- if (tablePrefix != null && tablePrefix.length() > 0) {
- return DELETE_FROM + tablePrefix + "." + tablename; //$NON-NLS-1$
- }
+ // long size = sourceObject.length();
+ // System.out.println("@@@@@@@@@@ Blob to bytes: " + size);
- return DELETE_FROM + tablename;
- }
+ // Open a stream to read the BLOB data
+ InputStream l_blobStream = sourceObject.getBinaryStream();
- public int getMaxFieldNameSize() {
- return 50;
- }
+ // Open a file stream to save the BLOB data
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ BufferedOutputStream bos = new BufferedOutputStream(out);
- public String[] getTableTypes() throws MetaMatrixException {
- if (tableTypes != null) {
- return tableTypes;
- }
+ // Read from the BLOB data input stream, and write to the file
+ // output
+ // stream
+ byte[] l_buffer = new byte[1024]; // buffer holding bytes to be
+ // transferred
+ int l_nbytes = 0; // Number of bytes read
+ while ((l_nbytes = l_blobStream.read(l_buffer)) != -1)
+ // Read from BLOB stream
+ bos.write(l_buffer, 0, l_nbytes); // Write to file stream
- Set tableTypesSet = new HashSet();
- try {
- ResultSet tableTypesResults = metadata.getTableTypes();
- while ( tableTypesResults.next() ) {
- tableTypesSet.add(tableTypesResults.getString(1).trim());
- }
- } catch ( SQLException e ){
- throw new MetaMatrixException(e);
-// errorMessages.add("Error using 'getTableTypes': " +
e.getMessage());
- }
+ // Flush and close the streams
+ bos.flush();
+ bos.close();
+ l_blobStream.close();
- tableTypes = new String[tableTypesSet.size()];
- int index = -1;
- Iterator iter = tableTypesSet.iterator();
- while ( iter.hasNext() ) {
- tableTypes[++index] = iter.next().toString();
- }
+ return out.toByteArray();
- return tableTypes;
- }
+ } catch (IOException ioe) {
+ throw new TransformationException(ioe,
+ ErrorMessageKeys.JDBC_ERR_0002, CommonPlugin.Util
+ .getString(ErrorMessageKeys.JDBC_ERR_0002,
+ sourceObject.getClass().getName()));
+ } catch (SQLException sqe) {
+ throw new TransformationException(sqe,
+ ErrorMessageKeys.JDBC_ERR_0002, CommonPlugin.Util
+ .getString(ErrorMessageKeys.JDBC_ERR_0002,
+ sourceObject.getClass().getName()));
+ }
- public Map getClassTypes()
- {
- if (classTypes == null)
- classTypes = buildClassTypes();
- return classTypes;
- }
+ }
- public Map getFieldTypes() {
- if (fieldTypes == null)
- fieldTypes = buildFieldTypes();
- return fieldTypes;
- }
+ protected static byte[] convertToByteArray(java.sql.Clob sourceObject)
+ throws TransformationException {
- /**
- * Call to determine what is the maximum value allowed for the
- * current database platform.
- * @param clazz is the java object data type that is of type Number
- * @return Number that represents the maximum value allowed on the
- * current database platform.
- */
- public synchronized Number getMaximumValue(Class clazz) {
- if (clazz == null) return null;
+ try {
- if (maximumValues == null) {
- maximumValues = maximumNumericValues();
- }
+ // long size = sourceObject.length();
+ // System.out.println("@@@@@@@@@@ Blob to bytes: " + size);
- Object obj = maximumValues.get(clazz);
- if (obj != null) {
- return (Number) obj;
- }
- return null;
- }
+ // Open a stream to read the BLOB data
+ InputStream l_clobStream = sourceObject.getAsciiStream();
- /**
- * Call to determine what is the minimum value allowed for the
- * current database platform.
- * @param clazz is the java object data type that is of type Number
- * @return Number that represents the minimum value allowed on the
- * current database platform.
- */
- public synchronized Number getMinimumValue(Class clazz) {
- if (clazz == null) return null;
+ // Open a file stream to save the BLOB data
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ BufferedOutputStream bos = new BufferedOutputStream(out);
- if (minimumValues == null) {
- minimumValues = minimumNumericValues();
- }
+ // Read from the BLOB data input stream, and write to the file
+ // output
+ // stream
+ byte[] l_buffer = new byte[1024]; // buffer holding bytes to be
+ // transferred
+ int l_nbytes = 0; // Number of bytes read
+ while ((l_nbytes = l_clobStream.read(l_buffer)) != -1)
+ // Read from BLOB stream
+ bos.write(l_buffer, 0, l_nbytes); // Write to file stream
- Object obj = minimumValues.get(clazz);
- if (obj != null) {
- return (Number) obj;
- }
- return null;
- }
+ // Flush and close the streams
+ bos.flush();
+ bos.close();
+ l_clobStream.close();
+ return out.toByteArray();
- public ExpressionOperator getOperator(String name) {
- return (ExpressionOperator) getPlatformOperators().get(name);
- }
+ } catch (IOException ioe) {
+ throw new TransformationException(ioe,
+ ErrorMessageKeys.JDBC_ERR_0002, CommonPlugin.Util
+ .getString(ErrorMessageKeys.JDBC_ERR_0002,
+ sourceObject.getClass().getName()));
+ } catch (SQLException sqe) {
+ throw new TransformationException(sqe,
+ ErrorMessageKeys.JDBC_ERR_0002, CommonPlugin.Util
+ .getString(ErrorMessageKeys.JDBC_ERR_0002,
+ sourceObject.getClass().getName()));
+ }
+ }
-/**
- * Return any platform-specific operators
- */
- public synchronized Map getPlatformOperators() {
- if (platformOperators == null)
- platformOperators = buildPlatformOperators();
- return platformOperators;
- }
+ public static int getDatabaseColumnSize(String tableName,
+ String columnName, Connection jdbcConnection) throws SQLException {
+ DatabaseMetaData dbMetadata = jdbcConnection.getMetaData();
+ String catalogName = jdbcConnection.getCatalog();
+ ResultSet columns = dbMetadata.getColumns(catalogName, null, tableName,
+ "%"); //$NON-NLS-1$
+ int s = -1;
+ while (columns.next()) {
+ String nis = columns.getString(4);
+ if (columnName.equals(nis)) {
+ s = columns.getInt(7);
+ }
- void initializePlatform() {
- }
-
- protected Map buildClassTypes() {
- HashMap types = new HashMap();
- return types;
- }
-
- protected Map buildFieldTypes() {
- HashMap types = new HashMap();
- return types;
- }
-
- protected void addOperator(ExpressionOperator op)
- {
- for (Iterator it=op.getSelectors().iterator(); it.hasNext(); ) {
- platformOperators.put(it.next(), op);
- }
- }
-
- protected Map buildPlatformOperators() {
-
- this.platformOperators = new Hashtable();
-
- // Ordering
- addOperator(ExpressionOperator.ascending());
- addOperator(ExpressionOperator.descending());
-
- // String
- addOperator(ExpressionOperator.toUpperCase());
- addOperator(ExpressionOperator.toLowerCase());
- addOperator(ExpressionOperator.maximum());
- addOperator(ExpressionOperator.minimum());
-
-// addOperator(ExpressionOperator.chr());
-// addOperator(ExpressionOperator.concat());
-// addOperator(ExpressionOperator.hexToRaw());
-// addOperator(ExpressionOperator.initcap());
-// addOperator(ExpressionOperator.instring());
-// addOperator(ExpressionOperator.leftPad());
-// addOperator(ExpressionOperator.leftTrim());
-// addOperator(ExpressionOperator.replace());
-// addOperator(ExpressionOperator.rightPad());
-// addOperator(ExpressionOperator.rightTrim());
-// addOperator(ExpressionOperator.substring());
-// addOperator(ExpressionOperator.toNumber());
-// addOperator(ExpressionOperator.translate());
-// addOperator(ExpressionOperator.trim());
-// addOperator(ExpressionOperator.ascii());
-
- // Date
-// addOperator(ExpressionOperator.addMonths());
-// addOperator(ExpressionOperator.dateToString());
-// addOperator(ExpressionOperator.lastDay());
-// addOperator(ExpressionOperator.monthsBetween());
-// addOperator(ExpressionOperator.nextDay());
-// addOperator(ExpressionOperator.roundDate());
-// addOperator(ExpressionOperator.toDate());
-
- // Math
- addOperator(ExpressionOperator.sum());
- addOperator(ExpressionOperator.count());
- addOperator(ExpressionOperator.average());
-
-// addOperator(ExpressionOperator.ceil());
-// addOperator(ExpressionOperator.cos());
-// addOperator(ExpressionOperator.cosh());
-// addOperator(ExpressionOperator.abs());
-// addOperator(ExpressionOperator.acos());
-// addOperator(ExpressionOperator.asin());
-// addOperator(ExpressionOperator.atan());
-// addOperator(ExpressionOperator.exp());
-// addOperator(ExpressionOperator.floor());
-// addOperator(ExpressionOperator.ln());
-// addOperator(ExpressionOperator.log());
-// addOperator(ExpressionOperator.mod());
-// addOperator(ExpressionOperator.power());
-// addOperator(ExpressionOperator.round());
-// addOperator(ExpressionOperator.sign());
-// addOperator(ExpressionOperator.sin());
-// addOperator(ExpressionOperator.sinh());
-// addOperator(ExpressionOperator.tan());
-// addOperator(ExpressionOperator.tanh());
-// addOperator(ExpressionOperator.trunc());
-
- // Object-relational
-// addOperator(ExpressionOperator.deref());
-// addOperator(ExpressionOperator.ref());
-// addOperator(ExpressionOperator.refToHex());
-// addOperator(ExpressionOperator.refToValue());
-
- // Other
-// addOperator(ExpressionOperator.greatest());
-// addOperator(ExpressionOperator.least());
-
- // ?
- addOperator(ExpressionOperator.today());
-
- return platformOperators;
-
-
- }
-
- /**
- * Builds a table of maximum numeric values keyed on java class. This is used for type
testing but
- * might also be useful to end users attempting to sanitize values.
- * <p><b>NOTE</b>: BigInteger & BigDecimal maximums are dependent
upon their precision & Scale
- */
- public Map maximumNumericValues()
- {
- Map values = new HashMap(1);
-/*
- values.put(Integer.class, new Integer(Integer.MAX_VALUE));
- values.put(Long.class, new Long(Long.MAX_VALUE));
- values.put(Double.class, new Double(Double.MAX_VALUE));
- values.put(Short.class, new Short(Short.MAX_VALUE));
- values.put(Byte.class, new Byte(Byte.MAX_VALUE));
- values.put(Float.class, new Float(Float.MAX_VALUE));
- values.put(java.math.BigInteger.class, new
java.math.BigInteger("999999999999999999999999999999999999999")); //$NON-NLS-1$
- values.put(java.math.BigDecimal.class, new
java.math.BigDecimal("99999999999999999999.9999999999999999999"));
//$NON-NLS-1$
-*/
- return values;
+ }
+ return s;
}
- /**
- * Builds a table of minimum numeric values keyed on java class. This is used for type
testing but
- * might also be useful to end users attempting to sanitize values.
- * <p><b>NOTE</b>: BigInteger & BigDecimal minimums are dependent
upon their precision & Scale
- */
- public Map minimumNumericValues()
- {
- Map values = new HashMap(1);
-/*
- values.put(Integer.class, new Integer(Integer.MIN_VALUE));
- values.put(Long.class, new Long(Long.MIN_VALUE));
- values.put(Double.class, new Double(Double.MIN_VALUE));
- values.put(Short.class, new Short(Short.MIN_VALUE));
- values.put(Byte.class, new Byte(Byte.MIN_VALUE));
- values.put(Float.class, new Float(Float.MIN_VALUE));
- values.put(java.math.BigInteger.class, new
java.math.BigInteger("-99999999999999999999999999999999999999")); //$NON-NLS-1$
- values.put(java.math.BigDecimal.class, new
java.math.BigDecimal("-9999999999999999999.9999999999999999999"));
//$NON-NLS-1$
-*/
- return values;
+ public static String getIdentifierQuoteString(Connection connection)
+ throws SQLException {
+ String quote = connection.getMetaData().getIdentifierQuoteString();
+ if (quote == null || quote.equals(" ")) { //$NON-NLS-1$
+ return ""; //$NON-NLS-1$
+ }
+ return quote;
}
- public byte[] convertToByteArray(Object sourceObject) throws TransformationException{
- if (sourceObject instanceof byte[]) {
- return (byte[]) sourceObject;
- } else if(sourceObject instanceof java.sql.Clob) {
- return convertToByteArray( (java.sql.Clob) sourceObject);
- } else if (sourceObject instanceof java.sql.Blob) {
- return convertToByteArray( (java.sql.Blob) sourceObject);
- } else {
- throw new TransformationException(ErrorMessageKeys.JDBC_ERR_0001,
CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0001,
sourceObject.getClass().getName()));
- }
- }
-
- protected byte[] convertToByteArray(java.sql.Blob sourceObject) throws
TransformationException{
-
- try {
-
-// long size = sourceObject.length();
-// System.out.println("@@@@@@@@@@ Blob to bytes: " + size);
-
- // Open a stream to read the BLOB data
- InputStream l_blobStream = sourceObject.getBinaryStream();
-
- // Open a file stream to save the BLOB data
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- BufferedOutputStream bos = new BufferedOutputStream(out);
-
- // Read from the BLOB data input stream, and write to the file output
- // stream
- byte[] l_buffer = new byte[1024]; // buffer holding bytes to be transferred
- int l_nbytes = 0; // Number of bytes read
- while ((l_nbytes = l_blobStream.read(l_buffer)) != -1) // Read from BLOB
stream
- bos.write(l_buffer,0,l_nbytes); // Write to file stream
-
- // Flush and close the streams
- bos.flush();
- bos.close();
- l_blobStream.close();
-
- return out.toByteArray();
-
- } catch (IOException ioe) {
- throw new TransformationException(ioe, ErrorMessageKeys.JDBC_ERR_0002,
CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0002,
sourceObject.getClass().getName()));
- } catch (SQLException sqe) {
- throw new TransformationException(sqe, ErrorMessageKeys.JDBC_ERR_0002,
CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0002,
sourceObject.getClass().getName()));
-
- }
-
- }
-
-
-
- public byte[] convertClobToByteArray(ResultSet results, String columName) throws
TransformationException{
- byte[] data = null;
- Clob clobResults = null;
- try {
- if(usesStreamsForClobBinding()) {
- clobResults = results.getClob(columName);
- if (clobResults != null) {
- data = convertToByteArray(clobResults);
- }
- } else {
- String s = results.getString(columName);
- data = s.getBytes();
-
- }
-// } catch (IOException ioe) {
-// throw new TransformationException(ioe, ErrorMessageKeys.JDBC_ERR_0002,
CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0002, columName));
- } catch (SQLException sqe) {
- throw new TransformationException(sqe, ErrorMessageKeys.JDBC_ERR_0002,
CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0002, columName));
-
- }
-
- return data;
-
-
- }
-
- protected byte[] convertToByteArray(java.sql.Clob sourceObject) throws
TransformationException{
-
- try {
-
-// long size = sourceObject.length();
-// System.out.println("@@@@@@@@@@ Blob to bytes: " + size);
-
- // Open a stream to read the BLOB data
- InputStream l_clobStream = sourceObject.getAsciiStream();
-
- // Open a file stream to save the BLOB data
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- BufferedOutputStream bos = new BufferedOutputStream(out);
-
- // Read from the BLOB data input stream, and write to the file output
- // stream
- byte[] l_buffer = new byte[1024]; // buffer holding bytes to be transferred
- int l_nbytes = 0; // Number of bytes read
- while ((l_nbytes = l_clobStream.read(l_buffer)) != -1) // Read from BLOB
stream
- bos.write(l_buffer,0,l_nbytes); // Write to file stream
-
- // Flush and close the streams
- bos.flush();
- bos.close();
- l_clobStream.close();
-
- return out.toByteArray();
-
- } catch (IOException ioe) {
- throw new TransformationException(ioe, ErrorMessageKeys.JDBC_ERR_0002,
CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0002,
sourceObject.getClass().getName()));
- } catch (SQLException sqe) {
- throw new TransformationException(sqe, ErrorMessageKeys.JDBC_ERR_0002,
CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0002,
sourceObject.getClass().getName()));
-
- }
- }
-
- /**
- * Takes a columns of Columns and returns a comma seperated string
- */
- protected String buildCommaSeperatedColumns(Collection columns) {
- StringBuffer sql = new StringBuffer();
- int i=1;
- int size = columns.size();
- for (Iterator cit=columns.iterator(); cit.hasNext(); i++) {
- Column column = (Column) cit.next();
- sql.append(column.getName());
- if (i < size) {
- sql.append(COMMA);
- }
- }
-
- return sql.toString();
-
- }
-
- protected String buildWhereParameterClause(Column[] whereColumns) {
-
- StringBuffer sql = new StringBuffer();
- sql.append(WHERE);
-
- int size = whereColumns.length;
-
- for(int k=0;k<size;k++){
- Column col = whereColumns[k];
- sql.append(col.getName());
- sql.append(EQUAL);
- sql.append(PARAM);
- if(k < size - 1){
- sql.append(AND);
- }
- }
-
- return sql.toString();
-
- }
-
- public int getDatabaseColumnSize(String tableName, String columnName, Connection
jdbcConnection) throws SQLException {
- DatabaseMetaData dbMetadata = jdbcConnection.getMetaData();
- String catalogName = jdbcConnection.getCatalog();
-
- ResultSet columns = dbMetadata.getColumns(catalogName, null, tableName,
"%"); //$NON-NLS-1$
- int s = -1;
- while ( columns.next() ) {
- String nis = columns.getString(4);
- if (columnName.equals(nis) ) {
- s = columns.getInt(7);
- }
-
- }
- return s;
- }
-
-// public Map getDatabaseColumns(String tableName, Connection jdbcConnection) throws
SQLException {
-// Map table = new HashMap();
-//
-// DatabaseMetaData dbMetadata = jdbcConnection.getMetaData();
-// String catalogName = jdbcConnection.getCatalog();
-//// String schemaName = jdbcConnection.getMetaData().getSchemaTerm();
-//
-// ResultSet columns = dbMetadata.getColumns(catalogName, null, tableName,
"%"); //$NON-NLS-1$
-//
-// while ( columns.next() ) {
-//
-// // Assume that the catalog, schema and table name all match ...
-// DatabaseColumn column = new DatabaseColumn( columns.getString(4) );
-// column.setDataType( columns.getShort(5) );
-// column.setDataTypeName( columns.getString(6) );
-// column.setSize( columns.getInt(7) );
-// //column.( columns.getShort(8) ); // buffer length is not used
-// column.setDecimalDigits( columns.getInt(9) );
-// column.setRadix( columns.getInt(10) );
-//// column.setNullability( Nullability.getInstance( columns.getInt(11) )
);
-// column.setRemarks( columns.getString(12) );
-// column.setDefaultValue( columns.getString(13) );
-// //column.( columns.getInt(14) ); // current unused
-// //column.( columns.getInt(15) ); // current unused
-// column.setCharOctetLength( columns.getInt(16) );
-// column.setPosition( columns.getInt(17) );
-// //column.( columns.getString(18) ); // nullability string
-//
-// table.put(column.getNameInSource(), column);
-// }
-//
-// return table;
-// }
-
-
- public List parseToExecutableStatements(BufferedReader reader, String delimiter)
throws SQLException {
-
- StringBuffer buffer = new StringBuffer();
- LinkedList listOfStatements = new LinkedList();
-
- try {
- List remove = getNonExecutableDelimiters();
- while (reader.ready()) {
- String line = reader.readLine();
- if(line == null) {
- // End of stream
- break;
- }
-
- line = line.trim();
- boolean doNotRemove=true;
- // check if the line starts with a nonexecutable delimiter
- // if so, then the line is not included
- if (line == null || line.length() == 0) {
- continue;
- }
- String UCASELINE = line.toUpperCase();
- for (Iterator it=remove.iterator(); it.hasNext();) {
- String removeItem = (String) it.next();
- if (UCASELINE.startsWith(removeItem)) {
- // line is to not be included in the statement list
- // i.e., it may be a comment
- doNotRemove=false;
- break;
- }
- }
-
- if (doNotRemove) {
- if (line.endsWith(delimiter)) {
- int x = line.lastIndexOf(delimiter);
- buffer.append(line.substring(0, x ));
- listOfStatements.add(buffer);
- buffer = new StringBuffer();
- } else {
- buffer.append(line + SPACE);
-
- }
-
- }
-
-
- }
-
- } catch(Exception e) {
- throw new SQLException(e.getMessage());
- }
-
- return listOfStatements;
-
- }
-
- /**
- * These nonexecutable delimiters are words or symbols that
- * cannot be excuted via an execute statement. These generally
- * are platform specific or are required to be handled
- * by the processing logic (i.e., commit, set spool off, etc.)
- *
- * the extending class should copy this forward and then
- * add to it. Also, make an alpha characters upper case.
- * @return
- */
- protected List getNonExecutableDelimiters() {
-
- List re = new ArrayList(1);
- re.add("--"); //$NON-NLS-1$
- re.add("SET");//$NON-NLS-1$
- re.add("COMMIT");//$NON-NLS-1$
- re.add("SPOOL");//$NON-NLS-1$
- return re;
-
- }
-
}
Deleted: trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCPlatformFactory.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCPlatformFactory.java 2009-04-03
01:31:23 UTC (rev 697)
+++
trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCPlatformFactory.java 2009-04-03
01:38:17 UTC (rev 698)
@@ -1,323 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.jdbc;
-
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.util.ErrorMessageKeys;
-
-/**
- * DO NOT USE LogManager in this class
- *
- * Here's the matrix for determining which platform to use:
- * PN = Product Name, which means the product name from the metadata will help determine
the platform
- * Protocol = means the Protocol (mmx:oracle, oracle, sequelink) will help determine the
platform
- *
- *
- * Driver | Oracle DB2 SQLServer Sybase Informix
- * ------------------------------------------------------------------------------
- * Native PN PN PN PN PN
- *
- * MMX (DD) Protocol PN PN PN PN
- * (mmx:oracle)
- *
- * MetaMatrix JDBC Protocol -->(SAME) -->(SAME) ----->(SAME) -->
(SAME)
- *
- * ------------------------------------------------------------------------------
- *
- * The process will look 1st at the protocol and then the product name to further
- * deliniate the type of platform that should be used.
- *
- */
-public class JDBCPlatformFactory {
-
- /**
- * These are the platforms supported
- */
- public interface Supported {
- public static final String ORACLE = "oracle"; //$NON-NLS-1$
- public static final String SYBASE = "sybase"; //$NON-NLS-1$
- public static final String DB2 = "db2"; //$NON-NLS-1$
- public static final String MSSQL = "microsoft"; //$NON-NLS-1$
- public static final String INFORMIX = "informix"; //$NON-NLS-1$
- public static final String METAMATRIX = "metamatrix"; //$NON-NLS-1$
- public static final String MM_ORACLE = "mmx:oracle"; //$NON-NLS-1$
- public static final String MYSQL = "mysql"; //$NON-NLS-1$
- public static final String POSTGRES = "postgres"; //$NON-NLS-1$
-
- // default
- public static final String DEFAULT = "default"; //$NON-NLS-1$
- public static final String DERBY = "derby"; //$NON-NLS-1$
- }
-
-
- /**
- * The use of platforms is a secondary search option
- * in case the supported platforms don't match
- * to the product name
- */
- protected interface Protocol {
- public static final String MSSQL = "mssql"; //$NON-NLS-1$
- public static final String SQLSERVER = "sqlserver"; //$NON-NLS-1$
- public static final String ORACLE = "oracle"; //$NON-NLS-1$
- public static final String DB2 = "db2"; //$NON-NLS-1$
- public static final String SYBASE = "sybase"; //$NON-NLS-1$
- public static final String INFORMIX = "informix-sqli"; //$NON-NLS-1$
- public static final String METAMATRIX = "metamatrix"; //$NON-NLS-1$
- public static final String MM_ORACLE = "mmx:oracle"; //$NON-NLS-1$
- public static final String DERBY = "derby"; //$NON-NLS-1$
- public static final String MYSQL = "mysql"; //$NON-NLS-1$
- public static final String POSTGRES = "postgres"; //$NON-NLS-1$
-
- }
-
- protected interface PlatformClass {
- public static final String MSSQL =
"com.metamatrix.common.jdbc.db.MSSQLPlatform"; //$NON-NLS-1$
- public static final String DB2 =
"com.metamatrix.common.jdbc.db.DB2Platform"; //$NON-NLS-1$
- public static final String ORACLE =
"com.metamatrix.common.jdbc.db.OraclePlatform"; //$NON-NLS-1$
- public static final String SYBASE =
"com.metamatrix.common.jdbc.db.SybasePlatform"; //$NON-NLS-1$
- public static final String INFORMIX =
"com.metamatrix.common.jdbc.db.InformixPlatform"; //$NON-NLS-1$
- public static final String METAMATRIX =
"com.metamatrix.common.jdbc.db.MetaMatrixPlatform"; //$NON-NLS-1$
- public static final String DEFAULT =
"com.metamatrix.common.jdbc.JDBCPlatform"; //$NON-NLS-1$
-
- public static final String MMORACLE =
"com.metamatrix.common.jdbc.db.MMOraclePlatform"; //$NON-NLS-1$
- public static final String DERBY =
"com.metamatrix.common.jdbc.db.DerbyPlatform"; //$NON-NLS-1$
- public static final String MYSQL =
"com.metamatrix.common.jdbc.db.MySQLPlatform"; //$NON-NLS-1$
- public static final String POSTGRES =
"com.metamatrix.common.jdbc.db.PostgresPlatform"; //$NON-NLS-1$
-
- }
-
- private static final String DEFAULT_PLATFORM = "default"; //$NON-NLS-1$
- private static Map classMap;
-
- private static Map platformCache;
-
-
- static {
- platformCache = new HashMap(10);
-
- classMap = new HashMap(10);
- classMap.put(Supported.DB2, PlatformClass.DB2);
- classMap.put(Supported.MSSQL, PlatformClass.MSSQL);
- classMap.put(Supported.ORACLE, PlatformClass.ORACLE);
- classMap.put(Supported.SYBASE, PlatformClass.SYBASE);
- classMap.put(Supported.INFORMIX, PlatformClass.INFORMIX);
- classMap.put(Supported.METAMATRIX, PlatformClass.METAMATRIX);
- classMap.put(Supported.MM_ORACLE, PlatformClass.MMORACLE);
- classMap.put(Supported.MYSQL, PlatformClass.MYSQL);
- classMap.put(Supported.POSTGRES, PlatformClass.POSTGRES);
-
-
- classMap.put(DEFAULT_PLATFORM, PlatformClass.DEFAULT);
- classMap.put(Supported.DERBY, PlatformClass.DERBY);
-
-
- }
-
- public static JDBCPlatform getPlatform(Connection jdbcConnection) throws
MetaMatrixException {
- try {
- DatabaseMetaData metadata = jdbcConnection.getMetaData();
- String productName = metadata.getDatabaseProductName();
- String driverName = metadata.getDriverName();
-
- JDBCPlatform p = getPlatform(metadata.getURL(), driverName, productName);
- if (p != null) {
- p.setConnection(jdbcConnection);
- }
- return p;
- } catch (Exception sqle) {
- throw new MetaMatrixException(sqle, ErrorMessageKeys.JDBC_ERR_0003,
CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0003));
- }
-
- }
-
- public static JDBCPlatform getPlatform(String url, String driverName) throws
MetaMatrixException {
-
- String productName = getSupportedByProtocol(url);
- if (productName == null) {
- return null;
- }
- return getPlatform(url, driverName, productName );
- }
-
-
-
- static JDBCPlatform getPlatform(String url, String driverName, String productName)
throws MetaMatrixException {
- try {
- boolean isSecure = false;
-
- JDBCURL jdbcurl = new JDBCURL(url);
-
- String dbplatform = getSupportedByProductName(productName);
-
- String supported = getSupportedByProtocol(jdbcurl.getProtocol());
-
-
- if (supported == null) {
- supported = dbplatform;
- }
-
- if (supported == null) {
- supported = Supported.DEFAULT;
- }
-
- String platformClass = getPlatformClass(supported);
-
-
-
- String key = driverName + " - " + jdbcurl.getProtocol();
//$NON-NLS-1$
-
- JDBCPlatform p = createPlatform(dbplatform, platformClass, key, isSecure);
-
- return p;
- } catch (Exception sqle) {
- throw new MetaMatrixException(sqle, ErrorMessageKeys.JDBC_ERR_0003,
CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0003));
- }
- }
-
-
- private static JDBCPlatform createPlatform(String productName, String platformClass,
String key, boolean isSecure) throws MetaMatrixException {
- try {
-
- JDBCPlatform p = getAvailablePlatform(platformClass, key);
-
- if (p != null) {
- return p;
- }
- Object o = Class.forName(platformClass).newInstance();
- if (o instanceof JDBCPlatform) {
- p = (JDBCPlatform) o;
- } else {
- throw new MetaMatrixException(ErrorMessageKeys.JDBC_ERR_0005,
CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0005));
- }
-
- if (isSecure) {
- p.setIsSecure(isSecure);
- }
-
- p.setPlatformName(productName);
- p.initializePlatform();
-
- addAvailablePlatform(platformClass, key, p);
-
- return p;
-
- } catch (Exception cnfe) {
- throw new MetaMatrixException(cnfe, ErrorMessageKeys.JDBC_ERR_0003,
CommonPlugin.Util.getString(ErrorMessageKeys.JDBC_ERR_0003));
- }
- }
-
- private static JDBCPlatform getAvailablePlatform(String platform, String key) {
-
- JDBCPlatform p =null;
- Map platformInstances = null;
- if (platformCache.containsKey(platform)) {
- platformInstances = (Map) platformCache.get(platform);
- if (platformInstances.containsKey(key)) {
- p = (JDBCPlatform) platformInstances.get(key);
- }
- } else {
- platformInstances = new HashMap(10);
- platformCache.put(platform, platformInstances);
- }
-
- return p;
- }
-
- private static void addAvailablePlatform(String platform, String key, JDBCPlatform
jdbc) {
-
- Map platformInstances = (Map) platformCache.get(platform);
- platformInstances.put(key, jdbc);
- }
-
- static String getSupportedByProtocol(String value) {
-// System.out.println("==== Look for platform by product " + value);
- String lower = value.toLowerCase();
-
- if (lower.indexOf(Protocol.METAMATRIX) >= 0) {
- return Supported.METAMATRIX;
- } else if (lower.indexOf(Protocol.MM_ORACLE) >= 0) {
- return Supported.MM_ORACLE;
- } else if (lower.indexOf(Protocol.MSSQL) >= 0 ||
lower.indexOf(Protocol.SQLSERVER) >= 0) {
- return Supported.MSSQL;
- } else if (lower.indexOf(Protocol.DB2) >= 0) {
- return Supported.DB2;
- } else if (lower.indexOf(Protocol.ORACLE) >= 0) {
- return Supported.ORACLE;
- } else if (lower.indexOf(Protocol.SYBASE) >= 0) {
- return Supported.SYBASE;
- } else if (lower.indexOf(Protocol.INFORMIX) >= 0) {
- return Supported.INFORMIX;
- } else if (lower.indexOf(Protocol.DERBY) >= 0) {
- return Supported.DERBY;
- } else if (lower.indexOf(Protocol.MYSQL) >= 0) {
- return Supported.MYSQL;
- } else if (lower.indexOf(Protocol.POSTGRES) >= 0) {
- return Supported.POSTGRES;
- }
-
- return null;
- }
-
- static String getSupportedByProductName(String value) {
-// System.out.println("==== Look for platform by product " + value);
- String lower = value.toLowerCase();
-
- if (lower.indexOf(Supported.MSSQL) >= 0) {
- return Supported.MSSQL;
- } else if (lower.indexOf(Supported.DB2) >= 0) {
- return Supported.DB2;
- } else if (lower.indexOf(Supported.ORACLE) >= 0) {
- return Supported.ORACLE;
- } else if (lower.indexOf(Supported.SYBASE) >= 0) {
- return Supported.SYBASE;
- } else if (lower.indexOf(Supported.INFORMIX) >= 0) {
- return Supported.INFORMIX;
- } else if (lower.indexOf(Supported.METAMATRIX) >= 0) {
- return Supported.METAMATRIX;
- } else if (lower.indexOf(Supported.DERBY) >= 0) {
- return Supported.DERBY;
- } else if (lower.indexOf(Supported.POSTGRES) >= 0) {
- return Supported.POSTGRES;
- } else if (lower.indexOf(Supported.MYSQL) >= 0) {
- return Supported.MYSQL;
- }
-
- return Supported.DEFAULT;
-
- }
-
- static String getPlatformClass(String supported) {
- String platformClass = (String) classMap.get(supported);
- if (platformClass == null) {
- platformClass = (String) classMap.get(Supported.DEFAULT);
- }
- return platformClass;
-
- }
-}
Deleted: trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCURL.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCURL.java 2009-04-03 01:31:23
UTC (rev 697)
+++ trunk/server/src/main/java/com/metamatrix/common/jdbc/JDBCURL.java 2009-04-03 01:38:17
UTC (rev 698)
@@ -1,125 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.jdbc;
-
-import java.util.List;
-
-import com.metamatrix.core.util.StringUtil;
-
-
-/**
- * @since 4.3
- */
-public class JDBCURL {
-
- private static final String DELIMITER_AT = "@";//$NON-NLS-1$
- private static final String DELIMITER_FORWARDSLASH = "//"; //$NON-NLS-1$
- private static final String JDBC_PROTOCOL = "jdbc:"; //$NON-NLS-1$
-
- private String connectionURL;
- private String protocol;
- private String databaseInfo;
-
- public JDBCURL(String jdbcURL) {
- parseURL(jdbcURL);
- connectionURL = jdbcURL;
- }
-
-
- public String getConnectionURL() {
- return connectionURL;
- }
-
- public String getProtocol() {
- return protocol;
- }
-
- public String getDataConnectionInfo() {
- return databaseInfo;
- }
-
-
- private void parseURL(String jdbcURL) {
- if (jdbcURL == null) {
- throw new IllegalArgumentException();
- }
- // Trim extra spaces
- jdbcURL = jdbcURL.trim();
- if (jdbcURL.length() == 0) {
- throw new IllegalArgumentException();
- }
-
- int delimiter = jdbcURL.indexOf(DELIMITER_AT);
- if (delimiter > 0) {
- parseWithAt(jdbcURL);
- } else {
- parseForSlash(jdbcURL);
- }
-
-
- }
-
- private void parseForSlash(String jdbcURL) {
-
- parseOnDelimiter(jdbcURL, DELIMITER_FORWARDSLASH);
- }
- private void parseOnDelimiter(String jdbcURL, String delim) {
- List urlParts = StringUtil.splitOnEntireString(jdbcURL, delim);
- // String[] urlParts = split(jdbcURL, DELIMITER_FORWARDSLASH);
- if (urlParts.size() != 2) {
- throw new IllegalArgumentException();
- }
- parseJDBCProtocol((String) urlParts.get(0));
- parseConnectionPart((String)urlParts.get(1));
- }
-
- private void parseWithAt(String jdbcURL) {
- parseOnDelimiter(jdbcURL, DELIMITER_AT);
- }
-
- private void parseJDBCProtocol(String protocolurl) {
- if (!protocolurl.startsWith(JDBC_PROTOCOL)) {
- throw new IllegalArgumentException();
- }
- if (protocolurl.length() == JDBC_PROTOCOL.length()) {
- throw new IllegalArgumentException();
- }
- protocol = protocolurl.substring(JDBC_PROTOCOL.length());
- }
-
- private void parseConnectionPart(String connectionInfo) {
- databaseInfo = connectionInfo;
-
- }
-
- public String getJDBCURL() {
- return connectionURL;
- }
-
- public String toString() {
- return getJDBCURL();
- }
-
-
-
-}
Modified: trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java 2009-04-03
01:31:23 UTC (rev 697)
+++ trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java 2009-04-03
01:38:17 UTC (rev 698)
@@ -32,6 +32,7 @@
import com.metamatrix.common.CommonPlugin;
import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.JDBCConnectionPoolHelper;
+import com.metamatrix.common.jdbc.JDBCPlatform;
import com.metamatrix.common.util.ErrorMessageKeys;
import com.metamatrix.core.log.LogMessage;
import com.metamatrix.core.util.DateUtil;
@@ -160,7 +161,7 @@
private int maxExceptionLength = DEFAULT_MAX_EXCEPTION_LENGTH;
private Properties connProps;
- private StringBuffer insertStr;
+ private String insert;
private boolean shutdown = false;
@@ -223,30 +224,7 @@
// ignore and use default
}
- // construct the insert string
- insertStr = new StringBuffer(INSERT_INTO);
- insertStr.append(getTableName(connProps));
- insertStr.append(LEFT_PAREN);
- insertStr.append( ColumnName.TIMESTAMP );
- insertStr.append(COMMA);
- insertStr.append( ColumnName.SEQUENCE_NUMBER );
- insertStr.append(COMMA);
- insertStr.append( ColumnName.CONTEXT );
- insertStr.append(COMMA);
- insertStr.append( ColumnName.LEVEL );
- insertStr.append(COMMA);
- insertStr.append( ColumnName.MESSAGE );
- insertStr.append(COMMA);
- insertStr.append( ColumnName.HOST );
- insertStr.append(COMMA);
- insertStr.append( ColumnName.VM );
- insertStr.append(COMMA);
- insertStr.append( ColumnName.THREAD );
- insertStr.append(COMMA);
- insertStr.append( '"'+ ColumnName.EXCEPTION +'"' );
- insertStr.append(VALUES);
}
-
public synchronized void logMessage(LogMessage msg) {
write(msg);
@@ -275,6 +253,36 @@
}
}
+ private String getInsertStr(Connection c) throws SQLException {
+ if (this.insert == null) {
+ // construct the insert string
+ StringBuffer insertStr = new StringBuffer(INSERT_INTO);
+ insertStr.append(getTableName(connProps));
+ insertStr.append(LEFT_PAREN);
+ insertStr.append( ColumnName.TIMESTAMP );
+ insertStr.append(COMMA);
+ insertStr.append( ColumnName.SEQUENCE_NUMBER );
+ insertStr.append(COMMA);
+ insertStr.append( ColumnName.CONTEXT );
+ insertStr.append(COMMA);
+ insertStr.append( ColumnName.LEVEL );
+ insertStr.append(COMMA);
+ insertStr.append( ColumnName.MESSAGE );
+ insertStr.append(COMMA);
+ insertStr.append( ColumnName.HOST );
+ insertStr.append(COMMA);
+ insertStr.append( ColumnName.VM );
+ insertStr.append(COMMA);
+ insertStr.append( ColumnName.THREAD );
+ insertStr.append(COMMA);
+ String quote = JDBCPlatform.getIdentifierQuoteString(c);
+ insertStr.append( quote+ ColumnName.EXCEPTION +quote );
+ insertStr.append(VALUES);
+ this.insert = insertStr.toString();
+ }
+ return this.insert;
+ }
+
private void printMsg(LogMessage message) throws SQLException {
if (this.shutdown) {
return;
@@ -289,7 +297,7 @@
PreparedStatement stmt = null;
try {
connection = JDBCConnectionPoolHelper.getInstance().getConnection();
- stmt = connection.prepareStatement(insertStr.toString());
+ stmt = connection.prepareStatement(getInsertStr(connection));
// Add values to Prepared statement
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCConnector.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCConnector.java 2009-04-03
01:31:23 UTC (rev 697)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCConnector.java 2009-04-03
01:38:17 UTC (rev 698)
@@ -33,8 +33,6 @@
import com.metamatrix.common.connection.ManagedConnection;
import com.metamatrix.common.connection.ManagedConnectionException;
import com.metamatrix.common.connection.jdbc.JDBCMgdResourceConnection;
-import com.metamatrix.common.jdbc.JDBCPlatform;
-import com.metamatrix.common.jdbc.JDBCPlatformFactory;
import com.metamatrix.common.log.I18nLogManager;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.util.DateUtil;
@@ -56,10 +54,9 @@
public class JDBCConnector extends BaseTransaction implements MetaBaseConnector {
- private static String IS_TRUE = "1";
- private static String IS_FALSE = "0";
+ private static String IS_TRUE = "1"; //$NON-NLS-1$
+ private static String IS_FALSE = "0"; //$NON-NLS-1$
private Connection jdbcConnection;
- private JDBCPlatform platform;
/**
* Create a new instance of a transaction for a managed connection.
* @param connection the connection that should be used and that was created using
this
@@ -74,12 +71,10 @@
JDBCMgdResourceConnection jdbcManagedConnection = (JDBCMgdResourceConnection)
connection;
this.jdbcConnection = jdbcManagedConnection.getConnection();
- platform = JDBCPlatformFactory.getPlatform(jdbcConnection);
} catch ( Exception e ) {
throw new ManagedConnectionException(ErrorMessageKeys.JDBCC_0002,
RuntimeMetadataPlugin.Util.getString(ErrorMessageKeys.JDBCC_0002,
JDBCMgdResourceConnection.class.getName() ) );
}
- JDBCRuntimeMetadataReader.setJDBCPlatform(this.platform);
}
/**
@@ -192,7 +187,7 @@
if (statement.executeUpdate() != 1) {
throw new VirtualDatabaseException(ErrorMessageKeys.JDBCC_0009,
RuntimeMetadataPlugin.Util.getString(ErrorMessageKeys.JDBCC_0009) );
}
- LogManager.logTrace(LogRuntimeMetadataConstants.CTX_RUNTIME_METADATA,new
Object[]{"Inserted Model with DBID ",new Long(modelID.getUID())});
+ LogManager.logTrace(LogRuntimeMetadataConstants.CTX_RUNTIME_METADATA,new
Object[]{"Inserted Model with DBID ",new Long(modelID.getUID())});
//$NON-NLS-1$
// Properties prop;
@@ -203,16 +198,16 @@
}catch (SQLException se){
BasicModelID modelID = (BasicModelID)model.getID();
- sql = StringUtil.replace(sql, "?", Long.toString(modelID.getUID())
);
- sql = StringUtil.replace(sql, "?", model.getName());
- sql = StringUtil.replace(sql, "?",
((ModelID)model.getID()).getVersion());
- sql = StringUtil.replace(sql, "?",
(adjustLengthToFit(model.getDescription())==null?"NULL" :
adjustLengthToFit(model.getDescription())));
- sql = StringUtil.replace(sql, "?", (model.isPhysical()? IS_TRUE :
IS_FALSE));
- sql = StringUtil.replace(sql, "?",
(model.isMultiSourceBindingEnabled()? IS_TRUE : IS_FALSE));
- sql = StringUtil.replace(sql, "?", (model.isVisible()? IS_TRUE :
IS_FALSE));
- sql = StringUtil.replace(sql, "?",
((BasicModelID)model.getID()).getUuid());
- sql = StringUtil.replace(sql, "?",
Integer.toString(model.getModelType()));
- sql = StringUtil.replace(sql, "?", model.getModelURI());
+ sql = StringUtil.replace(sql, "?", Long.toString(modelID.getUID())
); //$NON-NLS-1$
+ sql = StringUtil.replace(sql, "?", model.getName()); //$NON-NLS-1$
+ sql = StringUtil.replace(sql, "?",
((ModelID)model.getID()).getVersion()); //$NON-NLS-1$
+ sql = StringUtil.replace(sql, "?",
(adjustLengthToFit(model.getDescription())==null?"NULL" :
adjustLengthToFit(model.getDescription()))); //$NON-NLS-1$ //$NON-NLS-2$
+ sql = StringUtil.replace(sql, "?", (model.isPhysical()? IS_TRUE :
IS_FALSE)); //$NON-NLS-1$
+ sql = StringUtil.replace(sql, "?",
(model.isMultiSourceBindingEnabled()? IS_TRUE : IS_FALSE)); //$NON-NLS-1$
+ sql = StringUtil.replace(sql, "?", (model.isVisible()? IS_TRUE :
IS_FALSE)); //$NON-NLS-1$
+ sql = StringUtil.replace(sql, "?",
((BasicModelID)model.getID()).getUuid()); //$NON-NLS-1$
+ sql = StringUtil.replace(sql, "?",
Integer.toString(model.getModelType())); //$NON-NLS-1$
+ sql = StringUtil.replace(sql, "?", model.getModelURI());
//$NON-NLS-1$
throw new VirtualDatabaseException(se, ErrorMessageKeys.JDBCC_0003,
RuntimeMetadataPlugin.Util.getString(ErrorMessageKeys.JDBCC_0003, sql) );
}finally {
@@ -255,7 +250,7 @@
if (statement.executeUpdate() != 1) {
throw new VirtualDatabaseException(ErrorMessageKeys.JDBCC_0023,
RuntimeMetadataPlugin.Util.getString(ErrorMessageKeys.JDBCC_0023, vdb.getName() ) );
}
- LogManager.logTrace(LogRuntimeMetadataConstants.CTX_RUNTIME_METADATA,new
Object[]{"Inserted VirtualDatabase with DBID ",new
Long(((BasicVirtualDatabaseID)vdb.getID()).getUID())});
+ LogManager.logTrace(LogRuntimeMetadataConstants.CTX_RUNTIME_METADATA,new
Object[]{"Inserted VirtualDatabase with DBID ",new
Long(((BasicVirtualDatabaseID)vdb.getID()).getUID())}); //$NON-NLS-1$
}catch (SQLException se){
throw new VirtualDatabaseException(se, ErrorMessageKeys.JDBCC_0003,
RuntimeMetadataPlugin.Util.getString(ErrorMessageKeys.JDBCC_0003, sql) );
@@ -365,7 +360,7 @@
I18nLogManager.logError(LogRuntimeMetadataConstants.CTX_RUNTIME_METADATA,
ErrorMessageKeys.GEN_0008, e);
}
- LogManager.logTrace(LogRuntimeMetadataConstants.CTX_RUNTIME_METADATA,
"" + lines + " rows deleted.");
+ LogManager.logTrace(LogRuntimeMetadataConstants.CTX_RUNTIME_METADATA,
"" + lines + " rows deleted."); //$NON-NLS-1$ //$NON-NLS-2$
}
private String adjustLengthToFit(String oriString){
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCRuntimeMetadataReader.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCRuntimeMetadataReader.java 2009-04-03
01:31:23 UTC (rev 697)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCRuntimeMetadataReader.java 2009-04-03
01:38:17 UTC (rev 698)
@@ -35,8 +35,6 @@
import java.util.List;
import java.util.Properties;
-import com.metamatrix.common.jdbc.JDBCPlatform;
-import com.metamatrix.common.jdbc.syntax.ExpressionOperator;
import com.metamatrix.common.log.I18nLogManager;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.CorePlugin;
@@ -62,12 +60,6 @@
// private static String IS_FALSE = "0";
// private static int MAX_COLUMN_WIDTH = 255;
- private static JDBCPlatform platform;
-
- public static void setJDBCPlatform(JDBCPlatform jdbcPlatform) {
- platform = jdbcPlatform;
- }
-
/**
* returns the <code>VirtualDatabase</code> based on the virtual database
id.
* @param virtualDatabaseID is the VirtualDatabase to be returned.
@@ -342,31 +334,26 @@
return result;
}
-
protected static VirtualDatabaseID getVirtualDatabaseID(String fullName, String
version, boolean isActive, Connection jdbcConnection) throws
VirtualDatabaseDoesNotExistException, VirtualDatabaseException {
PreparedStatement statement = null;
String sql = null;
VirtualDatabaseID result = null;
- String uVdbName =
platform.getOperator(ExpressionOperator.ToUpperCase).buildExpression(JDBCNames.VirtualDatabases.ColumnName.VDB_NM);
int nParms = 2;
try{
if(isActive){
if(version == null){
- sql = replace(JDBCTranslator.SELECT_ACTIVE_VIRTUAL_DATABASE_ID_LV,
JDBCTranslator.PLATFORM_DEPENDENT_MARK, uVdbName);
- sql = replace(sql, JDBCTranslator.PLATFORM_DEPENDENT_MARK,
uVdbName);
- sql = replace(sql, JDBCTranslator.PLATFORM_DEPENDENT_MARK,
uVdbName);
+ sql = JDBCTranslator.SELECT_ACTIVE_VIRTUAL_DATABASE_ID_LV;
nParms = 3;
}else{
- sql = replace(JDBCTranslator.SELECT_ACTIVE_VIRTUAL_DATABASE_ID,
JDBCTranslator.PLATFORM_DEPENDENT_MARK, uVdbName);
+ sql = JDBCTranslator.SELECT_ACTIVE_VIRTUAL_DATABASE_ID;
}
}else{
if(version == null){
- sql = replace(JDBCTranslator.SELECT_VIRTUAL_DATABASE_ID_LV,
JDBCTranslator.PLATFORM_DEPENDENT_MARK, uVdbName);
- sql = replace(sql, JDBCTranslator.PLATFORM_DEPENDENT_MARK,
uVdbName);
+ sql = JDBCTranslator.SELECT_VIRTUAL_DATABASE_ID_LV;
}else
- sql = replace(JDBCTranslator.SELECT_VIRTUAL_DATABASE_ID,
JDBCTranslator.PLATFORM_DEPENDENT_MARK, uVdbName);
+ sql = JDBCTranslator.SELECT_VIRTUAL_DATABASE_ID;
}
statement = jdbcConnection.prepareStatement(sql);
statement.setString(1, fullName.toUpperCase());
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCTranslator.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCTranslator.java 2009-04-03
01:31:23 UTC (rev 697)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/spi/jdbc/JDBCTranslator.java 2009-04-03
01:38:17 UTC (rev 698)
@@ -52,32 +52,30 @@
public static long NA_LONG = 0;
public static int NA_INT = 0;
public static short NA_SHORT = 0;
- public static String PLATFORM_DEPENDENT_MARK = "??";
+ private static String IS_TRUE = "1"; //$NON-NLS-1$
- private static String IS_TRUE = "1";
-
// private static final String DELIMITER = ".";
// private static final String BLANK = MetadataConstants.BLANK;
- private static final String MAX = "MAX";
- private static final String INSERT = JDBCReservedWords.INSERT + " ";
- private static final String UPDATE = JDBCReservedWords.UPDATE + " ";
- private static final String DELETE = JDBCReservedWords.DELETE + " ";
- private static final String SELECT = JDBCReservedWords.SELECT + " ";
- private static final String FROM = " " + JDBCReservedWords.FROM +
" ";
- private static final String WHERE = " " + JDBCReservedWords.WHERE +
" ";
+ private static final String MAX = "MAX"; //$NON-NLS-1$
+ private static final String INSERT = JDBCReservedWords.INSERT + " ";
//$NON-NLS-1$
+ private static final String UPDATE = JDBCReservedWords.UPDATE + " ";
//$NON-NLS-1$
+ private static final String DELETE = JDBCReservedWords.DELETE + " ";
//$NON-NLS-1$
+ private static final String SELECT = JDBCReservedWords.SELECT + " ";
//$NON-NLS-1$
+ private static final String FROM = " " + JDBCReservedWords.FROM +
" "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String WHERE = " " + JDBCReservedWords.WHERE +
" "; //$NON-NLS-1$ //$NON-NLS-2$
// private static final String LIKE = " " + JDBCReservedWords.LIKE +
" ";
- private static final String ORDER_BY = " " + JDBCReservedWords.ORDER_BY
+ " ";
- private static final String SET = " " + JDBCReservedWords.SET +
" ";
+ private static final String ORDER_BY = " " + JDBCReservedWords.ORDER_BY
+ " "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String SET = " " + JDBCReservedWords.SET +
" "; //$NON-NLS-1$ //$NON-NLS-2$
// private static final String ON = " " + JDBCReservedWords.ON +
" ";
- private static final String INTO = " " + JDBCReservedWords.INTO +
" ";
- private static final String DISTINCT = " " + JDBCReservedWords.DISTINCT
+ " ";
- private static final String VALUES = " " + JDBCReservedWords.VALUES +
" ";
- private static final String AND = " " + JDBCReservedWords.AND +
" ";
- private static final String IN = " " + JDBCReservedWords.IN +
" ";
- private static final String NOT_IN = " " + JDBCReservedWords.NOT +
" " + JDBCReservedWords.IN + " ";
- private static final String OR = " " + JDBCReservedWords.OR +
" ";
+ private static final String INTO = " " + JDBCReservedWords.INTO +
" "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String DISTINCT = " " + JDBCReservedWords.DISTINCT
+ " "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String VALUES = " " + JDBCReservedWords.VALUES +
" "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String AND = " " + JDBCReservedWords.AND +
" "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String IN = " " + JDBCReservedWords.IN +
" "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String NOT_IN = " " + JDBCReservedWords.NOT +
" " + JDBCReservedWords.IN + " "; //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
+ private static final String OR = " " + JDBCReservedWords.OR +
" "; //$NON-NLS-1$ //$NON-NLS-2$
// private static final String IS = " " + JDBCReservedWords.IS +
" ";
// private static final String IS_NOT_NULL = IS + " " +
JDBCReservedWords.NOT + " " + JDBCReservedWords.NULL;
@@ -89,87 +87,87 @@
// ---------------------------------------------------------------------------------
//select IDs
public static final String SELECT_ACTIVE_VIRTUAL_DATABASE_ID
- = SELECT +
JDBCNames.VirtualDatabases.ColumnName.VDB_UID + ","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_NM +
","
+ = SELECT +
JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_NM +
"," //$NON-NLS-1$
+ JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + PLATFORM_DEPENDENT_MARK + "=?"
+ + "{fn ucase("
+JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ")}=?" //$NON-NLS-1$
//$NON-NLS-2$
+ AND
- +
JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + "=?"
- + AND + "(" +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=" + VDBStatus.ACTIVE
- + OR +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=" +
VDBStatus.ACTIVE_DEFAULT
- + ")";
+ +
JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + "=?" //$NON-NLS-1$
+ + AND + "(" +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=" + VDBStatus.ACTIVE
//$NON-NLS-1$ //$NON-NLS-2$
+ + OR +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=" +
VDBStatus.ACTIVE_DEFAULT //$NON-NLS-1$
+ + ")"; //$NON-NLS-1$
public static final String SELECT_VIRTUAL_DATABASE_ID
- = SELECT +
JDBCNames.VirtualDatabases.ColumnName.VDB_UID + ","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_NM +
","
+ = SELECT +
JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_NM +
"," //$NON-NLS-1$
+ JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + PLATFORM_DEPENDENT_MARK + "=?"
+ + "{fn ucase("
+JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ")}=?" //$NON-NLS-1$
//$NON-NLS-2$
+ AND
- +
JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + "=?";
+ +
JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + "=?"; //$NON-NLS-1$
public static final String SELECT_ACTIVE_VIRTUAL_DATABASE_ID_LV
- = SELECT +
JDBCNames.VirtualDatabases.ColumnName.VDB_UID + ","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_NM +
","
+ = SELECT +
JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_NM +
"," //$NON-NLS-1$
+
JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + PLATFORM_DEPENDENT_MARK + "=?"
- + AND +
JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE + "=("
- + SELECT + MAX + "("
- +
JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +")"
+ + "{fn ucase("
+JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ")}=?" //$NON-NLS-1$
//$NON-NLS-2$
+ + AND +
JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE + "=(" //$NON-NLS-1$
+ + SELECT + MAX + "(" //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +")" //$NON-NLS-1$
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + PLATFORM_DEPENDENT_MARK + "=?"
+ + "{fn ucase("
+JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ")}=?" //$NON-NLS-1$
//$NON-NLS-2$
+ AND
- +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "="
- + "(" + SELECT + MAX + "(" +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + ")"
+ +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=" //$NON-NLS-1$
+ + "(" + SELECT + MAX + "(" +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + ")" //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + PLATFORM_DEPENDENT_MARK + "=?"
- + AND + "(" +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=" + VDBStatus.ACTIVE
- + OR +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=" +
VDBStatus.ACTIVE_DEFAULT
- +")))";
+ + "{fn ucase("
+JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ")}=?" //$NON-NLS-1$
//$NON-NLS-2$
+ + AND + "(" +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=" + VDBStatus.ACTIVE
//$NON-NLS-1$ //$NON-NLS-2$
+ + OR +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=" +
VDBStatus.ACTIVE_DEFAULT //$NON-NLS-1$
+ +")))"; //$NON-NLS-1$
public static final String SELECT_VIRTUAL_DATABASE_ID_LV
- = SELECT +
JDBCNames.VirtualDatabases.ColumnName.VDB_UID + ","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_NM +
","
+ = SELECT +
JDBCNames.VirtualDatabases.ColumnName.VDB_UID + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_NM +
"," //$NON-NLS-1$
+
JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + PLATFORM_DEPENDENT_MARK + "=?"
- + AND +
JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE + "=("
- + SELECT + MAX + "("
- +
JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +")"
+ + "{fn ucase("
+JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ")}=?" //$NON-NLS-1$
//$NON-NLS-2$
+ + AND +
JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE + "=(" //$NON-NLS-1$
+ + SELECT + MAX + "(" //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +")" //$NON-NLS-1$
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + PLATFORM_DEPENDENT_MARK + "=?)";
+ + "{fn ucase("
+JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ")}=?"; //$NON-NLS-1$
//$NON-NLS-2$
//select objects
public static final String SELECT_VIRTUAL_DATABASES
- = SELECT +
JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ","
- +
JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + ","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_UID +
","
- +
JDBCNames.VirtualDatabases.ColumnName.DESCRIPTION + ","
- +
JDBCNames.VirtualDatabases.ColumnName.PROJECT_GUID +","
- +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS +","
- +
JDBCNames.VirtualDatabases.ColumnName.WSDL_DEFINED +","
- +
JDBCNames.VirtualDatabases.ColumnName.VERSION_BY +","
- +
JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +","
- +
JDBCNames.VirtualDatabases.ColumnName.CREATED_BY +","
- +
JDBCNames.VirtualDatabases.ColumnName.CREATION_DATE+","
- +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY+","
- +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE+","
+ = SELECT +
JDBCNames.VirtualDatabases.ColumnName.VDB_NM + "," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_UID +
"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.DESCRIPTION + "," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.PROJECT_GUID +"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS +"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.WSDL_DEFINED +"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.VERSION_BY +"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.CREATED_BY +"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.CREATION_DATE+"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY+"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE+"," //$NON-NLS-1$
+
JDBCNames.VirtualDatabases.ColumnName.VDB_FILE_NAME
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME;
@@ -181,189 +179,189 @@
+ FROM
+ JDBCNames.VDBModels.TABLE_NAME
+ WHERE
- + JDBCNames.VDBModels.ColumnName.VDB_UID +
"=?";
+ + JDBCNames.VDBModels.ColumnName.VDB_UID +
"=?"; //$NON-NLS-1$
public static final String SELECT_DELETED_VIRTUAL_DATABASES
- = SELECT +
JDBCNames.VirtualDatabases.ColumnName.VDB_NM + ","
- +
JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + ","
+ = SELECT +
JDBCNames.VirtualDatabases.ColumnName.VDB_NM + "," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + "," //$NON-NLS-1$
+ JDBCNames.VirtualDatabases.ColumnName.VDB_UID
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=4";
+ +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=4"; //$NON-NLS-1$
public static final String SELECT_VIRTUAL_DATABASE
- = SELECT +
JDBCNames.VirtualDatabases.ColumnName.DESCRIPTION + ","
- +
JDBCNames.VirtualDatabases.ColumnName.PROJECT_GUID +","
- +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS +","
- +
JDBCNames.VirtualDatabases.ColumnName.WSDL_DEFINED +","
- +
JDBCNames.VirtualDatabases.ColumnName.VERSION_BY +","
- +
JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +","
- +
JDBCNames.VirtualDatabases.ColumnName.CREATED_BY +","
- +
JDBCNames.VirtualDatabases.ColumnName.CREATION_DATE+","
- +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY+","
- +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE + ","
+ = SELECT +
JDBCNames.VirtualDatabases.ColumnName.DESCRIPTION + "," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.PROJECT_GUID +"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS +"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.WSDL_DEFINED +"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.VERSION_BY +"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.CREATED_BY +"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.CREATION_DATE+"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY+"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE + "," //$NON-NLS-1$
+
JDBCNames.VirtualDatabases.ColumnName.VDB_FILE_NAME
+ FROM
+ JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + JDBCNames.VirtualDatabases.ColumnName.VDB_UID +
"=?";
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_UID +
"=?"; //$NON-NLS-1$
public static final String SELECT_MODELS
- = SELECT + JDBCNames.VDBModels.TABLE_NAME +
"."
- + JDBCNames.Models.ColumnName.MDL_UID
+","
- + JDBCNames.Models.ColumnName.MDL_NM
+","
- + JDBCNames.Models.ColumnName.MDL_VERSION
+","
- + JDBCNames.Models.ColumnName.MDL_UUID
+","
- + JDBCNames.Models.ColumnName.MDL_TYPE
+","
- + JDBCNames.Models.ColumnName.MDL_URI
+","
- + JDBCNames.Models.ColumnName.DESCRIPTION
+","
- + JDBCNames.Models.ColumnName.IS_PHYSICAL
+","
- + JDBCNames.Models.ColumnName.MULTI_SOURCED
+","
- + JDBCNames.Models.ColumnName.VISIBILITY
+","
+ = SELECT + JDBCNames.VDBModels.TABLE_NAME +
"." //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_UID
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_NM
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_VERSION
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_UUID
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_TYPE
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_URI
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.DESCRIPTION
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.IS_PHYSICAL
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MULTI_SOURCED
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.VISIBILITY
+"," //$NON-NLS-1$
+ JDBCNames.VDBModels.ColumnName.CNCTR_BNDNG_NM
- + FROM + JDBCNames.Models.TABLE_NAME +
","
+ + FROM + JDBCNames.Models.TABLE_NAME +
"," //$NON-NLS-1$
+ JDBCNames.VDBModels.TABLE_NAME
+ WHERE
- + JDBCNames.VDBModels.TABLE_NAME + "."
- + JDBCNames.VDBModels.ColumnName.MDL_UID +
"="
- + JDBCNames.Models.TABLE_NAME + "."
+ + JDBCNames.VDBModels.TABLE_NAME + "."
//$NON-NLS-1$
+ + JDBCNames.VDBModels.ColumnName.MDL_UID +
"=" //$NON-NLS-1$
+ + JDBCNames.Models.TABLE_NAME + "."
//$NON-NLS-1$
+ JDBCNames.Models.ColumnName.MDL_UID
+ AND
- + JDBCNames.VDBModels.ColumnName.VDB_UID +
"=?"
+ + JDBCNames.VDBModels.ColumnName.VDB_UID +
"=?" //$NON-NLS-1$
+ ORDER_BY
+ JDBCNames.Models.ColumnName.MDL_NM
;
public static final String SELECT_MODEL_IDS
- = SELECT + JDBCNames.Models.ColumnName.MDL_UID
+","
- + JDBCNames.Models.ColumnName.MDL_VERSION
+","
- + JDBCNames.Models.ColumnName.MDL_NM
+","
+ = SELECT + JDBCNames.Models.ColumnName.MDL_UID
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_VERSION
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_NM
+"," //$NON-NLS-1$
+ JDBCNames.Models.ColumnName.MDL_UUID
+ FROM + JDBCNames.Models.TABLE_NAME;
public static final String SELECT_MODEL_IDS_ONLY_IN_VDB
- = SELECT + JDBCNames.Models.TABLE_NAME +
"."
- + JDBCNames.Models.ColumnName.MDL_UID
+","
- + JDBCNames.Models.ColumnName.MDL_VERSION
+","
- + JDBCNames.Models.ColumnName.MDL_NM
+","
+ = SELECT + JDBCNames.Models.TABLE_NAME +
"." //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_UID
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_VERSION
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_NM
+"," //$NON-NLS-1$
+ JDBCNames.Models.ColumnName.MDL_UUID
+ FROM + JDBCNames.Models.TABLE_NAME
+ WHERE
+ JDBCNames.Models.ColumnName.MDL_UID
- + NOT_IN +"("
- + SELECT + JDBCNames.Models.TABLE_NAME +
"."
+ + NOT_IN +"(" //$NON-NLS-1$
+ + SELECT + JDBCNames.Models.TABLE_NAME +
"." //$NON-NLS-1$
+ JDBCNames.Models.ColumnName.MDL_UID
- + FROM + JDBCNames.Models.TABLE_NAME +
","
+ + FROM + JDBCNames.Models.TABLE_NAME +
"," //$NON-NLS-1$
+ JDBCNames.VDBModels.TABLE_NAME
+ WHERE
- + JDBCNames.VDBModels.TABLE_NAME + "."
- + JDBCNames.VDBModels.ColumnName.MDL_UID +
"="
- + JDBCNames.Models.TABLE_NAME + "."
+ + JDBCNames.VDBModels.TABLE_NAME + "."
//$NON-NLS-1$
+ + JDBCNames.VDBModels.ColumnName.MDL_UID +
"=" //$NON-NLS-1$
+ + JDBCNames.Models.TABLE_NAME + "."
//$NON-NLS-1$
+ JDBCNames.Models.ColumnName.MDL_UID
+ AND
- + JDBCNames.VDBModels.ColumnName.VDB_UID + "
!=?)";
+ + JDBCNames.VDBModels.ColumnName.VDB_UID + "
!=?)"; //$NON-NLS-1$
//a special one
public static final String SELECT_PROPERTIES
- = SELECT +
JDBCNames.VCommonProperties.ColumnName.PRP_NM + ","
+ = SELECT +
JDBCNames.VCommonProperties.ColumnName.PRP_NM + "," //$NON-NLS-1$
+ JDBCNames.VCommonProperties.ColumnName.PRP_VL
- + FROM + "?"
+ + FROM + "?" //$NON-NLS-1$
+ WHERE
- + "="
+ + "=" //$NON-NLS-1$
+ AND
- + "?=?"
+ + "?=?" //$NON-NLS-1$
+ ORDER_BY
- + JDBCNames.VCommonProperties.ColumnName.PRP_NM +
","
+ + JDBCNames.VCommonProperties.ColumnName.PRP_NM +
"," //$NON-NLS-1$
+
JDBCNames.VCommonProperties.ColumnName.PART_ID;
//insert statement
public static final String INSERT_VIRTUAL_DATABASE
- = INSERT + INTO +
JDBCNames.VirtualDatabases.TABLE_NAME + "("
- + JDBCNames.VirtualDatabases.ColumnName.VDB_UID +
","
- +
JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + ","
- + JDBCNames.VirtualDatabases.ColumnName.VDB_NM +
","
- +
JDBCNames.VirtualDatabases.ColumnName.DESCRIPTION + ","
- +
JDBCNames.VirtualDatabases.ColumnName.PROJECT_GUID +","
- +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS +","
- +
JDBCNames.VirtualDatabases.ColumnName.WSDL_DEFINED +","
- +
JDBCNames.VirtualDatabases.ColumnName.VERSION_BY +","
- +
JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +","
- +
JDBCNames.VirtualDatabases.ColumnName.CREATED_BY +","
- +
JDBCNames.VirtualDatabases.ColumnName.CREATION_DATE+","
- +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY+","
- +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE+","
- +
JDBCNames.VirtualDatabases.ColumnName.VDB_FILE_NAME + ")"
+ = INSERT + INTO +
JDBCNames.VirtualDatabases.TABLE_NAME + "(" //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_UID +
"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + "," //$NON-NLS-1$
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_NM +
"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.DESCRIPTION + "," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.PROJECT_GUID +"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS +"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.WSDL_DEFINED +","
//$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.VERSION_BY +"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.VERSION_DATE +"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.CREATED_BY +"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.CREATION_DATE+"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY+"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE+"," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.VDB_FILE_NAME + ")" //$NON-NLS-1$
+ VALUES
- + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
//$NON-NLS-1$
public static final String INSERT_MODELS
- = INSERT + INTO + JDBCNames.Models.TABLE_NAME +
"("
- + JDBCNames.Models.ColumnName.MDL_UID
+","
- + JDBCNames.Models.ColumnName.MDL_NM
+","
- + JDBCNames.Models.ColumnName.MDL_VERSION
+","
- + JDBCNames.Models.ColumnName.DESCRIPTION
+","
- + JDBCNames.Models.ColumnName.IS_PHYSICAL
+","
- + JDBCNames.Models.ColumnName.MULTI_SOURCED
+","
- + JDBCNames.Models.ColumnName.VISIBILITY
+","
- + JDBCNames.Models.ColumnName.MDL_UUID
+","
- + JDBCNames.Models.ColumnName.MDL_TYPE
+","
- + JDBCNames.Models.ColumnName.MDL_URI +
")"
+ = INSERT + INTO + JDBCNames.Models.TABLE_NAME +
"(" //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_UID
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_NM
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_VERSION
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.DESCRIPTION
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.IS_PHYSICAL
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MULTI_SOURCED
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.VISIBILITY
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_UUID
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_TYPE
+"," //$NON-NLS-1$
+ + JDBCNames.Models.ColumnName.MDL_URI +
")" //$NON-NLS-1$
+ VALUES
- + "(?,?,?,?,?,?,?,?,?,?)";
+ + "(?,?,?,?,?,?,?,?,?,?)";
//$NON-NLS-1$
public static final String INSERT_VDB_MODELS
- = INSERT + INTO + JDBCNames.VDBModels.TABLE_NAME +
"("
- + JDBCNames.VDBModels.ColumnName.VDB_UID +
","
- + JDBCNames.VDBModels.ColumnName.MDL_UID +
")"
+ = INSERT + INTO + JDBCNames.VDBModels.TABLE_NAME +
"(" //$NON-NLS-1$
+ + JDBCNames.VDBModels.ColumnName.VDB_UID +
"," //$NON-NLS-1$
+ + JDBCNames.VDBModels.ColumnName.MDL_UID +
")" //$NON-NLS-1$
+ VALUES
- + "(?,?)";
+ + "(?,?)"; //$NON-NLS-1$
public static final String INSERT_VDB_MODELS_WITH_BINDING
- = INSERT + INTO + JDBCNames.VDBModels.TABLE_NAME
+ "("
- + JDBCNames.VDBModels.ColumnName.VDB_UID +
","
- + JDBCNames.VDBModels.ColumnName.MDL_UID +
","
- +
JDBCNames.VDBModels.ColumnName.CNCTR_BNDNG_NM + ")"
+ = INSERT + INTO + JDBCNames.VDBModels.TABLE_NAME
+ "(" //$NON-NLS-1$
+ + JDBCNames.VDBModels.ColumnName.VDB_UID +
"," //$NON-NLS-1$
+ + JDBCNames.VDBModels.ColumnName.MDL_UID +
"," //$NON-NLS-1$
+ +
JDBCNames.VDBModels.ColumnName.CNCTR_BNDNG_NM + ")" //$NON-NLS-1$
+ VALUES
- + "(?,?,?)";
+ + "(?,?,?)"; //$NON-NLS-1$
public static final String INSERT_PROP_NAMES
- = INSERT + INTO + "?" + "("
- + JDBCNames.VCommonProperties.ColumnName.PRP_UID
+ ","
- + "?," +
JDBCNames.VCommonProperties.ColumnName.PRP_NM + ")"
+ = INSERT + INTO + "?" + "("
//$NON-NLS-1$ //$NON-NLS-2$
+ + JDBCNames.VCommonProperties.ColumnName.PRP_UID
+ "," //$NON-NLS-1$
+ + "?," +
JDBCNames.VCommonProperties.ColumnName.PRP_NM + ")" //$NON-NLS-1$ //$NON-NLS-2$
+ VALUES
- + "(?,?,?)";
+ + "(?,?,?)"; //$NON-NLS-1$
public static final String INSERT_PROP_VALUES
- = INSERT + INTO + "?" + "("
- + JDBCNames.VCommonProperties.ColumnName.PRP_UID
+ ","
- + JDBCNames.VCommonProperties.ColumnName.PART_ID
+ ","
- + JDBCNames.VCommonProperties.ColumnName.PRP_VL +
")"
+ = INSERT + INTO + "?" + "("
//$NON-NLS-1$ //$NON-NLS-2$
+ + JDBCNames.VCommonProperties.ColumnName.PRP_UID
+ "," //$NON-NLS-1$
+ + JDBCNames.VCommonProperties.ColumnName.PART_ID
+ "," //$NON-NLS-1$
+ + JDBCNames.VCommonProperties.ColumnName.PRP_VL +
")" //$NON-NLS-1$
+ VALUES
- + "(?,?,?)";
+ + "(?,?,?)"; //$NON-NLS-1$
//update statement
public static final String UPDATE_SET_STATUS
= UPDATE + JDBCNames.VirtualDatabases.TABLE_NAME
+ SET
- +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=?,"
- +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY + "=?,"
- +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE + "=?"
+ +
JDBCNames.VirtualDatabases.ColumnName.VDB_STATUS + "=?," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY + "=?," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE + "=?" //$NON-NLS-1$
+ WHERE
- + JDBCNames.VirtualDatabases.ColumnName.VDB_UID +
"=?";
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_UID +
"=?"; //$NON-NLS-1$
public static final String UPDATE_CONNECTOR_BINGING_NAME
= UPDATE + JDBCNames.VDBModels.TABLE_NAME
+ SET
- + JDBCNames.VDBModels.ColumnName.CNCTR_BNDNG_NM +
"=?"
+ + JDBCNames.VDBModels.ColumnName.CNCTR_BNDNG_NM +
"=?" //$NON-NLS-1$
+ WHERE
- + JDBCNames.VDBModels.ColumnName.VDB_UID +
"=?"
+ + JDBCNames.VDBModels.ColumnName.VDB_UID +
"=?" //$NON-NLS-1$
+ AND
- + JDBCNames.VDBModels.ColumnName.MDL_UID +
"=?";
+ + JDBCNames.VDBModels.ColumnName.MDL_UID +
"=?"; //$NON-NLS-1$
// public static final String UPDATE_VISIBILITY_LEVELS
// = UPDATE + JDBCNames.VDBModels.TABLE_NAME
@@ -377,33 +375,33 @@
public static final String UPDATE_VDB
= UPDATE + JDBCNames.VirtualDatabases.TABLE_NAME
+ SET
- +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY + "=?,"
- +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE + "=?"
+ +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_BY + "=?," //$NON-NLS-1$
+ +
JDBCNames.VirtualDatabases.ColumnName.UPDATED_DATE + "=?" //$NON-NLS-1$
+ WHERE
- + JDBCNames.VirtualDatabases.ColumnName.VDB_UID +
"=?";
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_UID +
"=?"; //$NON-NLS-1$
public static final String UPDATE_VDB_VERSION
= UPDATE + JDBCNames.VirtualDatabases.TABLE_NAME
+ SET
- +
JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + "=?"
+ +
JDBCNames.VirtualDatabases.ColumnName.VDB_VERSION + "=?" //$NON-NLS-1$
+ WHERE
- + JDBCNames.VirtualDatabases.ColumnName.VDB_UID +
"=?";
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_UID +
"=?"; //$NON-NLS-1$
public static final String UPDATE_VDB_MODELS
= UPDATE + JDBCNames.VDBModels.TABLE_NAME
+ SET
- + JDBCNames.VDBModels.ColumnName.MDL_UID +
"=?"
+ + JDBCNames.VDBModels.ColumnName.MDL_UID +
"=?" //$NON-NLS-1$
+ WHERE
- + JDBCNames.VDBModels.ColumnName.VDB_UID +
"=?"
+ + JDBCNames.VDBModels.ColumnName.VDB_UID +
"=?" //$NON-NLS-1$
+ AND
- + JDBCNames.VDBModels.ColumnName.MDL_UID +
"=?";
+ + JDBCNames.VDBModels.ColumnName.MDL_UID +
"=?"; //$NON-NLS-1$
public static final String UPDATE_MODEL_NAME
= UPDATE + JDBCNames.Models.TABLE_NAME
+ SET
- + JDBCNames.Models.ColumnName.MDL_NM +
"=?"
+ + JDBCNames.Models.ColumnName.MDL_NM +
"=?" //$NON-NLS-1$
+ WHERE
- + JDBCNames.Models.ColumnName.MDL_UID +
"=?";
+ + JDBCNames.Models.ColumnName.MDL_UID +
"=?"; //$NON-NLS-1$
@@ -411,41 +409,41 @@
= DELETE + FROM +
JDBCNames.ModelPropValues.TABLE_NAME
+ WHERE
+ JDBCNames.ModelPropValues.ColumnName.PRP_UID
- + IN + "("
+ + IN + "(" //$NON-NLS-1$
+ SELECT
+ JDBCNames.ModelPropValues.ColumnName.PRP_UID
+ FROM
+ JDBCNames.ModelPropNames.TABLE_NAME
+ WHERE
- + JDBCNames.ModelPropNames.ColumnName.MDL_UID
+"=?)";
+ + JDBCNames.ModelPropNames.ColumnName.MDL_UID
+"=?)"; //$NON-NLS-1$
public static final String DELETE_MODEL_PROP_NMS
= DELETE + FROM +
JDBCNames.ModelPropNames.TABLE_NAME
+ WHERE
- + JDBCNames.ModelPropNames.ColumnName.MDL_UID +
"=?";
+ + JDBCNames.ModelPropNames.ColumnName.MDL_UID +
"=?"; //$NON-NLS-1$
public static final String DELETE_VDB_MODELS
= DELETE + FROM + JDBCNames.VDBModels.TABLE_NAME
+ WHERE
- + JDBCNames.VDBModels.ColumnName.VDB_UID +
"=?";
+ + JDBCNames.VDBModels.ColumnName.VDB_UID +
"=?"; //$NON-NLS-1$
public static final String DELETE_VDB_MODEL
= DELETE + FROM + JDBCNames.VDBModels.TABLE_NAME
+ WHERE
- + JDBCNames.VDBModels.ColumnName.VDB_UID +
"=?"
+ + JDBCNames.VDBModels.ColumnName.VDB_UID +
"=?" //$NON-NLS-1$
+ AND
- + JDBCNames.VDBModels.ColumnName.MDL_UID +
"=?";
+ + JDBCNames.VDBModels.ColumnName.MDL_UID +
"=?"; //$NON-NLS-1$
public static final String DELETE_MODEL
= DELETE + FROM + JDBCNames.Models.TABLE_NAME
+ WHERE
- + JDBCNames.Models.ColumnName.MDL_UID +
"=?";
+ + JDBCNames.Models.ColumnName.MDL_UID +
"=?"; //$NON-NLS-1$
public static final String DELETE_VDB
= DELETE + FROM +
JDBCNames.VirtualDatabases.TABLE_NAME
+ WHERE
- + JDBCNames.VirtualDatabases.ColumnName.VDB_UID +
"=?";
+ + JDBCNames.VirtualDatabases.ColumnName.VDB_UID +
"=?"; //$NON-NLS-1$
@@ -639,20 +637,20 @@
int i;
if(id instanceof ModelID){
- i = sql.indexOf("?");
+ i = sql.indexOf("?"); //$NON-NLS-1$
if(queryID == 1){
sql = sql.substring(0,i) + JDBCNames.VModelProperties.TABLE_NAME +
sql.substring(i+1);
- int j = sql.indexOf("=");
- sql = sql.substring(0,j) + JDBCNames.ModelPropNames.TABLE_NAME +
"."
- + JDBCNames.VCommonProperties.ColumnName.PRP_UID + "="
- + JDBCNames.ModelPropValues.TABLE_NAME + "."
+ int j = sql.indexOf("="); //$NON-NLS-1$
+ sql = sql.substring(0,j) + JDBCNames.ModelPropNames.TABLE_NAME +
"." //$NON-NLS-1$
+ + JDBCNames.VCommonProperties.ColumnName.PRP_UID + "="
//$NON-NLS-1$
+ + JDBCNames.ModelPropValues.TABLE_NAME + "." //$NON-NLS-1$
+ JDBCNames.VCommonProperties.ColumnName.PRP_UID +
sql.substring(j+1);
}else if(queryID ==2)
sql = sql.substring(0,i) + JDBCNames.ModelPropNames.TABLE_NAME +
sql.substring(i+1);
else
sql = sql.substring(0,i) + JDBCNames.ModelPropValues.TABLE_NAME +
sql.substring(i+1);
if(queryID != 3){
- i = sql.indexOf("?");
+ i = sql.indexOf("?"); //$NON-NLS-1$
sql = sql.substring(0,i) + JDBCNames.VModelProperties.ColumnName.MDL_UID
+ sql.substring(i+1);
}
}
Modified:
trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/ExtensionModuleConnection.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/ExtensionModuleConnection.java 2009-04-03
01:31:23 UTC (rev 697)
+++
trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/ExtensionModuleConnection.java 2009-04-03
01:38:17 UTC (rev 698)
@@ -11,6 +11,7 @@
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
import com.metamatrix.common.config.model.ConfigurationModelContainerAdapter;
import com.metamatrix.common.connection.ManagedConnectionException;
+import com.metamatrix.common.extensionmodule.ExtensionModuleManager;
import com.metamatrix.common.extensionmodule.ExtensionModuleTypes;
import com.metamatrix.common.extensionmodule.exception.ExtensionModuleNotFoundException;
import com.metamatrix.common.extensionmodule.spi.ExtensionModuleTransaction;
@@ -113,12 +114,12 @@
boolean inUse = trans.isNameInUse(model.getConfigurationID().getFullName());
if (inUse) {
- trans.setSource(principal, model.getConfigurationID().getFullName(),
data, data.length);
+ trans.setSource(principal, model.getConfigurationID().getFullName(),
data, ExtensionModuleManager.getChecksum(data));
} else {
trans.addSource(principal,
ExtensionModuleTypes.CONFIGURATION_MODEL_TYPE,
model.getConfigurationID().getFullName(),
data,
- data.length,
+ ExtensionModuleManager.getChecksum(data),
model.getConfigurationID().getFullName() + "
Configuration Model", //$NON-NLS-1$
true);
Modified:
trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataHelper.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataHelper.java 2009-04-03
01:31:23 UTC (rev 697)
+++
trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataHelper.java 2009-04-03
01:38:17 UTC (rev 698)
@@ -36,10 +36,9 @@
import com.metamatrix.admin.api.objects.AdminOptions;
import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.security.AuthorizationMgmtException;
import com.metamatrix.common.jdbc.JDBCPlatform;
-import com.metamatrix.common.jdbc.JDBCPlatformFactory;
+import com.metamatrix.common.jdbc.JDBCPlatform.Supported;
import com.metamatrix.common.tree.basic.BasicTreeNode;
import com.metamatrix.common.vdb.api.ModelInfo;
import com.metamatrix.core.MetaMatrixRuntimeException;
@@ -836,26 +835,23 @@
// Example: jdbc:mmx:oracle://host:port;SID=sid
if ( url != null ) {
- try {
- JDBCPlatform platform = JDBCPlatformFactory.getPlatform(url, driver);
- if (platform != null) {
- if (platform.isDB2()) {
- return DatabaseDialect.DB2.getType().toLowerCase();
- } else if (platform.isOracle()) {
- return DatabaseDialect.ORACLE.getType().toLowerCase();
- } else if (platform.isSybase()) {
- return DatabaseDialect.SYBASE.getType().toLowerCase();
- } else if (platform.isMSSQL()) {
- return DatabaseDialect.SQL_SERVER.getType().toLowerCase();
- } else if (platform.isMYSQL()) {
- return DatabaseDialect.MYSQL.getType().toLowerCase();
- }
- }
- } catch (MetaMatrixException err) {
- err.printStackTrace();
+ Supported supported = JDBCPlatform.getSupportedByProtocol(url);
+ if (supported != null) {
+ switch (supported) {
+ case DB2:
+ return DatabaseDialect.DB2.getType().toLowerCase();
+ case MM_ORACLE:
+ case ORACLE:
+ return DatabaseDialect.ORACLE.getType().toLowerCase();
+ case SYBASE:
+ return DatabaseDialect.SYBASE.getType().toLowerCase();
+ case MSSQL:
+ return DatabaseDialect.SQL_SERVER.getType().toLowerCase();
+ case MYSQL:
+ return DatabaseDialect.MYSQL.getType().toLowerCase();
+ }
}
-
Object[] urlParts = StringUtil.split(url, ":").toArray();
//$NON-NLS-1$
if (urlParts.length >= 3) {