[teiid-commits] teiid SVN: r1910 - in trunk: client/src/main/java/org/teiid/transport and 9 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Thu Mar 4 14:47:05 EST 2010
Author: shawkins
Date: 2010-03-04 14:47:03 -0500 (Thu, 04 Mar 2010)
New Revision: 1910
Removed:
trunk/client/src/main/java/com/metamatrix/common/comm/platform/client/
trunk/common-core/src/main/java/com/metamatrix/common/protocol/
Modified:
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDataSource.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMCallableStatement.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDataSource.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java
trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
trunk/client-jdbc/src/main/java/org/teiid/jdbc/SocketProfile.java
trunk/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDriver.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMPreparedStatement.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java
trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java
trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
trunk/client/src/main/java/org/teiid/transport/LocalServerConnection.java
Log:
TEIID-833 committing JCA merge
Modified: trunk/client/src/main/java/org/teiid/transport/LocalServerConnection.java
===================================================================
--- trunk/client/src/main/java/org/teiid/transport/LocalServerConnection.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client/src/main/java/org/teiid/transport/LocalServerConnection.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -26,15 +26,12 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Properties;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.security.LogonException;
import com.metamatrix.client.ExceptionUtil;
@@ -48,7 +45,7 @@
import com.metamatrix.platform.security.api.SessionToken;
public class LocalServerConnection implements ServerConnection {
- private static final String TEIID_RUNTIME = "teiid/engine-deployer";
+ private static final String TEIID_RUNTIME = "teiid/engine-deployer"; //$NON-NLS-1$
private final LogonResult result;
private boolean shutdown;
@@ -119,14 +116,8 @@
if (writeFuture != null) {
writeFuture.get(5000, TimeUnit.MILLISECONDS);
}
- } catch (InvalidSessionException e) {
+ } catch (Exception e) {
//ignore
- } catch (InterruptedException e) {
- //ignore
- } catch (ExecutionException e) {
- //ignore
- } catch (TimeoutException e) {
- //ignore
}
}
this.shutdown = true;
@@ -141,6 +132,7 @@
return (conn instanceof LocalServerConnection);
}
+ @SuppressWarnings("unchecked")
protected <T> T lookup(String jndiName) throws NamingException {
InitialContext ic = new InitialContext();
return (T)ic.lookup(jndiName);
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -23,7 +23,6 @@
package com.metamatrix.jdbc;
import java.io.PrintWriter;
-import java.io.Serializable;
import java.sql.Connection;
import java.sql.SQLException;
import java.text.MessageFormat;
@@ -141,18 +140,6 @@
*/
private String description;
- /**
- * The <code>Serializable</code> client token that will be passed directly
- * through to the connectors, which may use it and/or pass it down to their underlying data source.
- * This property is <i>optional</i>.
- * <p>
- * The form and type of the client token is up to the client but it <i>must</i> implement the
- * <code>Serializabe</code> interface. Teiid does nothing with this token except to make it
- * available for authentication/augmentation/replacement upon authentication to the system and to
- * connectors that may require it at the data source level.
- * </p>
- */
- private Serializable clientToken;
/**
* The user's name.
@@ -274,12 +261,6 @@
props.setProperty(BaseDataSource.APP_NAME,this.getApplicationName());
}
- Serializable token = this.getClientToken();
- if ( token != null ) {
- // Special case: token is a Serializable, not necessarily a String
- props.put(MMURL.CONNECTION.CLIENT_TOKEN_PROP, token);
- }
-
if (this.getPartialResultsMode() != null && this.getPartialResultsMode().trim().length() != 0) {
props.setProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE, this.getPartialResultsMode());
}
@@ -317,11 +298,6 @@
throw new SQLException(reason);
}
- reason = reasonWhyInvalidClientToken(this.clientToken);
- if ( reason != null ) {
- throw new SQLException(reason);
- }
-
reason = reasonWhyInvalidDatabaseName(this.databaseName);
if ( reason != null ) {
throw new SQLException(reason);
@@ -553,23 +529,7 @@
}
/**
- * Get the <code>Serializable</code> client token that will be passed directly
- * through to the connectors, which may use it and/or pass it down to their underlying data source.
- * This property is <i>optional</i>.
- * <p>
- * The form and type of the client token is up to the client but it <i>must</i> implement the
- * <code>Serializabe</code> interface. Teiid does nothing with this token except to make it
- * available for authentication/augmentation/replacement upon authentication to the system and to
- * connectors that may require it at the data source level.
- * </p>
- * @return The client token that was supplied by the client at system connection time; may be <code>null</code>.
- */
- public Serializable getClientToken() {
- return clientToken;
- }
-
- /**
- * Sets the name of the application. Supplying this property may allow an administrator of a
+< * Sets the name of the application. Supplying this property may allow an administrator of a
* Teiid Server to better identify individual connections and usage patterns.
* This property is <i>optional</i>.
* @param applicationName The applicationName to set
@@ -621,22 +581,6 @@
}
/**
- * Set the <code>Serializable</code> client token that will be passed directly
- * through to the connectors, which may use it and/or pass it down to their underlying data source.
- * This property is <i>optional</i>.
- * <p>
- * The form and type of the client token is up to the client but it <i>must</i> implement the
- * <code>Serializabe</code> interface. Teiid does nothing with this token except to make it
- * available for authentication/augmentation/replacement upon authentication to the system and to
- * connectors that may require it at the data source level.
- * </p>
- * @param clientToken The client token that will be passed with this user's requests.
- */
- public void setClientToken(Serializable clientToken) {
- this.clientToken = clientToken;
- }
-
- /**
* Sets the description of this data source.
* @param description The description for this data source; may be null
*/
@@ -760,17 +704,8 @@
return null; // anything is valid
}
- /**
- * Return the reason why the supplied client token may be invalid, or null
- * if it is considered valid.
- * @param clientToken a possible value for the property
- * @return the reason why the property is invalid, or null if it is considered valid
- * @see #setClientToken(Serializable)
- */
- public static String reasonWhyInvalidClientToken(final Serializable clientToken) {
- return null; // it is optional
- }
+
/**
* Return the reason why the supplied virtual database name may be invalid, or null
* if it is considered valid.
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDataSource.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDataSource.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDataSource.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -33,23 +33,4 @@
}
- /**
- * Returns the path and file name from which embedded DQP configuration information will be read.
- *
- * @return the name of the config file for this data source; may be null
- */
- public String getBootstrapFile() {
- return getEmbeddedBootstrapFile();
- }
-
- /**
- * Sets file name from which embedded DQP configuration information * will be read.
- *
- * @param configFile
- * The name of the config file name to set
- */
- public void setBootstrapFile(final String configFile) {
- setEmbeddedBootstrapFile(configFile);
- }
-
}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMCallableStatement.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMCallableStatement.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMCallableStatement.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -51,6 +51,8 @@
import com.metamatrix.common.util.SqlUtil;
import com.metamatrix.common.util.TimestampWithTimezone;
import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.RequestMessage.ResultsMode;
+import com.metamatrix.dqp.message.RequestMessage.StatementType;
/**
* <p> This class inherits Statement methods, which deal with SQL statements in
@@ -91,10 +93,9 @@
@Override
protected RequestMessage createRequestMessage(String[] commands,
- boolean isBatchedCommand, Boolean requiresResultSet) {
- RequestMessage message = super.createRequestMessage(commands, isBatchedCommand, requiresResultSet);
- message.setCallableStatement(true);
- message.setPreparedStatement(false);
+ boolean isBatchedCommand, ResultsMode resultsMode) {
+ RequestMessage message = super.createRequestMessage(commands, isBatchedCommand, resultsMode);
+ message.setStatementType(StatementType.CALLABLE);
return message;
}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -57,8 +57,6 @@
import javax.transaction.xa.Xid;
-import org.teiid.adminapi.Admin;
-
import com.metamatrix.common.api.MMURL;
import com.metamatrix.common.comm.api.ServerConnection;
import com.metamatrix.common.comm.exception.CommunicationException;
@@ -67,6 +65,7 @@
import com.metamatrix.common.xa.MMXid;
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.jdbc.api.ExecutionProperties;
/**
@@ -215,7 +214,7 @@
String key = (String)enumeration.nextElement();
Object anObj = info.get(key);
// Log each property except for password and token.
- if (!MMURL.JDBC.CREDENTIALS.equalsIgnoreCase(key) && !MMURL.CONNECTION.PASSWORD.equalsIgnoreCase(key) && !MMURL.CONNECTION.CLIENT_TOKEN_PROP.equalsIgnoreCase(key)) {
+ if (!MMURL.CONNECTION.PASSWORD.equalsIgnoreCase(key)) {
logger.fine(key+"="+anObj); //$NON-NLS-1$
}
}
@@ -225,14 +224,6 @@
String getUrl() {
return this.url;
}
-
- /**
- * @see com.metamatrix.jdbc.api.Connection#getAdminAPI()
- * @since 4.3
- */
- public synchronized Admin getAdminAPI() throws SQLException {
- return this.serverConn.getService(Admin.class);
- }
/**
* Connection identifier of this connection
@@ -240,7 +231,7 @@
* @throws SQLException
*/
public String getConnectionId() {
- return this.serverConn.getLogonResult().getSessionID().toString();
+ return String.valueOf(this.serverConn.getLogonResult().getSessionID());
}
long currentRequestId() {
@@ -287,7 +278,7 @@
} catch (SQLException se) {
firstException = se;
} finally {
- this.serverConn.shutdown();
+ this.serverConn.close();
if ( firstException != null )
throw (SQLException)firstException;
}
@@ -357,8 +348,9 @@
private void directCommit() throws SQLException {
try {
- this.dqp.commit();
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.commit();
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
logger.fine(JDBCPlugin.Util.getString("MMConnection.Commit_success")); //$NON-NLS-1$
@@ -483,12 +475,12 @@
checkConnection();
//get the virtual database name to which we are connected.
- return this.serverConn.getLogonResult().getProductInfo(MMURL.JDBC.VDB_NAME);
+ return this.serverConn.getLogonResult().getVdbName();
}
- public String getVDBVersion() throws SQLException {
+ public int getVDBVersion() throws SQLException {
checkConnection();
- return this.serverConn.getLogonResult().getProductInfo(MMURL.JDBC.VDB_VERSION);
+ return this.serverConn.getLogonResult().getVdbVersion();
}
/**
@@ -726,8 +718,9 @@
if (!autoCommitFlag) {
try {
try {
- this.dqp.rollback();
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.rollback();
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
logger.fine(JDBCPlugin.Util.getString("MMConnection.Rollback_success")); //$NON-NLS-1$
@@ -812,8 +805,9 @@
transactionXid = null;
this.autoCommitFlag = true;
try {
- this.dqp.commit(arg0, arg1);
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.commit(arg0, arg1);
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
}
@@ -822,8 +816,9 @@
checkConnection();
this.autoCommitFlag = true;
try {
- this.dqp.end(arg0, arg1);
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.end(arg0, arg1);
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
}
@@ -831,8 +826,9 @@
protected void forgetTransaction(MMXid arg0) throws SQLException {
checkConnection();
try {
- this.dqp.forget(arg0);
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.forget(arg0);
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
}
@@ -841,8 +837,9 @@
checkConnection();
transactionXid = null;
try {
- return this.dqp.prepare(arg0);
- } catch (XATransactionException e) {
+ ResultsFuture<Integer> future = this.dqp.prepare(arg0);
+ return future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
}
@@ -850,8 +847,9 @@
protected Xid[] recoverTransaction(int arg0) throws SQLException {
checkConnection();
try {
- return this.dqp.recover(arg0);
- } catch (XATransactionException e) {
+ ResultsFuture<Xid[]> future = this.dqp.recover(arg0);
+ return future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
}
@@ -861,8 +859,9 @@
transactionXid = null;
this.autoCommitFlag = true;
try {
- this.dqp.rollback(arg0);
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.rollback(arg0);
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
}
@@ -870,8 +869,9 @@
protected void startTransaction(MMXid arg0, int arg1, int timeout) throws SQLException {
checkConnection();
try {
- this.dqp.start(arg0, arg1, timeout);
- } catch (XATransactionException e) {
+ ResultsFuture<?> future = this.dqp.start(arg0, arg1, timeout);
+ future.get();
+ } catch (Exception e) {
throw MMSQLException.create(e);
}
transactionXid = arg0;
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDataSource.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDataSource.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDataSource.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -68,11 +68,6 @@
*/
private String serverName;
- /**
- * Specify a set of data source credentials to pass to the connectors as defined in
- * {@link MMURL.JDBC.CREDENTIALS}.
- */
- private String credentials;
/**
* Specify whether to make a secure (SSL, mms:) connection or a normal non-SSL mm: connection.
@@ -115,10 +110,6 @@
props.setProperty(MMURL.CONNECTION.AUTO_FAILOVER, this.getAutoFailover());
}
- if (this.getCredentials() != null) {
- props.setProperty(MMURL.JDBC.CREDENTIALS, this.getCredentials());
- }
-
if (this.getDiscoveryStrategy() != null) {
props.setProperty(MMURL.CONNECTION.DISCOVERY_STRATEGY, this.getDiscoveryStrategy());
}
@@ -248,14 +239,6 @@
}
/**
- * Returns the credentials string defining credentials to use with connectors for per-user logon.
- * @since 4.3.2
- */
- public String getCredentials() {
- return credentials;
- }
-
- /**
* Returns a flag indicating whether to create a secure connection or not.
* @return True if using secure mms: protocol, false for normal mm: protocol.
* @since 5.0.2
@@ -297,14 +280,6 @@
}
/**
- * Sets the credentials string defining credentials to use with connectors for per-user logon.
- * @since 4.3.2
- */
- public void setCredentials(final String credentials) {
- this.credentials = credentials;
- }
-
- /**
* Sets the secure flag to use mms: protocol instead of the default mm: protocol.
* @param secure True to use mms:
* @since 5.0.2
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -46,6 +46,7 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.MMJDBCSQLTypeInfo;
import com.metamatrix.common.util.SqlUtil;
+import com.metamatrix.core.CoreConstants;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.dqp.message.ResultsMessage;
import com.metamatrix.dqp.metadata.ResultsMetadataConstants;
@@ -63,6 +64,8 @@
*/
public class MMDatabaseMetaData extends WrapperImpl implements com.metamatrix.jdbc.api.DatabaseMetaData {
+ private static final String DATA_TYPES = "DataTypes"; //$NON-NLS-1$
+
private static Logger logger = Logger.getLogger("org.teiid.jdbc"); //$NON-NLS-1$
/** CONSTANTS */
@@ -122,7 +125,7 @@
private final static String LIKE_ESCAPE = " LIKE ? ESCAPE '" + ESCAPE_SEARCH_STRING + "' ";//$NON-NLS-1$//$NON-NLS-2$
final private static class RUNTIME_MODEL{
- public final static String VIRTUAL_MODEL_NAME = "System"; //$NON-NLS-1$
+ public final static String VIRTUAL_MODEL_NAME = CoreConstants.SYSTEM_MODEL;
}
private static final String TYPE_MAPPING;
@@ -1786,24 +1789,24 @@
Map[] metadataList = new Map[18];
- metadataList[0] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.TYPE_NAME, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[1] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.DATA_TYPE, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[2] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.PRECISION, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[3] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.LITERAL_PREFIX, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[4] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.LITERAL_SUFFIX, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[5] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.CREATE_PARAMS, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[6] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.NULLABLE, MMJDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[7] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.CASE_SENSITIVE, MMJDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE);//$NON-NLS-1$
- metadataList[8] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.SEARCHABLE, MMJDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[9] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.UNSIGNED_ATTRIBUTE, MMJDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[10] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.FIXED_PREC_SCALE, MMJDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[11] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.AUTOINCREMENT, MMJDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE);//$NON-NLS-1$
- metadataList[12] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.LOCAL_TYPE_NAME, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[13] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.MINIMUM_SCALE, MMJDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[14] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.MAXIMUM_SCALE, MMJDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[15] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.SQL_DATA_TYPE, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[16] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.SQL_DATETIME_SUB, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
- metadataList[17] = getColumnMetadata("System.DataTypes", JDBCColumnNames.TYPE_INFO.NUM_PREC_RADIX, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[0] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.TYPE_NAME, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[1] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.DATA_TYPE, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[2] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.PRECISION, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[3] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.LITERAL_PREFIX, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[4] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.LITERAL_SUFFIX, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[5] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.CREATE_PARAMS, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[6] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.NULLABLE, MMJDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[7] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.CASE_SENSITIVE, MMJDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE);//$NON-NLS-1$
+ metadataList[8] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.SEARCHABLE, MMJDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[9] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.UNSIGNED_ATTRIBUTE, MMJDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[10] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.FIXED_PREC_SCALE, MMJDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[11] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.AUTOINCREMENT, MMJDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE);//$NON-NLS-1$
+ metadataList[12] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.LOCAL_TYPE_NAME, MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[13] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.MINIMUM_SCALE, MMJDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[14] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.MAXIMUM_SCALE, MMJDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[15] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.SQL_DATA_TYPE, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[16] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.SQL_DATETIME_SUB, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE);//$NON-NLS-1$
+ metadataList[17] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.NUM_PREC_RADIX, MMJDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE);//$NON-NLS-1$
ResultSetMetaData rmetadata = ResultsMetadataWithProvider.newInstance(StaticMetadataProvider.createWithData(metadataList, 0));
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -43,7 +43,6 @@
import com.metamatrix.common.util.ApplicationInfo;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.jdbc.api.ConnectionProperties;
import com.metamatrix.jdbc.util.MMJDBCURL;
/**
@@ -140,7 +139,7 @@
MMConnection createMMConnection(String url, Properties info)
throws ConnectionException, CommunicationException {
- ServerConnection serverConn = SocketServerConnectionFactory.getInstance().createConnection(info);
+ ServerConnection serverConn = SocketServerConnectionFactory.getInstance().getConnection(info);
// construct a MMConnection object.
MMConnection connection = new MMConnection(serverConn, info, url);
@@ -238,7 +237,6 @@
dpis.add(dpi);
dpis.add(new DriverPropertyInfo(BaseDataSource.USER_NAME, info.getProperty(BaseDataSource.USER_NAME)));
dpis.add(new DriverPropertyInfo(BaseDataSource.PASSWORD, info.getProperty(BaseDataSource.PASSWORD)));
- dpis.add(new DriverPropertyInfo(ConnectionProperties.PROP_CLIENT_SESSION_PAYLOAD, info.getProperty(BaseDataSource.PASSWORD)));
return dpis;
}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -60,6 +60,8 @@
import com.metamatrix.core.util.ObjectConverterUtil;
import com.metamatrix.dqp.client.MetadataResult;
import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.RequestMessage.ResultsMode;
+import com.metamatrix.dqp.message.RequestMessage.StatementType;
import com.metamatrix.jdbc.api.ExecutionProperties;
/**
@@ -186,7 +188,7 @@
@Override
//## JDBC4.0-end ##
public boolean execute() throws SQLException {
- executeSql(new String[] {this.prepareSql}, false, null);
+ executeSql(new String[] {this.prepareSql}, false, ResultsMode.EITHER);
return hasResultSet();
}
@@ -196,7 +198,7 @@
return new int[0];
}
try{
- executeSql(new String[] {this.prepareSql}, true, false);
+ executeSql(new String[] {this.prepareSql}, true, ResultsMode.UPDATECOUNT);
}finally{
batchParameterList.clear();
}
@@ -207,7 +209,7 @@
@Override
//## JDBC4.0-end ##
public ResultSet executeQuery() throws SQLException {
- executeSql(new String[] {this.prepareSql}, false, true);
+ executeSql(new String[] {this.prepareSql}, false, ResultsMode.RESULTSET);
return resultSet;
}
@@ -215,17 +217,17 @@
@Override
//## JDBC4.0-end ##
public int executeUpdate() throws SQLException {
- executeSql(new String[] {this.prepareSql}, false, false);
+ executeSql(new String[] {this.prepareSql}, false, ResultsMode.UPDATECOUNT);
return this.updateCounts[0];
}
@Override
protected RequestMessage createRequestMessage(String[] commands,
- boolean isBatchedCommand, Boolean requiresResultSet) {
- RequestMessage message = super.createRequestMessage(commands, false, requiresResultSet);
- message.setPreparedStatement(true);
+ boolean isBatchedCommand, ResultsMode resultsMode) {
+ RequestMessage message = super.createRequestMessage(commands, false, resultsMode);
+ message.setStatementType(StatementType.PREPARED);
message.setParameterValues(isBatchedCommand?getParameterValuesList(): getParameterValues());
- message.setPreparedBatchUpdate(isBatchedCommand);
+ message.setBatchedUpdate(isBatchedCommand);
return message;
}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -127,7 +127,7 @@
this.statement = statement;
this.parameters = parameters;
// server latency-related timestamp
- this.processingTimestamp = resultsMsg.getProcessingTimestamp();
+ this.processingTimestamp = statement.getProcessingTimestamp();
this.requestID = statement.getCurrentRequestID();
this.cursorType = statement.getResultSetType();
this.batchResults = new BatchResults(this, getCurrentBatch(resultsMsg), this.cursorType == ResultSet.TYPE_FORWARD_ONLY ? 1 : BatchResults.DEFAULT_SAVED_BATCHES);
@@ -1121,7 +1121,7 @@
}
protected void setResultsData(ResultsMessage resultsMsg) {
- this.completedTimestamp = resultsMsg.getCompletedTimestamp();
+ this.completedTimestamp = new java.util.Date();
this.statement.accumulateWarnings(resultsMsg.getWarnings());
}
@@ -1191,9 +1191,9 @@
}
/**
- * Gets the time command execution is compleated on the server.
+ * Gets the time command execution is completed on the server.
*
- * @return Date object representing time the commond finished execution.
+ * @return Date object representing time the command finished execution.
*/
public java.util.Date getCompletedTimestamp() throws SQLException {
checkClosed();
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -22,7 +22,6 @@
package com.metamatrix.jdbc;
-import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
@@ -33,6 +32,7 @@
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
+import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -51,12 +51,13 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.util.SqlUtil;
+import com.metamatrix.core.util.ObjectConverterUtil;
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.dqp.message.ParameterInfo;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.message.ResultsMessage;
+import com.metamatrix.dqp.message.RequestMessage.ResultsMode;
import com.metamatrix.jdbc.api.Annotation;
import com.metamatrix.jdbc.api.ExecutionProperties;
import com.metamatrix.jdbc.api.PlanNode;
@@ -157,6 +158,8 @@
private Pattern setStatement = Pattern.compile("\\s*set\\s*(\\w+)\\s*=\\s*(\\w*)", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
+ private Date processingTimestamp;
+
/**
* Factory Constructor
* @param driverConnection
@@ -318,7 +321,7 @@
@Override
//## JDBC4.0-end ##
public boolean execute(String sql) throws SQLException {
- executeSql(new String[] {sql}, false, null);
+ executeSql(new String[] {sql}, false, ResultsMode.EITHER);
return hasResultSet();
}
@@ -330,7 +333,7 @@
return new int[0];
}
String[] commands = (String[])batchedUpdates.toArray(new String[batchedUpdates.size()]);
- executeSql(commands, true, false);
+ executeSql(commands, true, ResultsMode.UPDATECOUNT);
return updateCounts;
}
@@ -338,7 +341,7 @@
@Override
//## JDBC4.0-end ##
public ResultSet executeQuery(String sql) throws SQLException {
- executeSql(new String[] {sql}, false, true);
+ executeSql(new String[] {sql}, false, ResultsMode.RESULTSET);
return resultSet;
}
@@ -347,7 +350,7 @@
//## JDBC4.0-end ##
public int executeUpdate(String sql) throws SQLException {
String[] commands = new String[] {sql};
- executeSql(commands, false, false);
+ executeSql(commands, false, ResultsMode.UPDATECOUNT);
return this.updateCounts[0];
}
@@ -402,13 +405,13 @@
resultSet.setMaxFieldSize(this.maxFieldSize);
}
- protected void executeSql(String[] commands, boolean isBatchedCommand, Boolean requiresResultSet)
+ protected void executeSql(String[] commands, boolean isBatchedCommand, ResultsMode resultsMode)
throws SQLException, MMSQLException {
checkStatement();
resetExecutionState();
//handle set statement
- if (commands.length == 1 && requiresResultSet != Boolean.TRUE) {
+ if (commands.length == 1 && resultsMode != ResultsMode.RESULTSET) {
Matcher match = setStatement.matcher(commands[0]);
if (match.matches()) {
String key = match.group(1);
@@ -419,7 +422,7 @@
}
}
- RequestMessage reqMessage = createRequestMessage(commands, isBatchedCommand, requiresResultSet);
+ RequestMessage reqMessage = createRequestMessage(commands, isBatchedCommand, resultsMode);
ResultsMessage resultsMsg = null;
try {
resultsMsg = sendRequestMessageAndWait(reqMessage);
@@ -449,6 +452,15 @@
for (int i = 0; i < results.length; i++) {
updateCounts[i] = (Integer)results[i].get(0);
}
+
+ // In update scenarios close the statement implicitly
+ try {
+ getDQP().closeRequest(getCurrentRequestID());
+ } catch (MetaMatrixProcessingException e) {
+ throw MMSQLException.create(e);
+ } catch (MetaMatrixComponentException e) {
+ throw MMSQLException.create(e);
+ }
} else {
createResultSet(resultsMsg);
}
@@ -457,11 +469,11 @@
}
protected RequestMessage createRequestMessage(String[] commands,
- boolean isBatchedCommand, Boolean requiresResultSet) {
+ boolean isBatchedCommand, ResultsMode resultsMode) {
RequestMessage reqMessage = new RequestMessage();
reqMessage.setCommands(commands);
reqMessage.setBatchedUpdate(isBatchedCommand);
- reqMessage.setRequireResultSet(requiresResultSet);
+ reqMessage.setResultsMode(resultsMode);
return reqMessage;
}
@@ -752,6 +764,15 @@
// Get result set cache mode
String rsCache = getExecutionProperty(ExecutionProperties.RESULT_SET_CACHE_MODE);
res.setUseResultSetCache(Boolean.valueOf(rsCache).booleanValue());
+
+ res.setAnsiQuotedIdentifiers(Boolean.valueOf(
+ getExecutionProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS))
+ .booleanValue());
+ String sqlOptions = getExecutionProperty(ExecutionProperties.PROP_SQL_OPTIONS);
+ if (sqlOptions != null &&
+ sqlOptions.toUpperCase().indexOf(ExecutionProperties.SQL_OPTION_SHOWPLAN.toUpperCase()) >= 0) {
+ res.setShowPlan(true);
+ }
}
/**
@@ -812,34 +833,13 @@
/**
* Send out request message with necessary states.
- * @param transaction UsertTransaction
- * @param sql String of command or prepared string
- * @param listener Message Listener
- * @param timeout Maybe 0
- * @param isPreparedStatement flag indicating whether this statement is a PreparedStatement
- * @param isCallableStatement flag indicating whether this statement is a CallableStatement
- * @param params Parameters values of either PreparedStatement or CallableStatement
- * @param isBatchedCommand flag indicating whether the statements are being executed as a batch
- * @throws SQLException
- * @throws TimeoutException
- * @throws InterruptedException
- * @throws CommunicationException
*/
protected ResultsMessage sendRequestMessageAndWait(RequestMessage reqMsg)
throws SQLException, InterruptedException, TimeoutException {
-
+ this.processingTimestamp = new Date();
this.currentRequestID = this.driverConnection.nextRequestID();
// Create a request message
- reqMsg.markSubmissionStart();
reqMsg.setExecutionPayload(this.payload);
- reqMsg.setAnsiQuotedIdentifiers(Boolean.valueOf(
- getExecutionProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS))
- .booleanValue());
- String sqlOptions = getExecutionProperty(ExecutionProperties.PROP_SQL_OPTIONS);
- if (sqlOptions != null &&
- sqlOptions.toUpperCase().indexOf(ExecutionProperties.SQL_OPTION_SHOWPLAN.toUpperCase()) >= 0) {
- reqMsg.setShowPlan(true);
- }
reqMsg.setCursorType(this.resultSetType);
reqMsg.setFetchSize(this.fetchSize);
reqMsg.setStyleSheet(this.styleSheet);
@@ -896,23 +896,7 @@
* @throws IOException if unable to read the style sheet from the Reader object.
*/
public void attachStylesheet(Reader reader) throws IOException {
- BufferedReader bufferedReader = null;
- StringBuffer buffer = new StringBuffer();
- try {
- bufferedReader = new BufferedReader(reader);
- while(true) {
- String line = bufferedReader.readLine();
- if(line == null) {
- break;
- }
- buffer.append( line );
- }
- } finally {
- if(bufferedReader != null) {
- bufferedReader.close();
- }
- }
- this.styleSheet = buffer.toString();
+ this.styleSheet = ObjectConverterUtil.convertToString(reader);
}
/**
@@ -972,6 +956,10 @@
public Collection getAnnotations() {
return this.annotations;
}
+
+ public Date getProcessingTimestamp() {
+ return processingTimestamp;
+ }
public void setPartialResults(boolean isPartialResults){
if(isPartialResults){
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -24,23 +24,13 @@
import java.sql.SQLException;
-import org.teiid.adminapi.Admin;
-
/**
- * MetaMatrix extensions to the standard JDBC Connection interface.
+ * Extensions to the standard JDBC Connection interface.
*/
public interface Connection extends java.sql.Connection {
- /**
- * Retrieve an administrative object used to control MM Query.
- * @return EmbeddedAdmin object to administer the MM Query component
- * corresponding to this connection.
- * @throws SQLException
- */
- Admin getAdminAPI() throws SQLException;
-
- String getVDBVersion() throws SQLException;
+ int getVDBVersion() throws SQLException;
}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -31,7 +31,6 @@
import com.metamatrix.common.api.MMURL;
import com.metamatrix.jdbc.BaseDataSource;
-import com.metamatrix.jdbc.api.ConnectionProperties;
import com.metamatrix.jdbc.api.ExecutionProperties;
@@ -59,11 +58,8 @@
ExecutionProperties.PROP_XML_FORMAT,
ExecutionProperties.PROP_XML_VALIDATION,
ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS,
- ConnectionProperties.PROP_CLIENT_SESSION_PAYLOAD,
- ConnectionProperties.PROP_CREDENTIALS,
MMURL.CONNECTION.AUTO_FAILOVER,
- MMURL.CONNECTION.DISCOVERY_STRATEGY,
- MMURL.CONNECTION.SHUTDOWN
+ MMURL.CONNECTION.DISCOVERY_STRATEGY
};
private String vdbName;
@@ -77,8 +73,7 @@
}
public MMJDBCURL(String vdbName, String connectionURL, Properties props) {
- if (vdbName == null || vdbName.trim().length() == 0 ||
- connectionURL == null || connectionURL.trim().length() == 0) {
+ if (vdbName == null || vdbName.trim().length() == 0) {
throw new IllegalArgumentException();
}
this.vdbName = vdbName;
@@ -201,9 +196,10 @@
public String getJDBCURL() {
if (urlString == null) {
StringBuffer buf = new StringBuffer(JDBC_PROTOCOL)
- .append(vdbName)
- .append('@')
- .append(connectionURL);
+ .append(vdbName);
+ if (this.connectionURL != null) {
+ buf.append('@').append(connectionURL);
+ }
for (Iterator i = properties.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry)i.next();
if (entry.getValue() instanceof String) {
Modified: trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -22,70 +22,41 @@
package org.teiid.jdbc;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.sql.Connection;
import java.sql.SQLException;
import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Enumeration;
-import java.util.List;
import java.util.Properties;
import java.util.ResourceBundle;
-import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.AdminException;
+import org.teiid.transport.LocalServerConnection;
-import com.metamatrix.common.api.MMURL;
-import com.metamatrix.common.classloader.PostDelegatingClassLoader;
-import com.metamatrix.common.comm.api.ServerConnection;
-import com.metamatrix.common.comm.api.ServerConnectionFactory;
import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.comm.exception.ConnectionException;
-import com.metamatrix.common.protocol.MMURLConnection;
-import com.metamatrix.common.protocol.MetaMatrixURLStreamHandlerFactory;
-import com.metamatrix.common.protocol.URLHelper;
import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.util.ReflectionHelper;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
+import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.jdbc.BaseDataSource;
import com.metamatrix.jdbc.JDBCPlugin;
import com.metamatrix.jdbc.MMConnection;
-import com.metamatrix.jdbc.MMSQLException;
-import com.metamatrix.jdbc.api.SQLStates;
import com.metamatrix.jdbc.util.MMJDBCURL;
final class EmbeddedProfile {
- /**
+
+ private static final String BUNDLE_NAME = "com.metamatrix.jdbc.basic_i18n"; //$NON-NLS-1$
+
+ /**
* Match URL like
- * - jdbc:metamatrix:BQT at c:/foo.properties;version=1..
- * - jdbc:metamatrix:BQT at c:\\foo.properties;version=1..
- * - jdbc:metamatrix:BQT@\\foo.properties;version=1..
- * - jdbc:metamatrix:BQT@/foo.properties;version=1..
- * - jdbc:metamatrix:BQT at ../foo.properties;version=1..
- * - jdbc:metamatrix:BQT at ./foo.properties;version=1..
- * - jdbc:metamatrix:BQT at file:///c:/foo.properties;version=1..
- * - jdbc:metamatrix:BQT
- * - jdbc:metamatrix:BQT;verson=1
+ * - jdbc:teiid:BQT
+ * - jdbc:teiid:BQT;verson=1
*/
- static final String URL_PATTERN = "jdbc:(teiid|metamatrix):(\\w+)@(([^;]*)[;]?)((.*)*)"; //$NON-NLS-1$
- static final String BASE_PATTERN = "jdbc:(teiid|metamatrix):((\\w+)[;]?)(;([^@])+)*"; //$NON-NLS-1$
+ static final String BASE_PATTERN = "jdbc:teiid:((\\w+)[;]?)(;([^@])+)*"; //$NON-NLS-1$
private static Logger logger = Logger.getLogger("org.teiid.jdbc"); //$NON-NLS-1$
- private static EmbeddedTransport currentTransport = null;
- static Pattern urlPattern = Pattern.compile(URL_PATTERN);
static Pattern basePattern = Pattern.compile(BASE_PATTERN);
/**
@@ -106,79 +77,32 @@
// parse the URL to add it's properties to properties object
parseURL(url, info);
- MMConnection conn = createConnection(info);
- boolean shutdown = Boolean.parseBoolean(info.getProperty(MMURL.CONNECTION.SHUTDOWN, "false")); //$NON-NLS-1$
- if (shutdown) {
- Admin admin = conn.getAdminAPI();
- try {
- // this will make sure the user has permissions to do the shutdown.
- admin.shutdown(0);
- shutdown();
- throw new MMSQLException(getResourceMessage("EmbeddedDriver.shutdown_sucessful"), SQLStates.SUCESS); //$NON-NLS-1$
- } catch (AdminException e) {
- conn.close();
- throw new MMSQLException(e, getResourceMessage("EmbeddedDriver.shutdown_failure"), SQLStates.DEFAULT); //$NON-NLS-1$
- }
- }
-
- // logging
- String logMsg = JDBCPlugin.Util.getString("JDBCDriver.Connection_sucess"); //$NON-NLS-1$
- logger.fine(logMsg);
-
+ MMConnection conn = createConnection(url, info);
+ logger.fine(JDBCPlugin.Util.getString("JDBCDriver.Connection_sucess")); //$NON-NLS-1$
return conn;
-
}
- static MMConnection createConnection(Properties info) throws SQLException{
+ static MMConnection createConnection(String url, Properties info) throws SQLException{
// first validate the properties as this may called from the EmbeddedDataSource
// and make sure we have all the properties we need.
validateProperties(info);
-
- URL dqpURL;
- try {
- dqpURL = URLHelper.buildURL(info.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE));
- } catch (MalformedURLException e) {
- throw MMSQLException.create(e);
+ try {
+ return new MMConnection(new LocalServerConnection(info), info, url);
+ } catch (MetaMatrixRuntimeException e) {
+ throw new SQLException(e);
+ } catch (ConnectionException e) {
+ throw new SQLException(e);
+ } catch (CommunicationException e) {
+ throw new SQLException(e);
}
-
- // now create the connection
- EmbeddedTransport transport = getDQPTransport(dqpURL);
-
- MMConnection conn = transport.createConnection(info);
-
- return conn;
}
/**
- * Get the DQP transport or build the transport if one not available from the
- * DQP URL supplied. DQP transport contains all the details about DQP.
- * @param dqpURL - URL to the DQP.properties file
- * @return EmbeddedTransport
- * @throws SQLException
- * @since 4.4
- */
- private synchronized static EmbeddedTransport getDQPTransport(URL dqpURL) throws SQLException {
- EmbeddedTransport transport = currentTransport;
- if (transport == null || !transport.isAlive() || !currentTransport.getURL().equals(dqpURL)) {
- // shutdown any previous instance; we do encourage single instance in a given VM
- shutdown();
- try {
- transport = new EmbeddedTransport(dqpURL);
- } catch (SQLException e) {
- logger.log(Level.SEVERE, "Could not start the embedded engine", e); //$NON-NLS-1$
- throw e;
- }
- }
- currentTransport = transport;
- return transport;
- }
-
- /**
* This method parses the URL and adds properties to the the properties object. These include required and any optional
* properties specified in the URL.
* Expected URL format --
- * jdbc:metamatrix:local:VDB@<pathToConfigFile>logFile=<logFile.log>; logLevel=<logLevel>;credentials=mycredentials;
+ * jdbc:teiid:VDB;[name=value]*;
*
* @param The URL needed to be parsed.
* @param The properties object which is to be updated with properties in the URL.
@@ -195,16 +119,6 @@
// Set the VDB Name
info.setProperty(BaseDataSource.VDB_NAME, jdbcURL.getVDBName());
-
- // Need to resolve the URL fully, if we are using the default URL like
- // jdbc:metamatrix:<vdbName>.., where as this fully qualifies to
- // jdbc:metamatrix:<vdbName>@classpath:<vdbName>/mm.properties;...
- String connectionURL = jdbcURL.getConnectionURL();
- if (connectionURL == null) {
- connectionURL = getDefaultConnectionURL();
- info.setProperty(DQPEmbeddedProperties.VDB_DEFINITION, jdbcURL.getVDBName()+".vdb"); //$NON-NLS-1$
- }
- info.setProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE, connectionURL);
Properties optionalParams = jdbcURL.getProperties();
MMJDBCURL.normalizeProperties(info);
@@ -231,15 +145,6 @@
}
/**
- * Create the default connection URL, if one is not supplied
- * @param jdbcURL
- * @return default connection URL
- */
- static String getDefaultConnectionURL() {
- return "classpath:/deploy.properties"; //$NON-NLS-1$
- }
-
- /**
* validate some required properties
* @param info the connection properties to be validated
* @throws SQLException
@@ -257,226 +162,12 @@
}
public static boolean acceptsURL(String url) {
- Matcher m = urlPattern.matcher(url);
- boolean matched = m.matches();
- if (matched) {
- // make sure the group (2) which is the name of the file
- // does not start with mm:// or mms://
- String name = m.group(3).toLowerCase();
- return (!name.startsWith("mm://") && !name.startsWith("mms://") && (name.endsWith(".properties")||name.endsWith(".properties;"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
// Check if this can match our default one, then allow it.
- m = basePattern.matcher(url);
- matched = m.matches();
+ Matcher m = basePattern.matcher(url);
+ boolean matched = m.matches();
return matched;
}
-
-
- /**
- * Shutdown the DQP instance which has been started using the given URL
- * @param dqpURL
- */
- public static synchronized void shutdown() {
- if (currentTransport != null) {
- currentTransport.shutdown();
- currentTransport = null;
- }
- }
-
- /**
- * inner class to hold DQP tansportMap object
- * @since 4.3
- */
- static class EmbeddedTransport {
- private ServerConnectionFactory connectionFactory;
- private ClassLoader classLoader;
- private URL url;
-
- public EmbeddedTransport(URL dqpURL) throws SQLException {
- this.url = dqpURL;
-
- //Load the properties from dqp.properties file
- Properties props = loadDQPProperties(dqpURL);
-
- props = PropertiesUtils.resolveNestedProperties(props);
-
- // a non-delegating class loader will be created from where all third party dependent jars can be loaded
- ArrayList<URL> runtimeClasspathList = new ArrayList<URL>();
- String libLocation = props.getProperty(DQPEmbeddedProperties.DQP_LIBDIR, "./lib/"); //$NON-NLS-1$
- if (!libLocation.endsWith("/")) { //$NON-NLS-1$
- libLocation = libLocation + "/"; //$NON-NLS-1$
- }
-
- // find jars in the "lib" directory; patches is reverse alpaha and not case sensitive so small letters then capitals
- if (!EmbeddedProfile.getDefaultConnectionURL().equals(dqpURL.toString())) {
- runtimeClasspathList.addAll(libClassPath(dqpURL, libLocation+"patches/", MMURLConnection.REVERSEALPHA)); //$NON-NLS-1$
- runtimeClasspathList.addAll(libClassPath(dqpURL, libLocation, MMURLConnection.DATE));
-
- try {
- String configLocation = props.getProperty(DQPEmbeddedProperties.DQP_DEPLOYDIR, "./deploy/"); //$NON-NLS-1$
- if (!configLocation.endsWith("/")) { //$NON-NLS-1$
- configLocation = configLocation + "/"; //$NON-NLS-1$
- }
- runtimeClasspathList.add(URLHelper.buildURL(dqpURL, configLocation));
- } catch(IOException e) {
- // ignore..
- }
- }
-
- URL[] dqpClassPath = runtimeClasspathList.toArray(new URL[runtimeClasspathList.size()]);
- this.classLoader = new PostDelegatingClassLoader(dqpClassPath, this.getClass().getClassLoader(), new MetaMatrixURLStreamHandlerFactory());
-
- String logMsg = getResourceMessage("EmbeddedDriver.use_classpath"); //$NON-NLS-1$
- logger.log(Level.FINER, logMsg + " " + Arrays.toString(dqpClassPath)); //$NON-NLS-1$
-
- props.setProperty(DQPEmbeddedProperties.BOOTURL, url.toExternalForm());
- props.setProperty(DQPEmbeddedProperties.TEIID_HOME, getHomeDirectory(props));
- // Now using this class loader create the connection factory to the dqp.
- ClassLoader current = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(this.classLoader);
- String className = "com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl"; //$NON-NLS-1$
- try {
- this.connectionFactory = (ServerConnectionFactory)ReflectionHelper.create(className, null, this.classLoader);
- } catch (MetaMatrixCoreException e) {
- throw MMSQLException.create(e, "Could not load the embedded server, please ensure that your classpath is set correctly."); //$NON-NLS-1$
- }
- try {
- this.connectionFactory.initialize(props);
- } catch (MetaMatrixCoreException e) {
- throw MMSQLException.create(e);
- }
- } finally {
- Thread.currentThread().setContextClassLoader(current);
- }
- }
-
- URL getURL() {
- return this.url;
- }
-
- /**
- * Note that this only works when embedded loaded with "mmfile" protocol in the URL.
- * @param dqpURL
- * @return
- */
- private List<URL> libClassPath (URL dqpURL, String directory, String sortStyle) {
- ObjectInputStream in = null;
- ArrayList<URL> urlList = new ArrayList<URL>();
- try {
- urlList.add(URLHelper.buildURL(dqpURL, directory));
- dqpURL = URLHelper.buildURL(dqpURL, directory+"?action=list&filter=.jar&sort="+sortStyle); //$NON-NLS-1$
- in = new ObjectInputStream(dqpURL.openStream());
- String[] urls = (String[])in.readObject();
- for (int i = 0; i < urls.length; i++) {
- urlList.add(URLHelper.buildURL(urls[i]));
- }
- } catch(IOException e) {
- //ignore, treat as if lib does not exist
- } catch(ClassNotFoundException e) {
- //ignore, treat as if lib does not exist
- } finally {
- if (in != null) {
- try{in.close();}catch(IOException e) {}
- }
- }
- return urlList;
- }
-
- /**
- * Load DQP Properties from the URL supplied.
- * @param dqpURL - URL to the "dqp.properties" object
- * @return Properties loaded
- * @throws SQLException
- */
- Properties loadDQPProperties(URL dqpURL) throws SQLException {
- InputStream in = null;
- try{
- in = dqpURL.openStream();
- Properties props = new Properties(System.getProperties());
- props.load(in);
-
- String logMsg = getResourceMessage("EmbeddedDriver.use_properties"); //$NON-NLS-1$
- logger.log(Level.FINER, logMsg + props);
- return props;
- }catch(IOException e) {
- String logMsg = getResourceMessage("EmbeddedTransport.invalid_dqpproperties_path", new Object[] {dqpURL}); //$NON-NLS-1$
- throw MMSQLException.create(e, logMsg);
- }finally {
- if (in != null) {
- try{in.close();}catch(IOException e) {}
- }
- }
- }
-
- /**
- * Shutdown the current transport
- */
- void shutdown() {
- this.connectionFactory.shutdown(false);
- }
-
- boolean isAlive() {
- return this.connectionFactory.isAlive();
- }
-
- /**
- * Create a connection to the DQP defined by this transport object based on
- * properties supplied
- * @param info
- * @return Connection
- */
- MMConnection createConnection(Properties info) throws SQLException {
- ClassLoader current = null;
- try {
- current = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(classLoader);
- try {
- ServerConnection conn = connectionFactory.createConnection(info);
- return new MMConnection(conn, info, url.toExternalForm());
- } catch (CommunicationException e) {
- throw MMSQLException.create(e);
- } catch (ConnectionException e) {
- throw MMSQLException.create(e);
- }
- } finally {
- Thread.currentThread().setContextClassLoader(current);
- }
- }
-
- String getHomeDirectory(Properties props) throws SQLException {
- try {
- String teiidHome = props.getProperty(DQPEmbeddedProperties.TEIID_HOME);
-
- if (teiidHome == null) {
- if (EmbeddedProfile.getDefaultConnectionURL().equals(url.toString())) {
- teiidHome = System.getProperty("user.dir")+"/teiid"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- else {
- URL installDirectory = URLHelper.buildURL(url, "."); //$NON-NLS-1$
- teiidHome = installDirectory.getPath();
- }
- }
- File f = new File(teiidHome);
- return f.getCanonicalPath();
- } catch(IOException e) {
- throw MMSQLException.create(e);
- }
- }
-
- }
- private static final String BUNDLE_NAME = "com.metamatrix.jdbc.basic_i18n"; //$NON-NLS-1$
-
-
- static String getResourceMessage(String key, Object[] args) {
- ResourceBundle messages = ResourceBundle.getBundle(BUNDLE_NAME);
- String messageTemplate = messages.getString(key);
- return MessageFormat.format(messageTemplate, args);
- }
-
-
static String getResourceMessage(String key) {
ResourceBundle messages = ResourceBundle.getBundle(BUNDLE_NAME);
String messageTemplate = messages.getString(key);
Modified: trunk/client-jdbc/src/main/java/org/teiid/jdbc/SocketProfile.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/SocketProfile.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/SocketProfile.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -105,7 +105,7 @@
static MMConnection createConnection(String url, Properties info)
throws ConnectionException, CommunicationException {
- ServerConnection serverConn = SocketServerConnectionFactory.getInstance().createConnection(info);
+ ServerConnection serverConn = SocketServerConnectionFactory.getInstance().getConnection(info);
// construct a MMConnection object.
MMConnection connection = new MMConnection(serverConn, info, url);
Modified: trunk/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -22,21 +22,17 @@
package org.teiid.jdbc;
-import java.net.URL;
import java.sql.Connection;
-import java.sql.SQLException;
import java.util.Properties;
import com.metamatrix.common.api.MMURL;
-import com.metamatrix.common.protocol.URLHelper;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.jdbc.BaseDataSource;
import com.metamatrix.jdbc.JDBCPlugin;
import com.metamatrix.jdbc.MMSQLException;
import com.metamatrix.jdbc.util.MMJDBCURL;
/**
- * The MetaMatrix JDBC DataSource implementation class of {@link javax.sql.DataSource} and
+ * The Teiid JDBC DataSource implementation class of {@link javax.sql.DataSource} and
* {@link javax.sql.XADataSource}.
* <p>
* The {@link javax.sql.DataSource} interface follows the JavaBean design pattern,
@@ -52,10 +48,11 @@
* The following are the properties for this DataSource:
* <table cellspacing="0" cellpadding="0" border="1" width="100%">
* <tr><td><b>Property Name</b></td><td><b>Type</b></td><td><b>Description</b></td></tr>
- * <tr><td>portNumber </td><td><code>int </code></td><td>The port number where a MetaMatrix Server is listening
+ * <tr><td>portNumber </td><td><code>int </code></td><td>The port number where a Teiid Server is listening
* for requests.</td></tr>
- * <tr><td>serverName </td><td><code>String</code></td><td>The hostname or IP address of the MetaMatrix Server.</td></tr>
- * <table>
+ * <tr><td>serverName </td><td><code>String</code></td><td>The hostname or IP address of the Teiid Server.</td></tr>
+ * <table>
+ * If "serverName" property is not set then data source will try to create a embedded connection to the Teiid server.
* </p>
*/
public class TeiidDataSource extends BaseDataSource {
@@ -75,12 +72,6 @@
private String serverName;
/**
- * Specify a set of data source credentials to pass to the connectors as defined in
- * {@link MMURL.JDBC.CREDENTIALS}.
- */
- private String credentials;
-
- /**
* Specify whether to make a secure (SSL, mms:) connection or a normal non-SSL mm: connection.
* the default is to use a non-secure connection.
* @since 5.0.2
@@ -102,8 +93,6 @@
private String discoveryStrategy;
- private String bootstrapFile;
-
/**
* Constructor for MMDataSource.
*/
@@ -121,10 +110,6 @@
props.setProperty(MMURL.CONNECTION.AUTO_FAILOVER, this.getAutoFailover());
}
- if (this.getCredentials() != null) {
- props.setProperty(MMURL.JDBC.CREDENTIALS, this.getCredentials());
- }
-
if (this.getDiscoveryStrategy() != null) {
props.setProperty(MMURL.CONNECTION.DISCOVERY_STRATEGY, this.getDiscoveryStrategy());
}
@@ -227,10 +212,9 @@
final TeiidDriver driver = new TeiidDriver();
// check if this is embedded connection
- if (getEmbeddedBootstrapFile() != null) {
- validateEmbeddedProperties(userName,password);
+ if (getServerName() == null) {
final Properties props = buildEmbeddedProperties(userName, password);
- String url = new MMJDBCURL(getDatabaseName(), getEmbeddedBootstrapFile(), props).getJDBCURL();
+ String url = new MMJDBCURL(getDatabaseName(), null, props).getJDBCURL();
return driver.connect(url, props);
}
@@ -243,20 +227,7 @@
private Properties buildEmbeddedProperties(final String userName, final String password) {
Properties props = buildProperties(userName, password);
-
- if (this.getEmbeddedBootstrapFile().equals(EmbeddedProfile.getDefaultConnectionURL())) {
- props.put(DQPEmbeddedProperties.VDB_DEFINITION, getDatabaseName() + ".vdb"); //$NON-NLS-1$
- }
- props.put(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE, this.bootstrapFile);
return props;
- }
-
- private void validateEmbeddedProperties(final String userName, final String password) throws java.sql.SQLException {
- super.validateProperties(userName, password);
- String reason = reasonWhyInvalidConfigFile(this.bootstrapFile);
- if (reason != null) {
- throw new SQLException(reason);
- }
}
/**
@@ -287,14 +258,6 @@
}
/**
- * Returns the credentials string defining credentials to use with connectors for per-user logon.
- * @since 4.3.2
- */
- public String getCredentials() {
- return credentials;
- }
-
- /**
* Returns a flag indicating whether to create a secure connection or not.
* @return True if using secure mms: protocol, false for normal mm: protocol.
* @since 5.0.2
@@ -336,14 +299,6 @@
}
/**
- * Sets the credentials string defining credentials to use with connectors for per-user logon.
- * @since 4.3.2
- */
- public void setCredentials(final String credentials) {
- this.credentials = credentials;
- }
-
- /**
* Sets the secure flag to use mms: protocol instead of the default mm: protocol.
* @param secure True to use mms:
* @since 5.0.2
@@ -521,46 +476,5 @@
public void setDiscoveryStrategy(String discoveryStrategy) {
this.discoveryStrategy = discoveryStrategy;
}
-
- /**
- * Returns the path and file name from which embedded DQP configuration information will be read.
- *
- * @return the name of the config file for this data source; may be null
- */
- public String getEmbeddedBootstrapFile() {
- return bootstrapFile;
- }
-
- /**
- * Sets file name from which embedded DQP configuration information * will be read.
- *
- * @param configFile
- * The name of the config file name to set
- */
- public void setEmbeddedBootstrapFile(final String configFile) {
- this.bootstrapFile = configFile;
- }
-
- /**
- * Return the reason why the supplied config file may be invalid, or null if it is considered valid.
- *
- * @param configFile
- * a possible value for the property
- * @return the reason why the property is invalid, or null if it is considered valid
- * @see #setEmbeddedBootstrapFile(String)
- */
- public static String reasonWhyInvalidConfigFile(final String configFile) {
- if(configFile == null) {
- return getResourceMessage("EmbeddedDataSource.The_configFile_property_is_null"); //$NON-NLS-1$
- }
-
- try {
- URL url = URLHelper.buildURL(configFile);
- url.openStream();
- } catch (Exception e) {
- return getResourceMessage("EmbeddedDataSource.The_configFile_does_not_exist_or_cant_be_read"); //$NON-NLS-1$
- }
- return null;
- }
}
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -32,7 +32,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
-import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import java.util.concurrent.ExecutionException;
@@ -675,35 +674,6 @@
rs.close();
}
-
- /**
- * Case 4293 - timestamps for begin and end processing should both be set
- * server-side (from the same system clock)
- */
- @Test public void testProcessingTime() throws Exception {
- RequestMessage request = new RequestMessage();
- request.setProcessingTimestamp(new Date(12345678L));
- ResultsMessage resultsMsg = new ResultsMessage(request);
-
- // these two lines not important to the test
- resultsMsg.setColumnNames(new String[] { "IntNum" }); //$NON-NLS-1$
- resultsMsg.setDataTypes(new String[] { MMJDBCSQLTypeInfo.INTEGER });
-
- // expected results
- long expectedProcessingTime = resultsMsg.getCompletedTimestamp()
- .getTime()
- - resultsMsg.getProcessingTimestamp().getTime();
-
- // sleep for a couple milliseconds
- Thread.sleep(200);
-
- MMResultSet rs = new MMResultSet(resultsMsg, statement);
-
- long actualProcessingTime = rs.getProcessingTime();
-
- assertEquals(expectedProcessingTime, actualProcessingTime);
-
- }
/**
* 3 batches
@@ -850,7 +820,6 @@
private static ResultsMessage exampleResultsMsg4(int begin, int length, int fetchSize, boolean lastBatch) {
RequestMessage request = new RequestMessage();
- request.setProcessingTimestamp(new Date(1L));
request.setExecutionId(REQUEST_ID);
ResultsMessage resultsMsg = new ResultsMessage(request);
List[] results = exampleResults1(length, begin);
@@ -879,7 +848,6 @@
@Test public void testDateType() throws SQLException {
RequestMessage request = new RequestMessage();
- request.setProcessingTimestamp(new Date(1L));
request.setExecutionId(REQUEST_ID);
ResultsMessage resultsMsg = new ResultsMessage(request);
resultsMsg.setResults(new List[] {Arrays.asList(new Timestamp(0))});
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -29,17 +29,22 @@
import junit.framework.TestCase;
-import com.metamatrix.common.api.MMURL;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.common.xa.MMXid;
+import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.platform.security.api.LogonResult;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
public class TestMMConnection extends TestCase {
protected static final String STD_DATABASE_NAME = "QT_Ora9DS"; //$NON-NLS-1$
- protected static final String STD_DATABASE_VERSION = "1"; //$NON-NLS-1$
+ protected static final int STD_DATABASE_VERSION = 1;
static String serverUrl = "jdbc:metamatrix:QT_Ora9DS at mm://localhost:7001;version=1;user=metamatrixadmin;password=mm"; //$NON-NLS-1$
@@ -49,15 +54,35 @@
public static MMConnection getMMConnection() {
ServerConnection mock = mock(ServerConnection.class);
- stub(mock.getService(ClientSideDQP.class)).toReturn(mock(ClientSideDQP.class));
+ ClientSideDQP dqp = mock(ClientSideDQP.class);
+ try {
+ stub(dqp.start((MMXid)Mockito.anyObject(), Mockito.anyInt(), Mockito.anyInt())).toAnswer(new Answer() {
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ return ResultsFuture.NULL_FUTURE;
+ }
+ });
+ stub(dqp.rollback((MMXid)Mockito.anyObject())).toAnswer(new Answer() {
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ return ResultsFuture.NULL_FUTURE;
+ }
+ });
+ stub(dqp.rollback()).toAnswer(new Answer() {
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ return ResultsFuture.NULL_FUTURE;
+ }
+ });
+ } catch (XATransactionException e) {
+ throw new RuntimeException(e);
+ }
+ stub(mock.getService(ClientSideDQP.class)).toReturn(dqp);
Properties props = new Properties();
props.setProperty(BaseDataSource.VDB_NAME, STD_DATABASE_NAME);
- props.setProperty(BaseDataSource.VDB_VERSION, STD_DATABASE_VERSION);
+ props.setProperty(BaseDataSource.VDB_VERSION, String.valueOf(STD_DATABASE_VERSION));
props.setProperty(BaseDataSource.USER_NAME, "metamatrixadmin"); //$NON-NLS-1$
- Properties productInfo = new Properties();
- productInfo.setProperty(MMURL.JDBC.VDB_NAME, STD_DATABASE_NAME);
- productInfo.setProperty(MMURL.JDBC.VDB_VERSION, STD_DATABASE_VERSION);
- stub(mock.getLogonResult()).toReturn(new LogonResult(new SessionToken(new MetaMatrixSessionID(1), "metamatrixadmin"), productInfo, "fake")); //$NON-NLS-1$
+ stub(mock.getLogonResult()).toReturn(new LogonResult(new SessionToken(1, "metamatrixadmin"), STD_DATABASE_NAME,STD_DATABASE_VERSION , "fake")); //$NON-NLS-1$
return new MMConnection(mock, props, serverUrl);
}
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDriver.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDriver.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDriver.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -128,7 +128,7 @@
public void testGetPropertyInfo1() throws Exception {
DriverPropertyInfo info[] = drv.getPropertyInfo("jdbc:metamatrix:vdb at mm://localhost:12345", null); //$NON-NLS-1$
- assertEquals(6, info.length);
+ assertEquals(5, info.length);
assertEquals(true, info[0].required);
assertEquals("VirtualDatabaseName", info[0].name); //$NON-NLS-1$
assertEquals("vdb", info[0].value); //$NON-NLS-1$
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMPreparedStatement.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMPreparedStatement.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMPreparedStatement.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -41,6 +41,7 @@
import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.message.ResultsMessage;
+import com.metamatrix.dqp.message.RequestMessage.ResultsMode;
import com.metamatrix.platform.security.api.LogonResult;
/**
@@ -113,8 +114,7 @@
// Now verify the statement's RequestMessage is what we expect
assertEquals("Command does not match", sqlCommand, statement.requestMessage.getCommandString()); //$NON-NLS-1$
assertEquals("Parameter values do not match", expectedParameterValues, statement.requestMessage.getParameterValues()); //$NON-NLS-1$
- assertTrue("RequestMessage.isPreparedBatchUpdate should be true", statement.requestMessage.isPreparedBatchUpdate()); //$NON-NLS-1$
- assertFalse("RequestMessage.isBatchedUpdate should be false", statement.requestMessage.isBatchedUpdate()); //$NON-NLS-1$
+ assertTrue("RequestMessage.isBatchedUpdate should be true", statement.requestMessage.isBatchedUpdate()); //$NON-NLS-1$
assertFalse("RequestMessage.isCallableStatement should be false", statement.requestMessage.isCallableStatement()); //$NON-NLS-1$
assertTrue("RequestMessage.isPreparedStatement should be true", statement.requestMessage.isPreparedStatement()); //$NON-NLS-1$
}
@@ -323,9 +323,9 @@
public RequestMessage requestMessage;
@Override
protected RequestMessage createRequestMessage(String[] commands,
- boolean isBatchedCommand, Boolean requiresResultSet) {
+ boolean isBatchedCommand, ResultsMode resultsMode) {
this.requestMessage = super
- .createRequestMessage(commands, isBatchedCommand, requiresResultSet);
+ .createRequestMessage(commands, isBatchedCommand, resultsMode);
return this.requestMessage;
}
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -673,7 +673,7 @@
/** test getProcessingTime() -- include test for getProcessingTimestamp() and getCompletedTimestamp() */
@Test public void testGetProcessingTime() throws SQLException {
MMResultSet cs = helpExecuteQuery();
- assertTrue(cs.getProcessingTime() == cs.getCompletedTimestamp().getTime() - 1);
+ assertNotNull(cs.getCompletedTimestamp());
cs.close();
}
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -88,10 +88,10 @@
protected void checkResult(String testName, ResultSet actualResults, String testsuite) throws Exception {
ResultSetMetaData resultMetadata = actualResults.getMetaData();
- String metafilename = UnitTestUtil.getTestDataPath() + File.separator+testsuite+File.separator + "expected" + File.separator+ testName.substring(4) + ".metadata.txt"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ String metafilename = UnitTestUtil.getTestDataPath() + File.separator+testsuite+File.separator + "expected" + File.separator+ testName.substring(4) + ".metadata.txt"; //$NON-NLS-1$ //$NON-NLS-2$
assertResultsSetMetadataEquals(resultMetadata, new File(metafilename));
- String filename = UnitTestUtil.getTestDataPath() + File.separator+testsuite+File.separator + "expected" + File.separator+ testName.substring(4) + ".txt"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ String filename = UnitTestUtil.getTestDataPath() + File.separator+testsuite+File.separator + "expected" + File.separator+ testName.substring(4) + ".txt"; //$NON-NLS-1$ //$NON-NLS-2$
assertResultsSetEquals(actualResults, new File(filename));
}
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -41,7 +41,6 @@
import java.sql.Statement;
import org.junit.After;
-import org.teiid.adminapi.Admin;
import com.metamatrix.script.io.MetadataReader;
import com.metamatrix.script.io.ResultSetReader;
@@ -80,17 +79,7 @@
@After public void tearDown() throws Exception {
closeConnection();
}
-
- public Admin getAdmin() {
- try {
- assertNotNull(this.internalConnection);
- com.metamatrix.jdbc.api.Connection conn = (com.metamatrix.jdbc.api.Connection) this.internalConnection;
- return conn.getAdminAPI();
- } catch (SQLException e) {
- throw new RuntimeException(e);
- }
- }
-
+
public void setConnection(Connection c) {
this.internalConnection = c;
}
@@ -251,7 +240,6 @@
}
}
-
private void writeResultSet(File expected, BufferedReader resultReader)
throws IOException {
if (WRITE_ACTUAL) {
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -29,7 +29,6 @@
import com.metamatrix.common.api.MMURL;
import com.metamatrix.jdbc.BaseDataSource;
-import com.metamatrix.jdbc.api.ConnectionProperties;
import com.metamatrix.jdbc.api.ExecutionProperties;
@@ -243,15 +242,10 @@
} catch (Exception e) {
}
+
try {
- new MMJDBCURL("myVDB", null, null); //$NON-NLS-1$
- fail("Should have failed."); //$NON-NLS-1$
- } catch (Exception e) {
-
- }
- try {
+ // in embedded situation there is no connection url
new MMJDBCURL("myVDB", " ", null); //$NON-NLS-1$ //$NON-NLS-2$
- fail("Should have failed."); //$NON-NLS-1$
} catch (Exception e) {
}
@@ -265,7 +259,6 @@
MMJDBCURL.normalizeProperties(props);
assertEquals("myuser", props.getProperty(BaseDataSource.USER_NAME)); //$NON-NLS-1$
assertEquals("mypassword", props.getProperty(BaseDataSource.PASSWORD)); //$NON-NLS-1$
- assertEquals(new Integer(1), props.get(ConnectionProperties.PROP_CLIENT_SESSION_PAYLOAD));
}
public final void testEncodedPropertyProperties() throws Exception {
Modified: trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java
===================================================================
--- trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -45,112 +45,81 @@
* // (\\w:[\\\\,\\/]|file:\\/\\/|\\/|\\\\|(\\.){1,2}){1}
*/
@Test public void testAcceptsURL() {
-// // Windows Path
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at c:\\metamatrix\\dqp\\dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at c:\\metamatrix\\dqp\\dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at c:\\metamatrix\\dqp\\dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
- // Alternative windows path
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at c:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at c:/metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at c:/metamatrix/dqp/dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
-
- // Abosolute path (Unix or windows)
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
-
- // relative path
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at ../../metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at ../../metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at ../../metamatrix/dqp/dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
-
- // File URL should be supported (not sure)
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at file:///c:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at testdata/dqp/dqp.properties;partialResultsMode=true")); //$NON-NLS-1$
-
// ClassPath based URL
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at classpath:/dqp.properties;partialResultsMode=true")); //$NON-NLS-1$
+ assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT at classpath:/dqp.properties;partialResultsMode=true")); //$NON-NLS-1$
// These are specific to the MMorg.teiid.jdbc.EmbeddedProfile and should not be suported
- assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at mm://host:7001;version=1")); //$NON-NLS-1$
- assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at mms://host:7001;version=1")); //$NON-NLS-1$
- //assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at http://host:7001;version=1"));
+ assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT at mm://host:7001;version=1")); //$NON-NLS-1$
+ assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT at mms://host:7001;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT")); //$NON-NLS-1$
- assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT!/path/foo.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT;")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT;version=1;logFile=foo.txt")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT")); //$NON-NLS-1$
+ assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT!/path/foo.properties")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT;")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT;version=1;logFile=foo.txt")); //$NON-NLS-1$
}
@Test public void testParseURL() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT at c:\\metamatrix\\dqp\\dqp.properties", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertEquals("c:\\metamatrix\\dqp\\dqp.properties", p.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE)); //$NON-NLS-1$
- assertEquals(3, p.size());
+ assertEquals(2, p.size());
}
@Test public void testParseURL2() throws SQLException {
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT@\\metamatrix\\dqp\\dqp.properties;version=3", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT;version=3", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertEquals("\\metamatrix\\dqp\\dqp.properties", p.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE)); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("3")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VERSION).equals("3")); //$NON-NLS-1$
- assertEquals(5, p.size());
+ assertEquals(4, p.size());
}
@Test public void testParseURL3() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=4;autoCommitTxn=ON;partialResultsMode=YES;", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT@/metamatrix/dqp/dqp.properties;version=4;autoCommitTxn=ON;partialResultsMode=YES;", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("4")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VERSION).equals("4")); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP).equals("ON")); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("YES")); //$NON-NLS-1$
- assertEquals(7, p.size());
+ assertEquals(6, p.size());
}
@Test public void testParseURL4() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT at testdata/dqp/dqp.properties;partialResultsMode=true", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT;partialResultsMode=true", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertEquals("testdata/dqp/dqp.properties", p.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE)); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("true")); //$NON-NLS-1$
- assertEquals(4, p.size());
+ assertEquals(3, p.size());
}
@Test public void testParseURL5() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertTrue(p.get(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE).equals("classpath:/deploy.properties")); //$NON-NLS-1$
}
@Test public void testParseURL55() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT;", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT;", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertTrue(p.get(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE).equals("classpath:/deploy.properties")); //$NON-NLS-1$
}
@Test public void testParseURL6() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT;partialResultsMode=true;version=1", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT;partialResultsMode=true;version=1", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertTrue(p.get(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE).equals("classpath:/deploy.properties")); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("true")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("1")); //$NON-NLS-1$
- assertTrue(p.getProperty("vdb.definition").equals("BQT.vdb")); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(7, p.size());
+ assertEquals(5, p.size());
}
@Test public void test() throws Exception {
try {
Class.forName("org.teiid.jdbc.TeiidDriver"); //$NON-NLS-1$
- DriverManager.getConnection("jdbc:metamatrix:Parts at invalidConfig.properties;version=1"); //$NON-NLS-1$
+ DriverManager.getConnection("jdbc:teiid:Parts at invalidConfig.properties;version=1"); //$NON-NLS-1$
fail();
} catch (SQLException e) {
}
Modified: trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
===================================================================
--- trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java 2010-03-04 19:27:44 UTC (rev 1909)
+++ trunk/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java 2010-03-04 19:47:03 UTC (rev 1910)
@@ -24,6 +24,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
import java.sql.DriverPropertyInfo;
@@ -35,19 +36,19 @@
@Test public void testGetPropertyInfo1() throws Exception {
DriverPropertyInfo info[] = drv.getPropertyInfo("jdbc:teiid:vdb at mm://localhost:12345", null); //$NON-NLS-1$
- assertEquals(20, info.length);
+ assertEquals(17, info.length);
}
@Test public void testAccepts() throws Exception {
assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://localhost:12345")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://localhost:12345;user=foo;password=bar")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:teiid:vdb")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:teiid:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$
+ assertFalse(drv.acceptsURL("jdbc:teiid:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb at mm://localhost:12345")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb at mm://localhost:12345;user=foo;password=bar")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://localhost:12345")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://localhost:12345;user=foo;password=bar")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb")); //$NON-NLS-1$
+ assertFalse(drv.acceptsURL("jdbc:teiid:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$
}
More information about the teiid-commits
mailing list