[teiid-commits] teiid SVN: r4298 - in trunk: build/kits/embedded/lib and 7 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Fri Aug 3 12:06:06 EDT 2012


Author: shawkins
Date: 2012-08-03 12:06:05 -0400 (Fri, 03 Aug 2012)
New Revision: 4298

Added:
   trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedConnection.java
   trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedRequestOptions.java
Removed:
   trunk/build/kits/embedded/examples/embedded-portfolio/src/org/teiid/example/AbstarctDataSource.java
   trunk/build/kits/embedded/examples/embedded-portfolio/src/org/teiid/example/AbstractConnection.java
Modified:
   trunk/build/kits/embedded/examples/embedded-portfolio/src/org/teiid/example/TeiidEmbeddedPortfolio.java
   trunk/build/kits/embedded/lib/dependencies.txt
   trunk/client/src/main/java/org/teiid/client/RequestMessage.java
   trunk/client/src/main/java/org/teiid/jdbc/CallableStatementImpl.java
   trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
   trunk/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java
   trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
   trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java
   trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
   trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java
   trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestASTQueries.java
   trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
Log:
TEIID-2062 switching to an extension of the Connection for using language objects

Deleted: trunk/build/kits/embedded/examples/embedded-portfolio/src/org/teiid/example/AbstarctDataSource.java
===================================================================
--- trunk/build/kits/embedded/examples/embedded-portfolio/src/org/teiid/example/AbstarctDataSource.java	2012-08-03 13:18:56 UTC (rev 4297)
+++ trunk/build/kits/embedded/examples/embedded-portfolio/src/org/teiid/example/AbstarctDataSource.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.example;
-
-import java.io.PrintWriter;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-import javax.sql.DataSource;
-
-public abstract class AbstarctDataSource implements DataSource {
-
-	@Override
-	public PrintWriter getLogWriter() throws SQLException {
-		return null;
-	}
-
-	@Override
-	public void setLogWriter(PrintWriter out) throws SQLException {
-	}
-
-	@Override
-	public void setLoginTimeout(int seconds) throws SQLException {
-	}
-
-	@Override
-	public int getLoginTimeout() throws SQLException {
-		return 0;
-	}
-
-	@Override
-	public <T> T unwrap(Class<T> iface) throws SQLException {
-		return null;
-	}
-
-	@Override
-	public boolean isWrapperFor(Class<?> iface) throws SQLException {
-		return false;
-	}
-
-	@Override
-	public abstract Connection getConnection() throws SQLException;
-	
-	@Override
-	public Connection getConnection(String username, String password) throws SQLException {
-		return null;
-	}
-}

Deleted: trunk/build/kits/embedded/examples/embedded-portfolio/src/org/teiid/example/AbstractConnection.java
===================================================================
--- trunk/build/kits/embedded/examples/embedded-portfolio/src/org/teiid/example/AbstractConnection.java	2012-08-03 13:18:56 UTC (rev 4297)
+++ trunk/build/kits/embedded/examples/embedded-portfolio/src/org/teiid/example/AbstractConnection.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -1,27 +0,0 @@
-package org.teiid.example;
-
-import javax.resource.ResourceException;
-import javax.resource.cci.*;
-
-public abstract class AbstractConnection implements Connection {
-
-	@Override
-	public Interaction createInteraction() throws ResourceException {
-		return null;
-	}
-
-	@Override
-	public LocalTransaction getLocalTransaction() throws ResourceException {
-		return null;
-	}
-
-	@Override
-	public ConnectionMetaData getMetaData() throws ResourceException {
-		return null;
-	}
-
-	@Override
-	public ResultSetInfo getResultSetInfo() throws ResourceException {
-		return null;
-	}
-}

Modified: trunk/build/kits/embedded/examples/embedded-portfolio/src/org/teiid/example/TeiidEmbeddedPortfolio.java
===================================================================
--- trunk/build/kits/embedded/examples/embedded-portfolio/src/org/teiid/example/TeiidEmbeddedPortfolio.java	2012-08-03 13:18:56 UTC (rev 4297)
+++ trunk/build/kits/embedded/examples/embedded-portfolio/src/org/teiid/example/TeiidEmbeddedPortfolio.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -23,20 +23,25 @@
 package org.teiid.example;
 
 import java.io.File;
-import java.sql.*;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.StringTokenizer;
 
 import javax.resource.ResourceException;
 import javax.resource.cci.ConnectionFactory;
 import javax.sql.DataSource;
 
+import org.h2.jdbcx.JdbcDataSource;
 import org.teiid.adminapi.Model.Type;
 import org.teiid.adminapi.impl.ModelMetaData;
 import org.teiid.core.util.ObjectConverterUtil;
 import org.teiid.jdbc.TeiidDriver;
+import org.teiid.resource.adapter.file.FileConnectionImpl;
 import org.teiid.runtime.EmbeddedConfiguration;
 import org.teiid.runtime.EmbeddedServer;
-import org.teiid.runtime.EmbeddedServer.ConnectionFactoryProvider;
 import org.teiid.translator.FileConnection;
 import org.teiid.translator.TranslatorException;
 import org.teiid.translator.file.FileExecutionFactory;
@@ -49,7 +54,7 @@
  * view layer using DDL. 
  * 
  * Note that this example shows how to integrate the traditional sources like jdbc, file, web-service etc, however you are 
- * not limited to only those sources. As long as you can extended and provide implementaions for
+ * not limited to only those sources. As long as you can extended and provide implementations for
  *  - ConnectionfactoryProvider
  *  - Translator
  *  - Metadata Repository
