Author: shawkins
Date: 2010-07-14 12:27:29 -0400 (Wed, 14 Jul 2010)
New Revision: 2342
Modified:
trunk/client/src/main/java/org/teiid/client/plan/PlanNode.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/JDBCURL.java
trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
trunk/client/src/main/java/org/teiid/jdbc/TeiidStatement.java
trunk/client/src/main/resources/org/teiid/jdbc/i18n.properties
trunk/documentation/developer-guide/src/main/docbook/en-US/content/adminapi.xml
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java
Log:
TEIID-908 adding a show statement primarily to retrieve query plans.
Modified: trunk/client/src/main/java/org/teiid/client/plan/PlanNode.java
===================================================================
--- trunk/client/src/main/java/org/teiid/client/plan/PlanNode.java 2010-07-14 16:18:49 UTC
(rev 2341)
+++ trunk/client/src/main/java/org/teiid/client/plan/PlanNode.java 2010-07-14 16:27:29 UTC
(rev 2342)
@@ -40,6 +40,7 @@
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.util.ExternalizeUtil;
@@ -168,13 +169,18 @@
* document form.
* @return an XML document of this PlanNode
*/
- public String toXml() throws JAXBException {
- JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {PlanNode.class});
- Marshaller marshaller = jc.createMarshaller();
- marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE); //$NON-NLS-1$
- StringWriter writer = new StringWriter();
- marshaller.marshal(this, writer);
- return writer.toString();
+ public String toXml() {
+ try {
+ JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {PlanNode.class});
+ Marshaller marshaller = jc.createMarshaller();
+ marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
//$NON-NLS-1$
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(this, writer);
+ return writer.toString();
+ } catch (JAXBException e) {
+ //shouldn't happen
+ throw new TeiidRuntimeException(e);
+ }
}
@Override
Modified: trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java 2010-07-14 16:18:49 UTC
(rev 2341)
+++ trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java 2010-07-14 16:27:29 UTC
(rev 2342)
@@ -27,15 +27,13 @@
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Connection;
-import java.sql.DatabaseMetaData;
+import java.sql.NClob;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
+import java.sql.SQLClientInfoException;
import java.sql.SQLException;
import java.sql.SQLWarning;
-import java.sql.SQLClientInfoException;
-import java.sql.NClob;
import java.sql.SQLXML;
-
import java.sql.Savepoint;
import java.sql.Statement;
import java.sql.Struct;
@@ -56,13 +54,15 @@
import javax.transaction.xa.Xid;
import org.teiid.client.DQP;
+import org.teiid.client.plan.Annotation;
+import org.teiid.client.plan.PlanNode;
import org.teiid.client.util.ResultsFuture;
import org.teiid.client.xa.XATransactionException;
import org.teiid.client.xa.XidImpl;
import org.teiid.core.util.SqlUtil;
import org.teiid.net.CommunicationException;
+import org.teiid.net.ServerConnection;
import org.teiid.net.TeiidURL;
-import org.teiid.net.ServerConnection;
import org.teiid.net.socket.SocketServerConnection;
@@ -94,7 +94,7 @@
// collection of all open statements on this connection
private Collection<StatementImpl> statements = new
ArrayList<StatementImpl>();
// cached DatabaseMetadata
- private DatabaseMetaData dbmm;
+ private DatabaseMetaDataImpl dbmm;
//Xid for participating in TXN
private XidImpl transactionXid;
@@ -105,7 +105,14 @@
private boolean disableLocalTransactions = false;
private DQP dqp;
protected ServerConnection serverConn;
- private int transactionIsolation = DEFAULT_ISOLATION;
+ private int transactionIsolation = DEFAULT_ISOLATION;
+
+ // the last query plan description
+ private PlanNode currentPlanDescription;
+ // the last query debug log
+ private String debugLog;
+ // the last query annotations
+ private Collection<Annotation> annotations;
public ConnectionImpl(ServerConnection serverConn, Properties info, String url) {
this.serverConn = serverConn;
@@ -158,6 +165,30 @@
this.disableLocalTransactions =
Boolean.valueOf(this.propInfo.getProperty(ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS)).booleanValue();
}
+ public Collection<Annotation> getAnnotations() {
+ return annotations;
+ }
+
+ public void setAnnotations(Collection<Annotation> annotations) {
+ this.annotations = annotations;
+ }
+
+ public String getDebugLog() {
+ return debugLog;
+ }
+
+ public void setDebugLog(String debugLog) {
+ this.debugLog = debugLog;
+ }
+
+ public PlanNode getCurrentPlanDescription() {
+ return currentPlanDescription;
+ }
+
+ public void setCurrentPlanDescription(PlanNode currentPlanDescription) {
+ this.currentPlanDescription = currentPlanDescription;
+ }
+
protected Properties getConnectionProperties() {
return this.propInfo;
}
@@ -458,7 +489,7 @@
return this.serverConn.getLogonResult().getUserName();
}
- public DatabaseMetaData getMetaData() throws SQLException {
+ public DatabaseMetaDataImpl getMetaData() throws SQLException {
//Check to see the connection is open
checkConnection();
@@ -613,7 +644,7 @@
* @return a PreparedStatement object
* @throws SQLException if there is an error creating a prepared statement object
*/
- public PreparedStatement prepareStatement(String sql) throws SQLException {
+ public PreparedStatementImpl prepareStatement(String sql) throws SQLException {
return prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
}
@@ -626,7 +657,7 @@
* @param intValue indicating the ResultSet's concurrency
* @return a PreparedStatement object
*/
- public PreparedStatement prepareStatement(String sql, int resultSetType, int
resultSetConcurrency) throws SQLException {
+ public PreparedStatementImpl prepareStatement(String sql, int resultSetType, int
resultSetConcurrency) throws SQLException {
//Check to see the connection is open
checkConnection();
Modified: trunk/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java 2010-07-14
16:18:49 UTC (rev 2341)
+++ trunk/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java 2010-07-14
16:27:29 UTC (rev 2342)
@@ -32,16 +32,13 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
-import org.teiid.client.ResultsMessage;
import org.teiid.client.metadata.ResultsMetadataConstants;
import org.teiid.client.metadata.ResultsMetadataDefaults;
import org.teiid.core.CoreConstants;
-import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.JDBCSQLTypeInfo;
import org.teiid.core.util.SqlUtil;
@@ -392,43 +389,43 @@
Map[] metadataList = new Map[8];
// HardCoding metadata details for SCOPE column
- metadataList[0] = getColumnMetadata(null, JDBCColumnNames.BEST_ROW.SCOPE,
- JDBCSQLTypeInfo.SHORT,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[0] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.BEST_ROW.SCOPE,
+ JDBCSQLTypeInfo.SHORT,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// HardCoding metadata details for COLUMN_NAME column
- metadataList[1] = getColumnMetadata(null, JDBCColumnNames.BEST_ROW.COLUMN_NAME,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[1] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.BEST_ROW.COLUMN_NAME,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// HardCoding metadata details for DATA_TYPE column
- metadataList[2] = getColumnMetadata(null, JDBCColumnNames.BEST_ROW.DATA_TYPE,
- JDBCSQLTypeInfo.SHORT,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[2] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.BEST_ROW.DATA_TYPE,
+ JDBCSQLTypeInfo.SHORT,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// HardCoding metadata details for TYPE_NAME column
- metadataList[3] = getColumnMetadata(null, JDBCColumnNames.BEST_ROW.TYPE_NAME,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[3] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.BEST_ROW.TYPE_NAME,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// HardCoding metadata details for COLUMN_SIZE column
- metadataList[4] = getColumnMetadata(null, JDBCColumnNames.BEST_ROW.COLUMN_SIZE,
- JDBCSQLTypeInfo.INTEGER,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[4] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.BEST_ROW.COLUMN_SIZE,
+ JDBCSQLTypeInfo.INTEGER,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// HardCoding metadata details for BUFFER_LENGTH column
- metadataList[5] = getColumnMetadata(null,
JDBCColumnNames.BEST_ROW.BUFFER_LENGTH,
- JDBCSQLTypeInfo.INTEGER,
ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[5] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.BEST_ROW.BUFFER_LENGTH,
+ JDBCSQLTypeInfo.INTEGER,
ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
// HardCoding metadata details for DECIMAL_DIGITS column
- metadataList[6] = getColumnMetadata(null,
JDBCColumnNames.BEST_ROW.DECIMAL_DIGITS,
- JDBCSQLTypeInfo.SHORT,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[6] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.BEST_ROW.DECIMAL_DIGITS,
+ JDBCSQLTypeInfo.SHORT,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// HardCoding metadata details for PSEUDO_COLUMN column
- metadataList[7] = getColumnMetadata(null,
JDBCColumnNames.BEST_ROW.PSEUDO_COLUMN,
- JDBCSQLTypeInfo.SHORT,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[7] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.BEST_ROW.PSEUDO_COLUMN,
+ JDBCSQLTypeInfo.SHORT,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// logging
String logMsg =
JDBCPlugin.Util.getString("MMDatabaseMetadata.Best_row_sucess", table);
//$NON-NLS-1$
logger.fine(logMsg);
// construct results object from column values and their metadata
- return createResultSet(records, metadataList);
+ return dummyStatement().createResultSet(records, metadataList);
}
public ResultSet getCatalogs() throws SQLException {
@@ -442,57 +439,17 @@
Map[] metadataList = new Map[1];
// HardCoding metadata details for TABLE_CAT column
- metadataList[0] = getColumnMetadata(null, JDBCColumnNames.CATALOGS.TABLE_CAT,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[0] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.CATALOGS.TABLE_CAT,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
// logging
String logMsg =
JDBCPlugin.Util.getString("MMDatabaseMetadata.Catalog_success"); //$NON-NLS-1$
logger.fine(logMsg);
// construct results object from column values and their metadata
- return createResultSet(records, metadataList);
+ return dummyStatement().createResultSet(records, metadataList);
}
- private ResultSet createResultSet(List records, Map[] columnMetadata) throws
SQLException {
- ResultSetMetaData rsmd = new ResultSetMetaDataImpl(new
MetadataProvider(columnMetadata));
-
- return createResultSet(records, rsmd);
- }
-
- private ResultSet createResultSet(List records, ResultSetMetaData rsmd) throws
SQLException {
- rsmd.getScale(1); //force the load of the metadata
- ResultsMessage resultsMsg = createDummyResultsMessage(null, null, records);
- StatementImpl stmt = StatementImpl.newInstance(this.driverConnection,
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
- return new ResultSetImpl(resultsMsg, stmt, rsmd, 0);
- }
-
- private ResultSet createEmptyResultSet(String[] columnNames, String[] dataTypes)
throws SQLException {
- ResultsMessage resultsMsg = createDummyResultsMessage(columnNames, dataTypes,
Collections.EMPTY_LIST);
- StatementImpl stmt = StatementImpl.newInstance(this.driverConnection,
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
- try {
- stmt.setFetchSize(500);
- } catch(SQLException e) {
- // will never happen but throw a runtime if it does
- throw new TeiidRuntimeException(e);
- }
- Map[] metadata = new Map[columnNames.length];
- for (int i = 0; i < columnNames.length; i++) {
- metadata[i] = getColumnMetadata(null, columnNames[i], dataTypes[i],
ResultsMetadataConstants.NULL_TYPES.UNKNOWN);
- }
- return new ResultSetImpl(resultsMsg, stmt, new ResultSetMetaDataImpl(new
MetadataProvider(metadata)), 0);
- }
-
- private ResultsMessage createDummyResultsMessage(String[] columnNames, String[]
dataTypes, List records) {
- ResultsMessage resultsMsg = new ResultsMessage();
- resultsMsg.setColumnNames(columnNames);
- resultsMsg.setDataTypes(dataTypes);
- resultsMsg.setFirstRow(1);
- resultsMsg.setLastRow(records.size());
- resultsMsg.setFinalRow(records.size());
- resultsMsg.setResults((List[])records.toArray(new List[records.size()]));
- return resultsMsg;
- }
-
/**
* <p>Gets the String object used to separate a catalog name and a table name
* @return String delimiter
@@ -526,24 +483,24 @@
***********************************************************************/
Map[] metadataList = new Map[8];
- metadataList[0] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.TABLE_CAT,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE);
- metadataList[1] = getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.TABLE_SCHEM,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE);
- metadataList[2] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.TABLE_NAME,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
- metadataList[3] = getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.COLUMN_NAME,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
- metadataList[4] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.GRANTOR,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE);
- metadataList[5] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.GRANTEE,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
- metadataList[6] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.PRIVILEGE,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
- metadataList[7] = getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.IS_GRANTABLE,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[0] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.TABLE_CAT,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
+ metadataList[1] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.TABLE_SCHEM,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
+ metadataList[2] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.TABLE_NAME,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
+ metadataList[3] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.COLUMN_NAME,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
+ metadataList[4] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.GRANTOR,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
+ metadataList[5] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.GRANTEE,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
+ metadataList[6] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.PRIVILEGE,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
+ metadataList[7] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.IS_GRANTABLE,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
- return createResultSet(records, metadataList);
+ return dummyStatement().createResultSet(records, metadataList);
}
@@ -622,7 +579,7 @@
logger.fine(logMsg);
// construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
+ return dummyStatement().createResultSet(records, rmetadata);
} catch(Exception e) {
// logging
String logMsg =
JDBCPlugin.Util.getString("MMDatabaseMetadata.getCols_error", columnNamePattern,
tableNamePattern, e.getMessage()); //$NON-NLS-1$
@@ -976,7 +933,7 @@
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getIndex_success",
table)); //$NON-NLS-1$
// construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
+ return dummyStatement().createResultSet(records, rmetadata);
} catch (Exception e) {
throw TeiidSQLException.create(e,
JDBCPlugin.Util.getString("MMDatabaseMetadata.getIndex_error", table,
e.getMessage())); //$NON-NLS-1$
} finally {
@@ -1201,7 +1158,7 @@
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getPrimaryKey_success"));
//$NON-NLS-1$
// construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
+ return dummyStatement().createResultSet(records, rmetadata);
} catch (Exception e) {
throw TeiidSQLException.create(e,
JDBCPlugin.Util.getString("MMDatabaseMetadata.getPrimaryKey_error", table,
e.getMessage())); //$NON-NLS-1$
} finally {
@@ -1262,7 +1219,7 @@
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getProcCol_success",
columnNamePattern, procedureNamePattern)); //$NON-NLS-1$
// construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
+ return dummyStatement().createResultSet(records, rmetadata);
} catch (Exception e) {
throw TeiidSQLException.create(e,
JDBCPlugin.Util.getString("MMDatabaseMetadata.getProcCol_error",
columnNamePattern, e.getMessage())); //$NON-NLS-1$
} finally {
@@ -1323,7 +1280,7 @@
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getProc_success",
procedureNamePattern)); //$NON-NLS-1$
// construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
+ return dummyStatement().createResultSet(records, rmetadata);
} catch (Exception e) {
throw TeiidSQLException.create(e,
JDBCPlugin.Util.getString("MMDatabaseMetadata.getProc_error",
procedureNamePattern, e.getMessage())); //$NON-NLS-1$
} finally {
@@ -1392,23 +1349,23 @@
Map[] metadataList = new Map[4];
// HardCoding metadata details for TABLE_CAT column
- metadataList[0] = getColumnMetadata(null,
JDBCColumnNames.SUPER_TABLES.TABLE_CAT,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[0] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.SUPER_TABLES.TABLE_CAT,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
// HardCoding metadata details for TABLE_SCHEM column
- metadataList[1] = getColumnMetadata(null,
JDBCColumnNames.SUPER_TABLES.TABLE_SCHEM,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[1] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.SUPER_TABLES.TABLE_SCHEM,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
// HardCoding metadata details for TABLE_NAME column
- metadataList[2] = getColumnMetadata(null,
JDBCColumnNames.SUPER_TABLES.TABLE_NAME,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[2] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.SUPER_TABLES.TABLE_NAME,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// HardCoding metadata details for SUPERTABLE_NAME column
- metadataList[3] = getColumnMetadata(null,
JDBCColumnNames.SUPER_TABLES.SUPERTABLE_NAME,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[3] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.SUPER_TABLES.SUPERTABLE_NAME,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// construct results object from column values and their metadata
- return createResultSet(records, metadataList);
+ return dummyStatement().createResultSet(records, metadataList);
}
@@ -1430,31 +1387,31 @@
Map[] metadataList = new Map[6];
// HardCoding metadata details for TYPE_CAT column
- metadataList[0] = getColumnMetadata(null, JDBCColumnNames.SUPER_TYPES.TYPE_CAT,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[0] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.SUPER_TYPES.TYPE_CAT,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
// HardCoding metadata details for TYPE_SCHEM column
- metadataList[1] = getColumnMetadata(null,
JDBCColumnNames.SUPER_TYPES.TYPE_SCHEM,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[1] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.SUPER_TYPES.TYPE_SCHEM,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
// HardCoding metadata details for TYPE_NAME column
- metadataList[2] = getColumnMetadata(null, JDBCColumnNames.SUPER_TYPES.TYPE_NAME,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[2] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.SUPER_TYPES.TYPE_NAME,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// HardCoding metadata details for SUPERTYPE_CAT column
- metadataList[3] = getColumnMetadata(null,
JDBCColumnNames.SUPER_TYPES.SUPERTYPE_CAT,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[3] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.SUPER_TYPES.SUPERTYPE_CAT,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
// HardCoding metadata details for SUPERTYPE_SCHEM column
- metadataList[4] = getColumnMetadata(null,
JDBCColumnNames.SUPER_TYPES.SUPERTYPE_SCHEM,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[4] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.SUPER_TYPES.SUPERTYPE_SCHEM,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
// HardCoding metadata details for SUPERTYPE_NAME column
- metadataList[5] = getColumnMetadata(null,
JDBCColumnNames.SUPER_TYPES.SUPERTYPE_NAME,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[5] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.SUPER_TYPES.SUPERTYPE_NAME,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
// construct results object from column values and their metadata
- return createResultSet(records, metadataList);
+ return dummyStatement().createResultSet(records, metadataList);
}
public String getSystemFunctions() throws SQLException {
@@ -1468,22 +1425,22 @@
***********************************************************************/
Map[] metadataList = new Map[7];
- metadataList[0] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.TABLE_CAT,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE);
- metadataList[1] = getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.TABLE_SCHEM,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE);
- metadataList[2] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.TABLE_NAME,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
- metadataList[3] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.GRANTOR,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE);
- metadataList[4] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.GRANTEE,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
- metadataList[5] = getColumnMetadata(null, JDBCColumnNames.PRIVILEGES.PRIVILEGE,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
- metadataList[6] = getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.IS_GRANTABLE,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ metadataList[0] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.TABLE_CAT,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
+ metadataList[1] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.TABLE_SCHEM,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
+ metadataList[2] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.TABLE_NAME,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
+ metadataList[3] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.GRANTOR,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
+ metadataList[4] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.GRANTEE,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
+ metadataList[5] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.PRIVILEGE,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
+ metadataList[6] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.PRIVILEGES.IS_GRANTABLE,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NULLABLE, driverConnection);
- return createResultSet(records, metadataList);
+ return dummyStatement().createResultSet(records, metadataList);
}
@@ -1569,7 +1526,7 @@
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getTable_success",
tableNamePattern)); //$NON-NLS-1$
// construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
+ return dummyStatement().createResultSet(records, rmetadata);
} catch (Exception e) {
throw TeiidSQLException.create(e,
JDBCPlugin.Util.getString("MMDatabaseMetadata.getTable_error", tableNamePattern,
e.getMessage())); //$NON-NLS-1$
} finally {
@@ -1599,13 +1556,13 @@
Map[] metadataList = new Map[1];
- metadataList[0] = getColumnMetadata(null, JDBCColumnNames.TABLE_TYPES.TABLE_TYPE,
- JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadataList[0] = StatementImpl.getColumnMetadata(null,
JDBCColumnNames.TABLE_TYPES.TABLE_TYPE,
+ JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL, driverConnection);
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getTableType_success"));
//$NON-NLS-1$
// construct results object from column values and their metadata
- return createResultSet(records, metadataList);
+ return dummyStatement().createResultSet(records, metadataList);
}
public String getTimeDateFunctions() throws SQLException {
@@ -1615,7 +1572,7 @@
public ResultSet getTypeInfo() throws SQLException {
// list which represent records containing data type info
- List records = new ArrayList ();
+ List<List<Object>> records = new
ArrayList<List<Object>>();
records.add(Arrays.asList(createTypeInfoRow("boolean",
"{b'", "}", Boolean.TRUE, Boolean.TRUE, 0))); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
records.add(Arrays.asList(createTypeInfoRow("byte", null, null,
Boolean.TRUE, Boolean.TRUE, 0))); //$NON-NLS-1$
@@ -1638,31 +1595,31 @@
Map[] metadataList = new Map[18];
- metadataList[0] = getColumnMetadata(CoreConstants.SYSTEM_MODEL + "." +
DATA_TYPES, JDBCColumnNames.TYPE_INFO.TYPE_NAME, JDBCSQLTypeInfo.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, JDBCSQLTypeInfo.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, JDBCSQLTypeInfo.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, JDBCSQLTypeInfo.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, JDBCSQLTypeInfo.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, JDBCSQLTypeInfo.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, JDBCSQLTypeInfo.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, JDBCSQLTypeInfo.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, JDBCSQLTypeInfo.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, JDBCSQLTypeInfo.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, JDBCSQLTypeInfo.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, JDBCSQLTypeInfo.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, JDBCSQLTypeInfo.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, JDBCSQLTypeInfo.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, JDBCSQLTypeInfo.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, JDBCSQLTypeInfo.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, JDBCSQLTypeInfo.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, JDBCSQLTypeInfo.INTEGER,
ResultsMetadataConstants.NULL_TYPES.NULLABLE,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE,
Boolean.FALSE);//$NON-NLS-1$
+ metadataList[0] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL +
"." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.TYPE_NAME, JDBCSQLTypeInfo.STRING,
ResultsMetadataConstants.NULL_TYPES.NOT_NULL,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE,
Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[1] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL +
"." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.DATA_TYPE, JDBCSQLTypeInfo.INTEGER,
ResultsMetadataConstants.NULL_TYPES.NULLABLE,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE,
Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[2] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL +
"." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.PRECISION, JDBCSQLTypeInfo.INTEGER,
ResultsMetadataConstants.NULL_TYPES.NULLABLE,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE,
Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[3] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL +
"." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.LITERAL_PREFIX,
JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE,
Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[4] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL +
"." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.LITERAL_SUFFIX,
JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE,
Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[5] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL +
"." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.CREATE_PARAMS,
JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NULLABLE,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE,
Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[6] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL +
"." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.NULLABLE, JDBCSQLTypeInfo.SHORT,
ResultsMetadataConstants.NULL_TYPES.NULLABLE,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE,
Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[7] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL +
"." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.CASE_SENSITIVE,
JDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NOT_NULL,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE,
Boolean.TRUE, driverConnection);//$NON-NLS-1$
+ metadataList[8] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL +
"." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.SEARCHABLE, JDBCSQLTypeInfo.SHORT,
ResultsMetadataConstants.NULL_TYPES.NULLABLE,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE,
Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[9] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL +
"." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.UNSIGNED_ATTRIBUTE,
JDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NULLABLE,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE,
Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[10] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL +
"." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.FIXED_PREC_SCALE,
JDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NULLABLE,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE,
Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[11] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL +
"." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.AUTOINCREMENT,
JDBCSQLTypeInfo.BOOLEAN, ResultsMetadataConstants.NULL_TYPES.NOT_NULL,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.TRUE,
Boolean.TRUE, driverConnection);//$NON-NLS-1$
+ metadataList[12] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL +
"." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.LOCAL_TYPE_NAME,
JDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE,
Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[13] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL +
"." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.MINIMUM_SCALE,
JDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE,
Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[14] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL +
"." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.MAXIMUM_SCALE,
JDBCSQLTypeInfo.SHORT, ResultsMetadataConstants.NULL_TYPES.NULLABLE,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE,
Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[15] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL +
"." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.SQL_DATA_TYPE,
JDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE,
Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[16] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL +
"." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.SQL_DATETIME_SUB,
JDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.TRUE, Boolean.TRUE,
Boolean.FALSE, driverConnection);//$NON-NLS-1$
+ metadataList[17] = StatementImpl.getColumnMetadata(CoreConstants.SYSTEM_MODEL +
"." + DATA_TYPES, JDBCColumnNames.TYPE_INFO.NUM_PREC_RADIX,
JDBCSQLTypeInfo.INTEGER, ResultsMetadataConstants.NULL_TYPES.NULLABLE,
ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE, Boolean.FALSE, Boolean.FALSE,
Boolean.FALSE, driverConnection);//$NON-NLS-1$
ResultSetMetaData rmetadata = new ResultSetMetaDataImpl(new
MetadataProvider(metadataList));
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getTypes_success"));
//$NON-NLS-1$
// construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
+ return dummyStatement().createResultSet(records, rmetadata);
}
private Object[] createTypeInfoRow(String typeName, String prefix, String suffix,
Boolean unsigned, Boolean fixedPrecScale, int radix){
@@ -1709,9 +1666,13 @@
JDBCSQLTypeInfo.STRING,
JDBCSQLTypeInfo.SHORT
};
- return createEmptyResultSet(columnNames, dataTypes);
+ return dummyStatement().createResultSet(Collections.EMPTY_LIST, columnNames,
dataTypes);
}
+ private StatementImpl dummyStatement() {
+ return StatementImpl.newInstance(this.driverConnection,
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ }
+
public String getURL() throws SQLException {
return driverConnection.getUrl();
}
@@ -2312,41 +2273,9 @@
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getRefKey_success"));
//$NON-NLS-1$
// construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
+ return dummyStatement().createResultSet(records, rmetadata);
}
- private Map getColumnMetadata(String tableName, String columnName, String dataType,
Integer nullable) throws SQLException {
- return getColumnMetadata(tableName, columnName, dataType, nullable,
ResultsMetadataConstants.SEARCH_TYPES.UNSEARCHABLE, Boolean.FALSE, Boolean.FALSE,
Boolean.FALSE);
- }
-
- private Map getColumnMetadata(String tableName, String columnName, String dataType,
Integer nullable, Integer searchable, Boolean writable, Boolean signed, Boolean
caseSensitive) throws SQLException {
-
- // map that would contain metadata details
- Map metadataMap = new HashMap();
-
- /*******************************************************
- HardCoding Column metadata details for the given column
- ********************************************************/
-
- metadataMap.put(ResultsMetadataConstants.VIRTUAL_DATABASE_NAME,
driverConnection.getVDBName());
- metadataMap.put(ResultsMetadataConstants.GROUP_NAME, tableName);
- metadataMap.put(ResultsMetadataConstants.ELEMENT_NAME, columnName);
- metadataMap.put(ResultsMetadataConstants.DATA_TYPE, dataType);
- metadataMap.put(ResultsMetadataConstants.PRECISION,
ResultsMetadataDefaults.getDefaultPrecision(dataType));
- metadataMap.put(ResultsMetadataConstants.RADIX, new Integer(10));
- metadataMap.put(ResultsMetadataConstants.SCALE, new Integer(0));
- metadataMap.put(ResultsMetadataConstants.AUTO_INCREMENTING, Boolean.FALSE);
- metadataMap.put(ResultsMetadataConstants.CASE_SENSITIVE, caseSensitive);
- metadataMap.put(ResultsMetadataConstants.NULLABLE, nullable);
- metadataMap.put(ResultsMetadataConstants.SEARCHABLE, searchable);
- metadataMap.put(ResultsMetadataConstants.SIGNED, signed);
- metadataMap.put(ResultsMetadataConstants.WRITABLE, writable);
- metadataMap.put(ResultsMetadataConstants.CURRENCY, Boolean.FALSE);
- metadataMap.put(ResultsMetadataConstants.DISPLAY_SIZE,
ResultsMetadataDefaults.getMaxDisplaySize(dataType));
-
- return metadataMap;
- }
-
public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
return false;
}
@@ -2401,7 +2330,7 @@
ResultSetMetaData rmetadata = null;
ResultSetImpl results = null;
- PreparedStatement prepareQuery = null;
+ PreparedStatementImpl prepareQuery = null;
try {
prepareQuery = driverConnection.prepareStatement(QUERY_SCHEMAS);
prepareQuery.setObject(1, catalog.toUpperCase());
@@ -2427,7 +2356,7 @@
logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getschema_success"));
//$NON-NLS-1$
// construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
+ return dummyStatement().createResultSet(records, rmetadata);
} catch(Exception e) {
throw TeiidSQLException.create(e,
JDBCPlugin.Util.getString("MMDatabaseMetadata.getschema_error",
e.getMessage())); //$NON-NLS-1$
} finally {
Modified: trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java 2010-07-14 16:18:49 UTC (rev
2341)
+++ trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java 2010-07-14 16:27:29 UTC (rev
2342)
@@ -291,7 +291,7 @@
target.put(validKey, value);
}
- private static String getValidKey(String key) {
+ public static String getValidKey(String key) {
// figure out the valid key based on its case
for (int i = 0; i < KNOWN_PROPERTIES.length; i++) {
if (key.equalsIgnoreCase(KNOWN_PROPERTIES[i])) {
Modified: trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2010-07-14 16:18:49 UTC
(rev 2341)
+++ trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2010-07-14 16:27:29 UTC
(rev 2342)
@@ -25,11 +25,13 @@
import java.io.Serializable;
import java.sql.Connection;
import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -51,11 +53,15 @@
import org.teiid.client.RequestMessage.ResultsMode;
import org.teiid.client.RequestMessage.ShowPlan;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.client.metadata.ResultsMetadataConstants;
+import org.teiid.client.metadata.ResultsMetadataDefaults;
import org.teiid.client.plan.Annotation;
import org.teiid.client.plan.PlanNode;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidException;
import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.JDBCSQLTypeInfo;
+import org.teiid.core.types.SQLXMLImpl;
import org.teiid.core.util.SqlUtil;
@@ -139,7 +145,7 @@
protected Map outParamIndexMap = new HashMap();
private static Pattern SET_STATEMENT =
Pattern.compile("\\s*set\\s*(\\w+)\\s*(\\w*)", Pattern.CASE_INSENSITIVE);
//$NON-NLS-1$
-
+ private static Pattern SHOW_STATEMENT =
Pattern.compile("\\s*show\\s*(\\w*)", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
/**
* Factory Constructor
* @param driverConnection
@@ -289,7 +295,7 @@
* throws an exception if it is closed. </p>
* @throws SQLException if the statement object is closed.
*/
- protected void checkStatement() throws SQLException {
+ protected void checkStatement() throws TeiidSQLException {
//Check to see the connection is closed and proceed if it is not
if ( isClosed ) {
throw new
TeiidSQLException(JDBCPlugin.Util.getString("MMStatement.Stmt_closed"));
//$NON-NLS-1$
@@ -377,20 +383,73 @@
}
protected void executeSql(String[] commands, boolean isBatchedCommand, ResultsMode
resultsMode)
- throws SQLException, TeiidSQLException {
+ throws SQLException {
checkStatement();
resetExecutionState();
- //handle set statement
- if (commands.length == 1 && resultsMode != ResultsMode.RESULTSET) {
+ if (commands.length == 1) {
Matcher match = SET_STATEMENT.matcher(commands[0]);
if (match.matches()) {
+ if (resultsMode == ResultsMode.RESULTSET) {
+ throw new
TeiidSQLException(JDBCPlugin.Util.getString("StatementImpl.set_result_set"));
//$NON-NLS-1$
+ }
String key = match.group(1);
String value = match.group(2);
JDBCURL.addNormalizedProperty(key, value,
this.driverConnection.getConnectionProperties());
this.updateCounts = new int[] {0};
return;
}
+ match = SHOW_STATEMENT.matcher(commands[0]);
+ if (match.matches()) {
+ if (resultsMode == ResultsMode.UPDATECOUNT) {
+ throw new
TeiidSQLException(JDBCPlugin.Util.getString("StatementImpl.show_update_count"));
//$NON-NLS-1$
+ }
+ String show = match.group(1);
+ if (show.equalsIgnoreCase("PLAN")) { //$NON-NLS-1$
+ List<ArrayList<Object>> records = new
ArrayList<ArrayList<Object>>(1);
+ PlanNode plan = driverConnection.getCurrentPlanDescription();
+ if (plan != null) {
+ ArrayList<Object> row = new ArrayList<Object>(3);
+ row.add(DataTypeTransformer.getClob(plan.toString()));
+ row.add(new SQLXMLImpl(plan.toXml()));
+ row.add(DataTypeTransformer.getClob(driverConnection.getDebugLog()));
+ records.add(row);
+ }
+ createResultSet(records, new String[] {"PLAN_TEXT",
"PLAN_XML", "DEBUG_LOG"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new String[] {JDBCSQLTypeInfo.STRING, JDBCSQLTypeInfo.XML,
JDBCSQLTypeInfo.STRING});
+ return;
+ }
+ if (show.equalsIgnoreCase("ANNOTATIONS")) { //$NON-NLS-1$
+ List<ArrayList<Object>> records = new
ArrayList<ArrayList<Object>>(1);
+ Collection<Annotation> annos = driverConnection.getAnnotations();
+ for (Annotation annotation : annos) {
+ ArrayList<Object> row = new ArrayList<Object>(4);
+ row.add(annotation.getCategory());
+ row.add(annotation.getPriority().name());
+ row.add(annotation.getAnnotation());
+ row.add(annotation.getResolution());
+ records.add(row);
+ }
+ createResultSet(records, new String[] {"CATEGORY",
"PRIORITY", "ANNOTATION", "RESOLUTION"}, //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] {JDBCSQLTypeInfo.STRING, JDBCSQLTypeInfo.STRING,
JDBCSQLTypeInfo.STRING, JDBCSQLTypeInfo.STRING});
+ return;
+ }
+ if (show.equalsIgnoreCase("ALL")) { //$NON-NLS-1$
+ List<ArrayList<Object>> records = new
ArrayList<ArrayList<Object>>(1);
+ for (String key :
driverConnection.getConnectionProperties().stringPropertyNames()) {
+ ArrayList<Object> row = new ArrayList<Object>(4);
+ row.add(key);
+ row.add(driverConnection.getConnectionProperties().get(key));
+ records.add(row);
+ }
+ createResultSet(records, new String[] {"NAME", "VALUE"},
//$NON-NLS-1$ //$NON-NLS-2$
+ new String[] {JDBCSQLTypeInfo.STRING, JDBCSQLTypeInfo.STRING});
+ return;
+ }
+ List<List<String>> records =
Collections.singletonList(Collections.singletonList(driverConnection.getConnectionProperties().getProperty(JDBCURL.getValidKey(show))));
+ createResultSet(records, new String[] {show}, new String[]
{JDBCSQLTypeInfo.STRING});
+ return;
+ }
}
RequestMessage reqMessage = createRequestMessage(commands, isBatchedCommand,
resultsMode);
@@ -913,7 +972,10 @@
protected void setAnalysisInfo(ResultsMessage resultsMsg) {
this.debugLog = resultsMsg.getDebugLog();
this.currentPlanDescription = resultsMsg.getPlanDescription();
- this.annotations = resultsMsg.getAnnotations();
+ this.annotations = resultsMsg.getAnnotations();
+ this.driverConnection.setDebugLog(debugLog);
+ this.driverConnection.setCurrentPlanDescription(currentPlanDescription);
+ this.driverConnection.setAnnotations(annotations);
}
Calendar getDefaultCalendar() {
@@ -988,4 +1050,69 @@
}
this.maxFieldSize = max;
}
+
+ ResultSetImpl createResultSet(List records, String[] columnNames, String[] dataTypes)
throws SQLException {
+ Map[] metadata = new Map[columnNames.length];
+ for (int i = 0; i < columnNames.length; i++) {
+ metadata[i] = getColumnMetadata(null, columnNames[i], dataTypes[i],
ResultsMetadataConstants.NULL_TYPES.UNKNOWN, driverConnection);
+ }
+ return createResultSet(records, metadata);
+ }
+
+ ResultSetImpl createResultSet(List records, Map[] columnMetadata) throws SQLException
{
+ ResultSetMetaData rsmd = new ResultSetMetaDataImpl(new
MetadataProvider(columnMetadata));
+
+ return createResultSet(records, rsmd);
+ }
+
+ ResultSetImpl createResultSet(List records, ResultSetMetaData rsmd) throws
SQLException {
+ rsmd.getScale(1); //force the load of the metadata
+ ResultsMessage resultsMsg = createDummyResultsMessage(null, null, records);
+ resultSet = new ResultSetImpl(resultsMsg, this, rsmd, 0);
+ resultSet.setMaxFieldSize(this.maxFieldSize);
+ return resultSet;
+ }
+
+ static ResultsMessage createDummyResultsMessage(String[] columnNames, String[]
dataTypes, List records) {
+ ResultsMessage resultsMsg = new ResultsMessage();
+ resultsMsg.setColumnNames(columnNames);
+ resultsMsg.setDataTypes(dataTypes);
+ resultsMsg.setFirstRow(1);
+ resultsMsg.setLastRow(records.size());
+ resultsMsg.setFinalRow(records.size());
+ resultsMsg.setResults((List[])records.toArray(new List[records.size()]));
+ return resultsMsg;
+ }
+
+ static Map<Integer, Object> getColumnMetadata(String tableName, String
columnName, String dataType, Integer nullable, ConnectionImpl driverConnection) throws
SQLException {
+ return getColumnMetadata(tableName, columnName, dataType, nullable,
ResultsMetadataConstants.SEARCH_TYPES.UNSEARCHABLE, Boolean.FALSE, Boolean.FALSE,
Boolean.FALSE, driverConnection);
+ }
+
+ static Map<Integer, Object> getColumnMetadata(String tableName, String columnName,
String dataType, Integer nullable, Integer searchable, Boolean writable, Boolean signed,
Boolean caseSensitive, ConnectionImpl driverConnection) throws SQLException {
+
+ // map that would contain metadata details
+ Map<Integer, Object> metadataMap = new HashMap<Integer, Object>();
+
+ /*******************************************************
+ HardCoding Column metadata details for the given column
+ ********************************************************/
+
+ metadataMap.put(ResultsMetadataConstants.VIRTUAL_DATABASE_NAME,
driverConnection.getVDBName());
+ metadataMap.put(ResultsMetadataConstants.GROUP_NAME, tableName);
+ metadataMap.put(ResultsMetadataConstants.ELEMENT_NAME, columnName);
+ metadataMap.put(ResultsMetadataConstants.DATA_TYPE, dataType);
+ metadataMap.put(ResultsMetadataConstants.PRECISION,
ResultsMetadataDefaults.getDefaultPrecision(dataType));
+ metadataMap.put(ResultsMetadataConstants.RADIX, new Integer(10));
+ metadataMap.put(ResultsMetadataConstants.SCALE, new Integer(0));
+ metadataMap.put(ResultsMetadataConstants.AUTO_INCREMENTING, Boolean.FALSE);
+ metadataMap.put(ResultsMetadataConstants.CASE_SENSITIVE, caseSensitive);
+ metadataMap.put(ResultsMetadataConstants.NULLABLE, nullable);
+ metadataMap.put(ResultsMetadataConstants.SEARCHABLE, searchable);
+ metadataMap.put(ResultsMetadataConstants.SIGNED, signed);
+ metadataMap.put(ResultsMetadataConstants.WRITABLE, writable);
+ metadataMap.put(ResultsMetadataConstants.CURRENCY, Boolean.FALSE);
+ metadataMap.put(ResultsMetadataConstants.DISPLAY_SIZE,
ResultsMetadataDefaults.getMaxDisplaySize(dataType));
+
+ return metadataMap;
+ }
}
\ No newline at end of file
Modified: trunk/client/src/main/java/org/teiid/jdbc/TeiidStatement.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/TeiidStatement.java 2010-07-14 16:18:49 UTC
(rev 2341)
+++ trunk/client/src/main/java/org/teiid/jdbc/TeiidStatement.java 2010-07-14 16:27:29 UTC
(rev 2342)
@@ -40,7 +40,7 @@
* Get the execution property value.
* @param name Execution property name
* @return Execution property value or null if not set
- * @deprecated
+ * @deprecated use show statement
*/
String getExecutionProperty(String name);
@@ -48,7 +48,7 @@
* Set the execution property value.
* @param name Execution property name
* @param value Execution property value
- * @deprecated use set property value
+ * @deprecated use set statement
*/
void setExecutionProperty(String name, String value);
@@ -67,6 +67,7 @@
* SHOWPLAN DEBUG. If no debug output was requested, this
* method will return null.
* @return Debug log or null if no log exists
+ * @deprecated use show statement
*/
String getDebugLog();
@@ -74,6 +75,7 @@
* Get collection of annotations from the query planner from
* the last command executed on the Statement
* @return Collection of {@link Annotation}s, may return null
+ * @deprecated use show statement
*/
Collection<Annotation> getAnnotations();
Modified: trunk/client/src/main/resources/org/teiid/jdbc/i18n.properties
===================================================================
--- trunk/client/src/main/resources/org/teiid/jdbc/i18n.properties 2010-07-14 16:18:49 UTC
(rev 2341)
+++ trunk/client/src/main/resources/org/teiid/jdbc/i18n.properties 2010-07-14 16:27:29 UTC
(rev 2342)
@@ -248,4 +248,7 @@
EmbeddedDataSource.The_configFile_property_is_null=The configFile property is null.
EmbeddedDataSource.The_configFile_does_not_exist_or_cant_be_read=The configFile does not
exist or cannot be read.
EmbeddedTransport.no_classpath=The Embedded Service Bootstrap does not contain a
dqp.classpath property. Add the dqp.classpath property or specify unifiedClassLoader=true
on the DQP JDBC URL.
-EmbeddedTransport.invalid_dqpproperties_path=The path {0} is invalid. Please check your
file system and correct your JDBC URL.
\ No newline at end of file
+EmbeddedTransport.invalid_dqpproperties_path=The path {0} is invalid. Please check your
file system and correct your JDBC URL.
+
+StatementImpl.show_update_count=SHOW does not return an update count
+StatementImpl.set_result_set=SET does not return a result set.
\ No newline at end of file
Modified: trunk/documentation/developer-guide/src/main/docbook/en-US/content/adminapi.xml
===================================================================
---
trunk/documentation/developer-guide/src/main/docbook/en-US/content/adminapi.xml 2010-07-14
16:18:49 UTC (rev 2341)
+++
trunk/documentation/developer-guide/src/main/docbook/en-US/content/adminapi.xml 2010-07-14
16:27:29 UTC (rev 2342)
@@ -9,8 +9,8 @@
<sect1 id="connecting">
<title>Connecting</title>
<para>An AdminAPI connection, which is represented by the
<code>org.teiid.adminapi.Admin</code> interface, is obtained through the
<code>org.teiid.adminapi.AdminFactory.createAdmin</code> methods.
- <code>AdminFactory</code> is a singleton, see
<code>AdminFactory.getInstance()</code>, so there is no need to create
instance. The <code>Admin</code> instance automatically tests its connection
and reconnects to a server in the event of a failure. The <code>close</code>
method should be called to terminate the connection.</para>
- <para>See your Teiid installation for the appropriate admin port, which by
default 31443.</para>
+ <code>AdminFactory</code> is a singleton, see
<code>AdminFactory.getInstance()</code>. The <code>Admin</code>
instance automatically tests its connection and reconnects to a server in the event of a
failure. The <code>close</code> method should be called to terminate the
connection.</para>
+ <para>See your Teiid installation for the appropriate admin port - the default is
31443.</para>
</sect1>
<sect1 id="admin_methods">
<title>Admin Methods</title>
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java 2010-07-14
16:18:49 UTC (rev 2341)
+++
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java 2010-07-14
16:27:29 UTC (rev 2342)
@@ -26,9 +26,11 @@
import java.sql.Connection;
import java.sql.ResultSet;
+import java.sql.SQLXML;
import java.sql.Statement;
-import org.junit.Before;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.teiid.core.util.UnitTestUtil;
@@ -36,14 +38,18 @@
@SuppressWarnings("nls")
public class TestQueryPlans {
- private Connection conn;
+ private static Connection conn;
- @Before public void setUp() throws Exception {
+ @BeforeClass public static void setUp() throws Exception {
FakeServer server = new FakeServer();
server.deployVDB("test", UnitTestUtil.getTestDataPath() +
"/TestCase3473/test.vdb");
conn = server.createConnection("jdbc:teiid:test"); //$NON-NLS-1$
//$NON-NLS-2$
}
+ @AfterClass public static void tearDown() throws Exception {
+ conn.close();
+ }
+
@Test public void testNoExec() throws Exception {
Statement s = conn.createStatement();
s.execute("set noexec on");
@@ -60,13 +66,39 @@
ResultSet rs = s.executeQuery("select * from all_tables");
assertNotNull(s.unwrap(TeiidStatement.class).getPlanDescription());
assertNull(s.unwrap(TeiidStatement.class).getDebugLog());
+
+ rs = s.executeQuery("show plan");
+ assertTrue(rs.next());
+ SQLXML plan = rs.getSQLXML(2);
+ assertTrue(plan.getString().startsWith("<?xml"));
+ assertNull(rs.getObject("DEBUG_LOG"));
+ assertNotNull(rs.getObject("PLAN_TEXT"));
+
s.execute("SET showplan debug");
rs = s.executeQuery("select * from all_tables");
assertNotNull(s.unwrap(TeiidStatement.class).getDebugLog());
+
+ rs = s.executeQuery("show plan");
+ assertTrue(rs.next());
+ assertNotNull(rs.getObject("DEBUG_LOG"));
+
s.execute("SET showplan off");
rs = s.executeQuery("select * from all_tables");
assertNull(s.unwrap(TeiidStatement.class).getPlanDescription());
assertTrue(rs.next());
}
+ @Test public void testShow() throws Exception {
+ Statement s = conn.createStatement();
+ ResultSet rs = s.executeQuery("show all");
+ assertTrue(rs.next());
+ assertNotNull(rs.getString("NAME"));
+
+ s.execute("set showplan on");
+
+ rs = s.executeQuery("show showplan");
+ rs.next();
+ assertEquals("on", rs.getString(1));
+ }
+
}