@@ -61,54 +66,17 @@
 	
 	/**
 	 * If you are trying to use per-built translators in Teiid framework, then the connection semantics for that
-	 * source already defined in a interface. The below examples show how you can define connection interfaces that translator
-	 * can understands. If you are writing a custom translator and then you define the connection interface and 
-	 * connection provider based on that.  
+	 * source already defined in a interface. The below examples show how you use the connection interface that translator
+	 * understands, in this case by using the default implementation with default values. If you are writing a custom translator
+	 *  then can you define the connection interface and connection provider based on that.  
 	 */
-	private static EmbeddedServer.ConnectionFactoryProvider<ConnectionFactory> getFileConnectionProvider(){
-		return new ConnectionFactoryProvider<ConnectionFactory>() {
-			@Override
-			public ConnectionFactory getConnectionFactory() throws TranslatorException {
-				return new AbstractConnectionFactory<FileConnection>() {
-					@Override
-					public FileConnection getConnection() throws ResourceException {
-						return new FileConnectionImpl();
-					}
-				};
-			}
-		};
-	}
-	
-	private static EmbeddedServer.ConnectionFactoryProvider<DataSource> getJDBCProvider(){
-		return new ConnectionFactoryProvider<DataSource>() {
-			@Override
-			public DataSource getConnectionFactory() throws TranslatorException {
-				return new AbstarctDataSource() {
-					
-					@Override
-					public Connection getConnection() throws SQLException {
-						try {
-							String url = "jdbc:h2:accounts";
-							Class.forName("org.h2.Driver");
-							return DriverManager.getConnection(url);
-						} catch (ClassNotFoundException e) {
-							e.printStackTrace();
-						}
-						return null;
-					}
-				};
-			}
-		};
-	}	
-	
-	static class FileConnectionImpl extends AbstractConnection implements FileConnection {
+	@SuppressWarnings("serial")
+	private static final class FileConnectionFactory extends
+			AbstractConnectionFactory<FileConnection> {
 		@Override
-		public File getFile(String path) throws ResourceException {
-			return new File(path);
+		public FileConnection getConnection() throws ResourceException {
+			return new FileConnectionImpl(".", null, false);
 		}
-		@Override
-		public void close() throws ResourceException {
-		}		
 	}
 	
 	/**
@@ -177,7 +145,15 @@
 	public static void main(String[] args) throws Exception {
 		// setup accounts database (if you already have external database this is not needed)
 		// for schema take look at "data/customer-schema.sql" file.
-		EmbeddedServer.ConnectionFactoryProvider<DataSource> jdbcProvider = getJDBCProvider();
+		final JdbcDataSource h2ds = new JdbcDataSource();
+    	h2ds.setURL("jdbc:h2:accounts");
+
+		EmbeddedServer.ConnectionFactoryProvider<DataSource> jdbcProvider = new EmbeddedServer.ConnectionFactoryProvider<DataSource>() {
+			@Override
+			public DataSource getConnectionFactory() throws TranslatorException {
+				return h2ds;
+			}
+		};
 		Connection conn = jdbcProvider.getConnectionFactory().getConnection();
 		String schema = ObjectConverterUtil.convertFileToString(new File("data/customer-schema.sql"));
 		StringTokenizer st = new StringTokenizer(schema, ";");
@@ -198,7 +174,13 @@
 		// configure the connection provider and translator for file based source. 
 		// NOTE: every source that is being integrated, needs its connection provider and its translator 
 		// check out https://docs.jboss.org/author/display/TEIID/Built-in+Translators prebuit translators
-		teiidServer.addConnectionFactoryProvider("source-file", getFileConnectionProvider());
+		final ConnectionFactory cf = new FileConnectionFactory();;
+		teiidServer.addConnectionFactoryProvider("source-file", new EmbeddedServer.ConnectionFactoryProvider<ConnectionFactory>() {
+			@Override
+			public ConnectionFactory getConnectionFactory() throws TranslatorException {
+				return cf;
+			}
+		});
 		teiidServer.addTranslator(new FileExecutionFactory());
 
 		// configure the connection provider and translator for jdbc based source

Modified: trunk/build/kits/embedded/lib/dependencies.txt
===================================================================
--- trunk/build/kits/embedded/lib/dependencies.txt	2012-08-03 13:18:56 UTC (rev 4297)
+++ trunk/build/kits/embedded/lib/dependencies.txt	2012-08-03 16:06:05 UTC (rev 4298)
@@ -1,3 +1,3 @@
 If you are not using XQuery, there is no need to include "saxonhe-9.2.1.5.jar" jar file in the class path. All other files need 
 to be included in your applications's classpath. Depending upon which sources you use with the Teiid embedded, you also need 
-to add translators jar files from optional directory. 
\ No newline at end of file
+to add translators jar files from the optional directory. 
\ No newline at end of file

Modified: trunk/client/src/main/java/org/teiid/client/RequestMessage.java
===================================================================
--- trunk/client/src/main/java/org/teiid/client/RequestMessage.java	2012-08-03 13:18:56 UTC (rev 4297)
+++ trunk/client/src/main/java/org/teiid/client/RequestMessage.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -95,8 +95,9 @@
      * Used by embedded connections, could change if we add support
      * for an asynch socket transport
      */
-    private transient boolean sync;
+    private boolean sync;
     private RequestOptions requestOptions;
+    private Object command;
     
     public RequestMessage() {
     }
@@ -314,9 +315,13 @@
 		this.commands = batchedCommands;
 	}
 	
-	public Object getQueryCommand() {
-		return null;
+	public Object getCommand() {
+		return command;
 	}
+	
+	public void setCommand(Object command) {
+		this.command = command;
+	}
 
 	public void setExecutionPayload(Serializable executionPayload) {
 		this.executionPayload = executionPayload;

Modified: trunk/client/src/main/java/org/teiid/jdbc/CallableStatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/CallableStatementImpl.java	2012-08-03 13:18:56 UTC (rev 4297)
+++ trunk/client/src/main/java/org/teiid/jdbc/CallableStatementImpl.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -55,13 +55,6 @@
     private Object parameterValue;
 
     /**
-     * Factory Constructor (be sure to cast it to  MMCallableStatement)
-     */
-    static CallableStatementImpl newInstance(ConnectionImpl connection, String procedureCall, int resultSetType, int resultSetConcurrency) throws SQLException {
-        return new CallableStatementImpl(connection, procedureCall, resultSetType, resultSetConcurrency);        
-    }
-    
-    /**
      * <p>MMCallableStatement constructor that sets the procedureName, IN parameters
      * and OUT parameters on this object.
      * @param Driver's connection object which creates this object.

Modified: trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java	2012-08-03 13:18:56 UTC (rev 4297)
+++ trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -249,16 +249,12 @@
     	return this.serverConn.getLogonResult().getSessionID();
     }
     
-    long currentRequestId() {
-        return requestIDGenerator;
-    }
-    
     /**
      * Generate the next unique requestID for matching up requests with responses.
      * These IDs should be unique only in the context of a ServerConnection instance.
      * @return Request ID
      */
-    long nextRequestID() {
+    protected synchronized long nextRequestID() {
         return requestIDGenerator++;
     }
 
@@ -387,18 +383,8 @@
      * @param intValue indicating the ResultSet's concurrency
      * @return Statement object.
      */
-    public StatementImpl createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
-        //Check to see the connection is open
-        checkConnection();
-
-        validateResultSetType(resultSetType);
-        validateResultSetConcurrency(resultSetConcurrency);
-
-        // add the statement object to the map
-        StatementImpl newStatement = StatementImpl.newInstance(this, resultSetType, resultSetConcurrency);
-        statements.add(newStatement);
-
-        return newStatement;
+    public StatementImpl createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
+    	return createStatement(resultSetType, resultSetConcurrency, ResultSet.HOLD_CURSORS_OVER_COMMIT);
     }
 
     /** 
@@ -559,7 +545,7 @@
      * @return CallableStatement object that can be used to execute the storedProcedure
      * @throws SQLException if there is an error creating the callable statement object
      */
-    public CallableStatement prepareCall(String sql) throws SQLException {
+    public CallableStatementImpl prepareCall(String sql) throws SQLException {
     	//there is a problem setting the result set type to be non-scrollable
     	//See defect 17768
         return prepareCall(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
@@ -575,18 +561,8 @@
      * @param intValue indicating the ResultSet's concurrency
      * @return CallableStatement object that can be used to execute the storedProcedure
      */
-    public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
-        //Check to see the connection is open
-        checkConnection();
-        
-        validateResultSetType(resultSetType);
-        validateResultSetConcurrency(resultSetConcurrency);
-        validateSQL(sql);
-        
-        // add the statement object to the map
-        CallableStatementImpl newStatement = CallableStatementImpl.newInstance(this, sql, resultSetType, resultSetConcurrency);
-        statements.add(newStatement);
-        return newStatement;
+    public CallableStatementImpl prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+    	return prepareCall(sql, resultSetType, resultSetConcurrency, ResultSet.HOLD_CURSORS_OVER_COMMIT);
     }
 
     /** 
@@ -614,23 +590,23 @@
      * @param intValue indicating the ResultSet's concurrency
      * @return a PreparedStatement object
      */
-    public PreparedStatementImpl prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
-        //Check to see the connection is open
-        checkConnection();
-        
-        validateResultSetType(resultSetType);
-        validateResultSetConcurrency(resultSetConcurrency);
-        validateSQL(sql);
-        
-        // add the statement object to the map
-        PreparedStatementImpl newStatement = PreparedStatementImpl.newInstance(this, sql, resultSetType, resultSetConcurrency);
-        statements.add(newStatement);
-        return newStatement;
+    public PreparedStatementImpl prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+    	return prepareStatement(sql, resultSetType, resultSetConcurrency, ResultSet.HOLD_CURSORS_OVER_COMMIT);
     }
 
-    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
+    public PreparedStatementImpl prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
         int resultSetHoldability ) throws SQLException {
-    	throw SqlUtil.createFeatureNotSupportedException();
+        //Check to see the connection is open
+        checkConnection();
+        
+        validateResultSetType(resultSetType);
+        validateResultSetConcurrency(resultSetConcurrency);
+        validateSQL(sql);
+        
+        // add the statement object to the map
+        PreparedStatementImpl newStatement = new PreparedStatementImpl(this, sql, resultSetType, resultSetConcurrency);
+        statements.add(newStatement);
+        return newStatement;
     }
 
     public void rollback() throws SQLException {
@@ -896,11 +872,21 @@
 		throw SqlUtil.createFeatureNotSupportedException();
 	}
 
-	public Statement createStatement(int resultSetType,
+	public StatementImpl createStatement(int resultSetType,
 			int resultSetConcurrency, int resultSetHoldability)
-			throws SQLException {
-		throw SqlUtil.createFeatureNotSupportedException();
-
+			throws SQLException {
+        //Check to see the connection is open
+        checkConnection();
+
+        validateResultSetType(resultSetType);
+        validateResultSetConcurrency(resultSetConcurrency);
+        //TODO: implement close cursors at commit
+
+        // add the statement object to the map
+        StatementImpl newStatement = new StatementImpl(this, resultSetType, resultSetConcurrency);
+        statements.add(newStatement);
+
+        return newStatement;
 	}
 
 	public Struct createStruct(String typeName, Object[] attributes)
@@ -908,13 +894,23 @@
 		throw SqlUtil.createFeatureNotSupportedException();
 	}
 
-	public CallableStatement prepareCall(String sql, int resultSetType,
+	public CallableStatementImpl prepareCall(String sql, int resultSetType,
 			int resultSetConcurrency, int resultSetHoldability)
 			throws SQLException {
-		throw SqlUtil.createFeatureNotSupportedException();
+        //Check to see the connection is open
+        checkConnection();
+        
+        validateResultSetType(resultSetType);
+        validateResultSetConcurrency(resultSetConcurrency);
+        validateSQL(sql);
+        //TODO: implement close cursors at commit
+        
+        // add the statement object to the map
+        CallableStatementImpl newStatement = new CallableStatementImpl(this, sql, resultSetType, resultSetConcurrency);
+        statements.add(newStatement);
+        return newStatement;
+	}
 
-	}
-
 	public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
 			throws SQLException {
 		throw SqlUtil.createFeatureNotSupportedException();

Modified: trunk/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java	2012-08-03 13:18:56 UTC (rev 4297)
+++ trunk/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -1656,7 +1656,7 @@
     }
     
     private StatementImpl dummyStatement() {
-    	return StatementImpl.newInstance(this.driverConnection, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+    	return new StatementImpl(this.driverConnection, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
     }
     
     public String getURL() throws SQLException {

Modified: trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java	2012-08-03 13:18:56 UTC (rev 4297)
+++ trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -84,19 +84,9 @@
     private ParameterMetaDataImpl parameterMetaData;
     
     private Calendar serverCalendar;
+    private Object command;
 
     /**
-     * Factory Constructor 
-     * @param connection
-     * @param sql
-     * @param resultSetType
-     * @param resultSetConcurrency
-     */
-    static PreparedStatementImpl newInstance(ConnectionImpl connection, String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
-        return new PreparedStatementImpl(connection, sql, resultSetType, resultSetConcurrency);        
-    }
-    
-    /**
      * <p>MMPreparedStatement constructor.
      * @param Driver's connection object.
      * @param String object representing the prepared statement
@@ -235,6 +225,7 @@
     	message.setStatementType(StatementType.PREPARED);
     	message.setParameterValues(isBatchedCommand?getParameterValuesList(): getParameterValues());
     	message.setBatchedUpdate(isBatchedCommand);
+    	message.setCommand(this.command);
     	return message;
     }
 
@@ -710,4 +701,8 @@
 			throws SQLException {
 		throw SqlUtil.createFeatureNotSupportedException();
 	}
+	
+	public void setCommand(Object command) {
+		this.command = command;
+	}
 }

Modified: trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java	2012-08-03 13:18:56 UTC (rev 4297)
+++ trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -158,15 +158,6 @@
     static Pattern TRANSACTION_STATEMENT = Pattern.compile("\\s*(commit|rollback|(start\\s+transaction))\\s*;?", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
     static Pattern SET_STATEMENT = Pattern.compile("\\s*set(?:\\s+(payload))?\\s+((?:session authorization)|(?:[a-zA-Z]\\w*))\\s+(?:([a-zA-Z]\\w*)|((?:'[^']*')+));?", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
     static Pattern SHOW_STATEMENT = Pattern.compile("\\s*show\\s+([a-zA-Z]\\w*);?", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
-    /**
-     * Factory Constructor 
-     * @param driverConnection
-     * @param resultSetType
-     * @param resultSetConcurrency
-     */
-    static StatementImpl newInstance(ConnectionImpl driverConnection, int resultSetType, int resultSetConcurrency) {
-        return new StatementImpl(driverConnection, resultSetType, resultSetConcurrency);        
-    }
     
     /**
      * MMStatement Constructor.

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java	2012-08-03 13:18:56 UTC (rev 4297)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -154,17 +154,23 @@
             LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Query does not exist in cache: ", sqlQuery}); //$NON-NLS-1$
             super.generatePlan(false);
         	prepPlan.setCommand(this.userCommand);
+        	
+        	//there's no need to cache the plan if it's a stored procedure, since we already do that in the optimizer
+        	boolean cache = !(this.userCommand instanceof StoredProcedure);
+        	
 	        // Defect 13751: Clone the plan in its current state (i.e. before processing) so that it can be used for later queries
-	        prepPlan.setPlan(processPlan.clone(), this.context);
+	        prepPlan.setPlan(cache?processPlan.clone():processPlan, this.context);
 	        prepPlan.setAnalysisRecord(analysisRecord);
 			
-	        Determinism determinismLevel = this.context.getDeterminismLevel();
-			if (userCommand.getCacheHint() != null && userCommand.getCacheHint().getDeterminism() != null) {
-				LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Cache hint modified the query determinism from ",this.context.getDeterminismLevel(), " to ", determinismLevel }); //$NON-NLS-1$ //$NON-NLS-2$
-				determinismLevel = userCommand.getCacheHint().getDeterminism();
-			}		        
-	        
-	        this.prepPlanCache.put(id, determinismLevel, prepPlan, userCommand.getCacheHint() != null?userCommand.getCacheHint().getTtl():null);
+	        if (cache) {
+		        Determinism determinismLevel = this.context.getDeterminismLevel();
+				if (userCommand.getCacheHint() != null && userCommand.getCacheHint().getDeterminism() != null) {
+					LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Cache hint modified the query determinism from ",this.context.getDeterminismLevel(), " to ", determinismLevel }); //$NON-NLS-1$ //$NON-NLS-2$
+					determinismLevel = userCommand.getCacheHint().getDeterminism();
+				}		        
+		        
+		        this.prepPlanCache.put(id, determinismLevel, prepPlan, userCommand.getCacheHint() != null?userCommand.getCacheHint().getTtl():null);
+	        }
         }
         
         if (requestMsg.isBatchedUpdate()) {

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java	2012-08-03 13:18:56 UTC (rev 4297)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -294,8 +294,8 @@
     }
     
     private Command parseCommand() throws QueryParserException {
-    	if (requestMsg.getQueryCommand() != null) {
-    		return (Command)requestMsg.getQueryCommand();
+    	if (requestMsg.getCommand() != null) {
+    		return (Command)requestMsg.getCommand();
     	}
         String[] commands = requestMsg.getCommands();
         ParseInfo parseInfo = createParseInfo(this.requestMsg);

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java	2012-08-03 13:18:56 UTC (rev 4297)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -74,6 +74,7 @@
 import org.teiid.query.parser.QueryParser;
 import org.teiid.query.processor.BatchCollector;
 import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.sql.lang.CacheHint;
 import org.teiid.query.sql.lang.Command;
 import org.teiid.query.sql.lang.SPParameter;
 import org.teiid.query.sql.lang.StoredProcedure;
@@ -499,7 +500,7 @@
 		boolean cachable = false;
 		CacheID cacheId = null;
 		boolean canUseCached = !requestMsg.getRequestOptions().isContinuous() && (requestMsg.useResultSetCache() || 
-				QueryParser.getQueryParser().parseCacheHint(requestMsg.getCommandString()) != null);
+				getCacheHint() != null);
 		
 		if (rsCache != null) {
 			if (!canUseCached) {
@@ -604,6 +605,13 @@
 	    }
 		request = null;
 	}
+
+	private CacheHint getCacheHint() {
+		if (requestMsg.getCommand() != null) {
+			return ((Command)requestMsg.getCommand()).getCacheHint();
+		}
+		return QueryParser.getQueryParser().parseCacheHint(requestMsg.getCommandString());
+	}
 	
 	private void addToCache() {
 		if (!doneProducingBatches || cid == null) {

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java	2012-08-03 13:18:56 UTC (rev 4297)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -31,7 +31,11 @@
 
 import org.junit.Test;
 import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
 import org.teiid.query.processor.HardcodedDataManager;
+import org.teiid.query.processor.TestProcessor;
 import org.teiid.query.unittest.RealMetadataFactory;
 
 @SuppressWarnings("nls")
@@ -48,6 +52,21 @@
 		}
 	}
 	
+	@Test public void testProcedurePlanCaching() throws Exception {
+		String sql = "{? = call BQT_V.v_spTest9(?)}"; //$NON-NLS-1$
+
+		List values = new ArrayList();
+		values.add(1);
+		
+		List[] expected = new List[1];
+		expected[0] = Arrays.asList(1);
+		
+		HardcodedDataManager dataManager = new HardcodedDataManager();
+		dataManager.addData("ret = EXEC pm4.spTest9(1)", expected);
+		
+		TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, RealMetadataFactory.exampleBQTCached(), true, RealMetadataFactory.exampleBQTVDB());
+	}
+	
 	@Test public void testReturnParameter() throws Exception {
 		String sql = "{? = call pm4.spTest9(?)}"; //$NON-NLS-1$
 
@@ -60,13 +79,23 @@
 		HardcodedDataManager dataManager = new HardcodedDataManager();
 		dataManager.addData("? = EXEC pm4.spTest9(1)", expected);
 		
-		TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, RealMetadataFactory.exampleBQTCached(), true, RealMetadataFactory.exampleBQTVDB());
+        helpProcess(sql, values, expected, dataManager);
 	}
-	
+
 	/**
-	 * same result as above, but the return parameter is not specified
-	 * TODO: it would be best if the return parameter were not actually returned here, since it wasn't specified in the initial sql
+	 * help process a physical callable statement
 	 */
+	private void helpProcess(String sql, List values, List[] expected,
+			HardcodedDataManager dataManager) throws TeiidComponentException,
+			TeiidProcessingException, Exception {
+		SessionAwareCache<PreparedPlan> planCache = new SessionAwareCache<PreparedPlan>();
+		PreparedStatementRequest plan = TestPreparedStatement.helpGetProcessorPlan(sql, values, new DefaultCapabilitiesFinder(), RealMetadataFactory.exampleBQTCached(), planCache, 1, true, false, RealMetadataFactory.exampleBQTVDB());
+        TestProcessor.doProcess(plan.processPlan, dataManager, expected, plan.context);
+        
+        TestPreparedStatement.helpGetProcessorPlan(sql, values, new DefaultCapabilitiesFinder(), RealMetadataFactory.exampleBQTCached(), planCache, 1, true, false, RealMetadataFactory.exampleBQTVDB());
+        assertEquals(0, planCache.getCacheHitCount());
+	}
+	
 	@Test public void testNoReturnParameter() throws Exception {
 		String sql = "{call pm4.spTest9(?)}"; //$NON-NLS-1$
 
@@ -79,7 +108,7 @@
 		HardcodedDataManager dataManager = new HardcodedDataManager();
 		dataManager.addData("EXEC pm4.spTest9(1)", expected);
 		
-		TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, RealMetadataFactory.exampleBQTCached(), true, RealMetadataFactory.exampleBQTVDB());
+		helpProcess(sql, values, expected, dataManager);
 	}
 		
 	@Test public void testOutParameter() throws Exception {
@@ -94,7 +123,7 @@
 		HardcodedDataManager dataManager = new HardcodedDataManager();
 		dataManager.addData("EXEC pm2.spTest8(2)", expected);
 		
-		TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, RealMetadataFactory.exampleBQTCached(), true, RealMetadataFactory.exampleBQTVDB());
+		helpProcess(sql, values, expected, dataManager);
 	}
 	
 	@Test(expected=QueryResolverException.class) public void testInvalidReturn() throws Exception {
@@ -117,7 +146,7 @@
 		HardcodedDataManager dataManager = new HardcodedDataManager();
 		dataManager.addData("EXEC pm2.spTest8(1)", expected);
 		
-		TestPreparedStatement.helpTestProcessing(sql, null, expected, dataManager, RealMetadataFactory.exampleBQTCached(), true, RealMetadataFactory.exampleBQTVDB());
+		helpProcess(sql, null, expected, dataManager);
 	}
 
 }

Modified: trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java	2012-08-03 13:18:56 UTC (rev 4297)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -216,6 +216,10 @@
         createElements(vqtg2589i, elemNames, elemTypes);
         createElements(bvqtg1, elemNames, elemTypes);        
         createElements(bvqt2g1, elemNames, elemTypes);        
+        
+        ProcedureParameter rsp1 = createParameter("ret", ParameterInfo.RETURN_VALUE, DataTypeManager.DefaultDataTypes.INTEGER);  //$NON-NLS-1$
+        ProcedureParameter rsp2 = createParameter("inkey", ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$
+        createVirtualProcedure("v_spTest9", bvqt, Arrays.asList(rsp1, rsp2), new QueryNode("ret = call pm4.spTest9(inkey);")); //$NON-NLS-1$ //$NON-NLS-2$
 
      // Add stored procedure
         Schema pm1 = createPhysicalModel("pm1", metadataStore); //$NON-NLS-1$

Added: trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedConnection.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedConnection.java	                        (rev 0)
+++ trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedConnection.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.runtime;
+
+import java.sql.CallableStatement;
+import java.sql.SQLException;
+
+import org.teiid.jdbc.TeiidConnection;
+import org.teiid.jdbc.TeiidPreparedStatement;
+import org.teiid.query.sql.lang.Command;
+
+/**
+ * An extension to {@link TeiidConnection} that allows for by-passing the parser.
+ * <br>
+ * Note this is a non-public API that is subject to change.  And that the parser will still be consulted
+ * if prepared statement metadata is asked for prior to execution or if named parameters are used for
+ * {@link CallableStatement} parameter assignments.
+ */
+public interface EmbeddedConnection extends TeiidConnection {
+	
+	CallableStatement prepareCall(Command command, EmbeddedRequestOptions options) throws SQLException;
+
+	TeiidPreparedStatement prepareStatement(Command command, EmbeddedRequestOptions options) throws SQLException;
+
+}


Property changes on: trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedConnection.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedRequestOptions.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedRequestOptions.java	                        (rev 0)
+++ trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedRequestOptions.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.runtime;
+
+import java.sql.ResultSet;
+
+public class EmbeddedRequestOptions {
+	private int resultSetType = ResultSet.TYPE_FORWARD_ONLY;
+
+	public EmbeddedRequestOptions() {
+	}
+	
+	public int getResultSetType() {
+		return resultSetType;
+	}
+	
+	public void setResultSetType(int resultSetType) {
+		this.resultSetType = resultSetType;
+	}
+	
+	public EmbeddedRequestOptions resultSetType(int r) {
+		this.resultSetType = r;
+		return this;
+	}
+	
+}
\ No newline at end of file


Property changes on: trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedRequestOptions.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java	2012-08-03 13:18:56 UTC (rev 4297)
+++ trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -26,17 +26,16 @@
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
@@ -49,24 +48,17 @@
 import org.teiid.Replicated;
 import org.teiid.Replicated.ReplicationMode;
 import org.teiid.adminapi.impl.ModelMetaData;
-import org.teiid.adminapi.impl.SessionMetadata;
 import org.teiid.adminapi.impl.VDBMetaData;
 import org.teiid.cache.Cache;
 import org.teiid.cache.CacheConfiguration;
-import org.teiid.cache.CacheConfiguration.Policy;
 import org.teiid.cache.DefaultCacheFactory;
+import org.teiid.cache.CacheConfiguration.Policy;
 import org.teiid.client.DQP;
-import org.teiid.client.RequestMessage;
-import org.teiid.client.ResultsMessage;
 import org.teiid.client.security.ILogon;
-import org.teiid.client.util.ResultsFuture;
 import org.teiid.common.buffer.BufferManager;
 import org.teiid.common.buffer.TupleBufferCache;
-import org.teiid.core.BundleUtil.Event;
-import org.teiid.core.types.JDBCSQLTypeInfo;
-import org.teiid.core.TeiidException;
-import org.teiid.core.TeiidProcessingException;
 import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.BundleUtil.Event;
 import org.teiid.deployers.CompositeVDB;
 import org.teiid.deployers.UDFMetaData;
 import org.teiid.deployers.VDBLifeCycleListener;
@@ -78,7 +70,6 @@
 import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ExecutionFactoryProvider;
 import org.teiid.dqp.internal.process.CachedResults;
 import org.teiid.dqp.internal.process.DQPCore;
-import org.teiid.dqp.internal.process.DQPWorkContext;
 import org.teiid.dqp.internal.process.PreparedPlan;
 import org.teiid.dqp.internal.process.SessionAwareCache;
 import org.teiid.dqp.internal.process.TransactionServerImpl;
@@ -87,9 +78,12 @@
 import org.teiid.dqp.service.TransactionContext.Scope;
 import org.teiid.events.EventDistributor;
 import org.teiid.events.EventDistributorFactory;
+import org.teiid.jdbc.CallableStatementImpl;
 import org.teiid.jdbc.ConnectionImpl;
 import org.teiid.jdbc.ConnectionProfile;
+import org.teiid.jdbc.PreparedStatementImpl;
 import org.teiid.jdbc.TeiidDriver;
+import org.teiid.jdbc.TeiidPreparedStatement;
 import org.teiid.jdbc.TeiidSQLException;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
@@ -99,15 +93,14 @@
 import org.teiid.metadata.MetadataStore;
 import org.teiid.net.CommunicationException;
 import org.teiid.net.ConnectionException;
+import org.teiid.net.ServerConnection;
 import org.teiid.query.ObjectReplicator;
 import org.teiid.query.function.SystemFunctionManager;
 import org.teiid.query.metadata.TransformationMetadata;
 import org.teiid.query.metadata.TransformationMetadata.Resource;
-import org.teiid.query.sql.lang.QueryCommand;
-import org.teiid.query.sql.visitor.SQLStringVisitor;
+import org.teiid.query.sql.lang.Command;
 import org.teiid.query.tempdata.GlobalTableStore;
 import org.teiid.query.tempdata.GlobalTableStoreImpl;
-import org.teiid.query.tempdata.TempTableDataManager;
 import org.teiid.query.validator.ValidatorFailure;
 import org.teiid.query.validator.ValidatorReport;
 import org.teiid.services.AbstractEventDistributorFactoryService;
@@ -130,6 +123,31 @@
 @SuppressWarnings("serial")
 public class EmbeddedServer extends AbstractVDBDeployer implements EventDistributorFactory, ExecutionFactoryProvider {
 
+	private final class EmbeddedConnectionImpl extends ConnectionImpl implements EmbeddedConnection {
+
+		public EmbeddedConnectionImpl(ServerConnection serverConn,
+				Properties info, String url) {
+			super(serverConn, info, url);
+		}
+
+		@Override
+		public CallableStatement prepareCall(Command command, EmbeddedRequestOptions options)
+				throws SQLException {
+			CallableStatementImpl csi = this.prepareCall(command.toString(), options.getResultSetType(), ResultSet.CONCUR_READ_ONLY);
+			csi.setCommand(command);
+			return csi;
+		}
+		
+		@Override
+		public TeiidPreparedStatement prepareStatement(Command command,
+				EmbeddedRequestOptions options) throws SQLException {
+			PreparedStatementImpl psi = this.prepareStatement(command.toString(), options.getResultSetType(), ResultSet.CONCUR_READ_ONLY);
+			psi.setCommand(command);
+			return psi;
+		}
+		
+	}
+
 	protected final class TransactionDetectingTransactionServer extends
 			TransactionServerImpl {
 		
@@ -307,7 +325,6 @@
 	//to allow teiid to start a request transaction under an existing thread bound transaction
 	protected boolean detectTransactions = true;
 	private Boolean running;
-	private AtomicLong requestIdentifier = new AtomicLong();
 	
 	public EmbeddedServer() {
 
@@ -402,7 +419,7 @@
 				} catch (ConnectionException e) {
 					throw TeiidSQLException.create(e);
 				}
-				return new ConnectionImpl(conn, info, url);
+				return new EmbeddedConnectionImpl(conn, info, url);
 			}
 		});
 	}
@@ -588,211 +605,4 @@
 		return this.repo;
 	}
 	
-	public class ExecutionResults {
-		private List<String> columnNames;
-		private List<Integer> dataTypes = new ArrayList<Integer>();
-		private List<? extends List<?>> rows;
-		private boolean hasMoreRows = false;
-		private int lastRow;
-		private SessionMetadata session;
-		private long requestId;
-		private DQPWorkContext context;
-		private int index = 0;
-		private int rowsRead = 0;
-		private boolean closed = false;
-		
-		/**
-		 * Advances the cursor and gets the next row of results. If this represents a update, then column name will
-		 * be "update-count"
-		 * @return row; if advanced over the last row of data, TeiidException is thrown.
-		 * @throws TeiidException
-		 */
-		public List<?> next() throws TeiidException {
-			if (hasNext()) {
-				return this.rows.get(this.index++);
-			}
-			throw new TeiidProcessingException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40098));
-		}
-		
-		/**
-		 * Get the name of the columns
-		 * @return
-		 */
-		public List<String> getColumnNames() {
-			return columnNames;
-		}
-
-		/**
-		 * Get SQL Type of the column - 0 indexed
-		 * @return SQL type from java.sql.Types
-		 */
-		public int getDataType(int index) {
-			return dataTypes.get(index);
-		}
-		
-		/**
-		 * Check to see if the is another row of data available
-		 * @return true if data available; false otherwise
-		 * @throws TeiidException
-		 */
-		public boolean hasNext() throws TeiidException {
-			if ((this.index+this.rowsRead) >= this.lastRow) {
-				if (this.hasMoreRows) {
-					batchNext();
-				}
-				else {
-					return false;
-				}
-			}
-			return true;
-		}
-		
-		private boolean batchNext() throws TeiidException {
-			try {
-				if (this.hasMoreRows) {
-					Future<ResultsMessage> message = dqp.processCursorRequest(requestId, this.lastRow+1, 1024);
-					ResultsMessage rm = message.get();
-					this.columnNames = Arrays.asList(rm.getColumnNames());
-					this.rows = rm.getResultsList(); 
-					this.rowsRead = this.lastRow;
-					this.lastRow = rm.getLastRow();
-					this.index = 0;
-				    if (rm.getFinalRow() == -1 || rm.getLastRow() < rm.getFinalRow()) {
-				    	this.hasMoreRows = true;
-				    }
-				    else {
-				    	this.hasMoreRows = false;
-				    }
-				    return true;
-				}
-				return false;
-			} catch (InterruptedException e) {
-				throw new TeiidProcessingException(e);
-			} catch (ExecutionException e) {
-				throw new TeiidProcessingException(e);
-			}
-		}
-		
-		public void close() throws TeiidException {
-			if (!this.closed) {
-				try {
-			        ResultsFuture<?> response = dqp.closeRequest(this.requestId);
-			        response.get();
-			        this.closed = true;
-			        
-					context.runInContext(new Callable<Void>() {
-						@Override
-						public Void call() throws Exception {
-							dqp.terminateSession(session.getSessionId());
-							return null;
-						}
-					});
-				} catch (Throwable e) {
-					throw new TeiidException(e);
-				}			
-			}
-		}
-	}
-	
-	/**
-	 * Internal use only. Subject to change in next versions.
-	 * 
-	 * Execute the query directly in the engine by submitting the AST form of the SQL and omit the whole JDBC 
-	 * layer. The returned object contain the results, which is designed like java.sql.ResultSet.
-	 * 
-	 * @param vdbName
-	 * @param version
-	 * @param command
-	 * @param timoutInMilli
-	 * @return
-	 * @throws TeiidException
-	 */
-	public ExecutionResults executeQuery(final String vdbName, final int version, final QueryCommand command, final long timoutInMilli) throws TeiidException {
-		String user = "embedded"; //$NON-NLS-1$
-		
-        VDBMetaData vdb = this.repo.getLiveVDB(vdbName, version);
-        if (vdb == null) {
-        	throw new TeiidException(RuntimePlugin.Util.getString("wrong_vdb"));//$NON-NLS-1$
-        }
-        
-        final SessionMetadata session = TempTableDataManager.createTemporarySession(user, "embedded", vdb); //$NON-NLS-1$
-
-		final long requestID =  this.requestIdentifier.getAndIncrement();
-		
-		final DQPWorkContext context = new DQPWorkContext();
-		context.setUseCallingThread(true);
-		context.setSession(session);
-		
-		try {
-			return context.runInContext(new Callable<ExecutionResults>() {
-				@Override
-				public ExecutionResults call() throws Exception {
-					
-					ExecutionResults results = new ExecutionResults();
-					results.session = session;
-					results.requestId = requestID;
-					results.context = context;
-					
-					RequestMessage request = new RequestMessage() {
-						@Override
-						public QueryCommand getQueryCommand() {
-							return command;
-						}	
-						
-						@Override
-						public String[] getCommands() {
-							return new String[] {buildStringForm()};
-						}
-						
-						@Override
-						public String getCommandString() {
-							return buildStringForm();
-						}	
-						
-						private String buildStringForm() {
-							return SQLStringVisitor.getSQLString(getQueryCommand());
-						}						
-					};
-					request.setExecutionId(requestID);
-					request.setRowLimit(0);
-					Future<ResultsMessage> message = dqp.executeRequest(requestID, request);
-					ResultsMessage rm = null;
-					if (timoutInMilli < 0) {
-						rm = message.get();
-					} else {
-						rm = message.get(timoutInMilli, TimeUnit.MILLISECONDS);
-					}
-			        if (rm.getException() != null) {
-			             throw rm.getException();
-			        }
-			        
-			        if (rm.isUpdateResult()) {
-			        	results.columnNames = Arrays.asList("update-count");//$NON-NLS-1$
-			        	results.dataTypes.add(JDBCSQLTypeInfo.getSQLType("integer"));//$NON-NLS-1$
-			        	results.rows = rm.getResultsList(); 
-			        	results.lastRow = 1;
-			        	results.hasMoreRows = false;
-			        	results.close();
-			        }
-			        else {
-			        	results.columnNames = Arrays.asList(rm.getColumnNames());
-			        	for (String type:rm.getDataTypes()) {
-			        		results.dataTypes.add(JDBCSQLTypeInfo.getSQLType(type));
-			        	}
-			        	results.rows = rm.getResultsList(); 	
-			        	results.lastRow = rm.getLastRow();
-				        if (rm.getFinalRow() == -1 || rm.getLastRow() < rm.getFinalRow()) {
-				        	results.hasMoreRows = true;
-				        }
-				        else {
-				        	results.close();
-				        }
-			        }
-					return results;
-				}
-			});
-		} catch (Throwable t) {
-			throw new TeiidException(t);
-		}
-	}
 }

Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestASTQueries.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestASTQueries.java	2012-08-03 13:18:56 UTC (rev 4297)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestASTQueries.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -21,11 +21,13 @@
  */
 package org.teiid.jdbc;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.*;
 
+import java.sql.Connection;
+import java.sql.ResultSet;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Properties;
 
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -39,8 +41,9 @@
 import org.teiid.query.sql.symbol.ElementSymbol;
 import org.teiid.query.sql.symbol.GroupSymbol;
 import org.teiid.runtime.EmbeddedConfiguration;
+import org.teiid.runtime.EmbeddedConnection;
+import org.teiid.runtime.EmbeddedRequestOptions;
 import org.teiid.runtime.EmbeddedServer;
-import org.teiid.runtime.EmbeddedServer.ExecutionResults;
 import org.teiid.translator.loopback.LoopbackExecutionFactory;
 
 @SuppressWarnings("nls")
@@ -73,11 +76,14 @@
 	}
 
 	@Test public void testAST() throws Exception {
-		ExecutionResults rs = server.executeQuery("test", 1, sampleQuery(), -1);
+		TeiidDriver td = server.getDriver();
+		Connection c = td.connect("jdbc:teiid:test", new Properties());
+		EmbeddedConnection ec = c.unwrap(EmbeddedConnection.class);
+		TeiidPreparedStatement tps = ec.prepareStatement(sampleQuery(), new EmbeddedRequestOptions());
+		ResultSet rs = tps.executeQuery();
 		assertNotNull(rs);
 		int count = 0;
-		while (rs.hasNext()) {
-			rs.next();
+		while (rs.next()) {
 			count++;
 		}
 		assertEquals(10, count);

Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java	2012-08-03 13:18:56 UTC (rev 4297)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java	2012-08-03 16:06:05 UTC (rev 4298)
@@ -249,6 +249,10 @@
     		fail();
     	}
     	
+    	for (int i = 0; !server.getDqp().getRequests().isEmpty() && i < 40; i++) {
+    		//the concurrent modification may not be seen initially
+    		Thread.sleep(50);
+    	}
     	assertTrue(server.getDqp().getRequests().isEmpty());
     	
     	if (handler.t != null) {



More information about the teiid-commits mailing list