h1. {color:#000000}{*}JDBC Translator{*}{color} |
h1. {*}JDBC Translator{*} |
|
{color:#333333}The JDBC translator bridges between SQL semantic and data type difference between Teiid and a target RDBMS. Teiid has a range of specific translators that target the most popular open source and proprietary databases.{color} |
|
{color:#333333}Type names:* {color}{color:#333333}{_}jdbc-ansi{_}{color}{color:#333333}\- Type names:* {_}jdbc-ansi{_}\- declares support for most SQL constructs supported by Teiid, except for row limit/offset and EXCEPT/INTERCECT. Translates source SQL into ANSI compliant syntax. This translator should be used when another more specific type is not available.{color} |
* _jdbc-simple_\- same as jdbc-ansi, except disables support for function, UNION, and aggregate pushdown. |
... |
The MySQL Translators expect the database or session to be using ANSI mode. If the database is not using ANSI mode, an initialization query should be used on the pool to set ANSI mode: {code}set SESSION sql_mode = 'ANSI'{code} |
{color:#333333} {color} |
* _netezza_ \- for use with any Netezza version. |
... |
* _teradata_\- for use with Teradata V2R5.1 or later. |
{color:#333333}{*}Execution Properties - shared by all JDBC Translators{*}{color}{color:#333333} {color} Translators{*} |
|| {color:#000000}Name{color} || {color:#000000}Description{color} || {color:#000000}Default{color} || | {color:#333333}DatabaseTimeZone{color} | {color:#333333}The time zone of the database. Used when fetchings date, time, or timestamp values.{color} | {color:#333333}The system default time zone{color} | |
|| Name || Description || Default || | DatabaseTimeZone | The time zone of the database. Used when fetchings date, time, or timestamp values. | The system default time zone | |
| {color:#333333}DatabaseVersion{color} DatabaseVersion | {color:#333333}The specific database version. Used to further tune pushdown support.{color} | {color:#333333}The base supported version or derived from the DatabaseMetadata.getProduceVersion string. Automatic detection requires a Connection. If there are circumstances where you are getting an exception from capabilities being unavailable (most likely due to an issue obtaining a Connection), then set DatabaseVersion property. Use the JDBCExecutionFactory.usesDatabaseVersion() method to control whether your translator requires a connection to determine capabilities.{color} | |
| {color:#333333}TrimStrings{color} TrimStrings | {color:#333333}true to trim trailing whitespace from fixed length character strings. Note that Teiid only has a string, or varchar, type that treats trailing whitespace as meaningful.{color} | {color:#333333}false{color} false | |
| {color:#333333}UseBindVariables{color} UseBindVariables | {color:#333333}true to indicate that PreparedStatements should be used and that literal values in the source query should be replace with bind variables. If false only LOB values will trigger the use of PreparedStatements.{color} | {color:#333333}true{color} true | |
| {color:#333333}UseCommentsInSourceQuery{color} UseCommentsInSourceQuery | {color:#333333}This will embed a leading comment with session/request id in source SQL query for informational purposes{color} | {color:#333333}false{color} false | |
| {color:#333333}MaxPreparedInsertBatchSize{color} | {color:#333333}The max size of a prepared insert batch.{color} | {color:#333333}2048{color} | |
| MaxPreparedInsertBatchSize | The max size of a prepared insert batch. | 2048 | | StructRetrieval | Struct retrieval mode can be one of OBJECT - getObject value returned, COPY - returned as a {{SerialStruct}}, ARRAY - returned as an {{Array}}) | OBJECT | |
{color:#333333}{*}Importer Properties - shared by all JDBC Translators{*}{color}{color:#333333} {color} Translators{*} |
|| {color:#000000}Name{color} || {color:#000000}Description{color} || {color:#000000}Default{color} || | {color:#333333}catalog{color} | {color:#333333}See DatabaseMetaData.getTablesFull \[1\]{color} | {color:#333333}null{color} | | {color:#333333}schemaPattern{color} | {color:#333333}See DatabaseMetaData.getTables \[1\]{color} | {color:#333333}null{color} | | {color:#333333}tableNamePattern{color} | {color:#333333}See DatabaseMetaData.getTables \[1\]{color} | {color:#333333}null{color} | | {color:#333333}procedureNamePattern{color} | {color:#333333}See DatabaseMetaData.getProcedures \[1\]{color} | {color:#333333}null{color} | |
|| Name || Description || Default || | catalog | See DatabaseMetaData.getTablesFull \[1\] | null | | schemaPattern | See DatabaseMetaData.getTables \[1\] | null | | tableNamePattern | See DatabaseMetaData.getTables \[1\] | null | | procedureNamePattern | See DatabaseMetaData.getProcedures \[1\] | null | |
| {color:#333333}tableTypes{color} tableTypes | {color:#333333}Comma separated list - without spaces - of imported table types. See DatabaseMetaData.getTables \[1\]{color} | {color:#333333}null{color} null | |
| {color:#333333}excludeTables {color} excludeTables | {color:#333333}A A case-insensitive regular expression that when matched against a fully qualified Teiid table name will exclude it from import. Applied after table names are retrieved. Use a negative look-ahead (?\!<inclusion pattern>).\* to act as an inclusion filter.{color} | {color:#333333}null {color} null | |
| {color:#333333}excludeProcedures {color} excludeProcedures | {color:#333333}A A case-insensitive regular expression that when matched against a fully qualified Teiid procedure name will exclude it from import. Applied after procedure names are retrieved. Use a negative look-ahead (?\!<inclusion pattern>).\* to act as an inclusion filter.{color} | {color:#333333}null {color} null | |
| {color:#333333}useFullSchemaName{color} useFullSchemaName | {color:#333333}When false, directs the importer to drop the source catalog/schema from the Teiid object name, so that the Teiid fully qualified name will be in the form of <model name>.<table name> - Note: when false this may lead to objects with duplicate names when importing from multiple schemas, which results in an exception. This option does not affect the name in source property.{color} | {color:#333333}true{color} true | |
| {color:#333333}importKeys{color} | {color:#333333}true to import primary and foreign keys{color} | {color:#333333}true{color} | | {color:#333333}importIndexes{color} | {color:#333333}true to import index/unique key/cardinality information{color} | {color:#333333}true{color} | | {color:#333333}importApproximateIndexes{color} | {color:#333333}true to import approximate index information. See DatabaseMetaData.getIndexInfo \[1\]{color} | {color:#333333}true{color} | |
| importKeys | true to import primary and foreign keys | true | | importIndexes | true to import index/unique key/cardinality information | true | | importApproximateIndexes | true to import approximate index information. See DatabaseMetaData.getIndexInfo \[1\] | true | |
| {color:#333333}importProcedures{color} importProcedures | {color:#333333}true to import procedures and procedure columns - Note that it is not always possible to import procedure result set columns due to database limitations. It is also not currently possible to import overloaded procedures.{color} | {color:#333333}true{color} true | |
| {color:#333333}widenUnsignedTypes{color} widenUnsignedTypes | {color:#333333}true to convert unsigned types to the next widest type. For example SQL Server reports tinyint as an unsigned type. With this option enabled, tinyint would be imported as a short instead of a byte.{color} | {color:#333333}true{color} true | |
| {color:#333333}quoteNameInSource{color} quoteNameInSource | {color:#333333}false will override the default and direct Teiid to create source queries using unquoted identifiers.{color} | {color:#333333}true{color} true | |
| {color:#333333}useProcedureSpecificName{color} useProcedureSpecificName | {color:#333333}true will allow the import of overloaded procedures (which will normally result in a duplicate procedure error) by using the unique procedure specific name as the Teiid name. This option will only work with JDBC 4.0 compatible drivers that report specific names.{color} | {color:#333333}false{color} false | |
| {color:#333333}useCatalogName{color} useCatalogName | {color:#333333}true will use any non-null/non-empty catalog name as part of the name in source, e.g. "catalog"."schema"."table"."column", and in the Teiid runtime name if useFullSchemaName is also true. false will not use the catalog name in either the name in source or the Teiid runtime name. Should be set to false for sources that do not fully support a catalog concept, but return a non-null catalog name in their metadata - such as HSQL.{color} | {color:#333333}true{color} true | |
| {color:#333333}useQualifiedName{color} useQualifiedName | {color:#333333}true will use name qualification for both the Teiid name and name in source as dictated by the useCatalogName and useFullSchemaName properties. Set to false to disable all qualification for both the Teiid name and the name in source, which effectively ignores the useCatalogName and useFullSchemaName properties. Note: when false this may lead to objects with duplicate names when importing from multiple schemas, which results in an exception.{color} | {color:#333333}true {color} true | |
{color:#333333}\[1\] JavaDoc for {color}[DatabaseMetaData|http://java.sun.com/javase/6/docs/api/java/sql/DatabaseMetaData.html] |
\[1\] JavaDoc for [DatabaseMetaData|http://java.sun.com/javase/6/docs/api/java/sql/DatabaseMetaData.html] |
{warning:title=Warning} The default import settings will crawl all available metadata. This import process is time consuming and full metadata import is not needed in most situations. Most commonly you'll want to limit the import by at least schemaPattern and tableTypes.{warning} |
{color:#333333}Example importer settings to only import tables and views from my-schema.{color} |
{code:lang=XML} ... |
... |
{code} |
h3. {color:#000000}{*}Usage{*}{color} {*}Usage{*} |
|
{color:#333333}Usage of a JDBC source is straight-forward. Using Teiid SQL, the source may be queried as if the tables and procedures were local to the Teiid system.{color} |
|
h3. {color:#000000}{*}Native Queries{*}{color} |
h3. {*}Native Queries{*} |
|
{color:#333333}Both physical tables and procedures may optionally have native queries associated with them. No validation of the native query is performed, it is simply used in a straight-forward manner to generate the source SQL. For a physical table setting the teiid_rel:native-query extension metadata will execute the native query as an inline view in the source query. This feature should only be used against sources that support inline views. The native query is used as is and is not treated as a parameterized string. For example on a physical table y with nameInSource="x" and teiid_rel:native-query="select c from g", the Teiid source query"SELECT c FROM y" would generate the SQL query "SELECT c FROM (select c from g) as x". Note that the column names in the native query must match the nameInSource of the physical table columns for the resulting SQL to be valid.{color} |
|
{color:#333333}For physical procedures you may also set the teiid_rel:native-query extension metadata to a desired query string with the added ability to positionally reference IN parameters - see {color}[Parameterizable Native Queries|Translators#native]. The teiid_rel:non-prepared extension metadata property may be set to false to turn off parameter binding. Note this option should be used with caution as inbound may allow for SQL injection attacks if not properly validated. The native query does not need to call a stored procedure. Any SQL that returns a result set positionally matching the result set expected by the physical stored procedure metadata will work. For example on a stored procedure x with teiid_rel:native-query="select c from g where c1 = $1 and c2 = '$$1'", the Teiid source query "CALL x\(?)" would generate the SQL query "select c from g where c1 = ? and c2 = '$1'". Note that ? in this example will be replaced with the actual value bound to parameter 1. |
|
h4. {color:#000000}{*}Native Procedure{*}{color} |
h4. {*}Native Procedure{*} |
{warning} |
{color:#333333}This feature is turned off by default because of the security risk this exposes to execute any command against the source. To enable this feature, override the translator property called "SupportsNativeQueries" to true. Look for {color}[Override Execution Properties|Translators#Override Execution Properties] above. |
{warning} |
... |
The JDBC translator bridges between SQL semantic and data type difference between Teiid and a target RDBMS. Teiid has a range of specific translators that target the most popular open source and proprietary databases.
Type names:* jdbc-ansi- declares support for most SQL constructs supported by Teiid, except for row limit/offset and EXCEPT/INTERCECT. Translates source SQL into ANSI compliant syntax. This translator should be used when another more specific type is not available.
set SESSION sql_mode = 'ANSI'
The current Netezza vendor supplied JDBC driver performs poorly with single transactional updates. As is generally the case when possible use batched updates. |
Execution Properties - shared by all JDBC Translators
Name | Description | Default |
---|---|---|
DatabaseTimeZone | The time zone of the database. Used when fetchings date, time, or timestamp values. | The system default time zone |
DatabaseVersion | The specific database version. Used to further tune pushdown support. | The base supported version or derived from the DatabaseMetadata.getProduceVersion string. Automatic detection requires a Connection. If there are circumstances where you are getting an exception from capabilities being unavailable (most likely due to an issue obtaining a Connection), then set DatabaseVersion property. Use the JDBCExecutionFactory.usesDatabaseVersion() method to control whether your translator requires a connection to determine capabilities. |
TrimStrings | true to trim trailing whitespace from fixed length character strings. Note that Teiid only has a string, or varchar, type that treats trailing whitespace as meaningful. | false |
UseBindVariables | true to indicate that PreparedStatements should be used and that literal values in the source query should be replace with bind variables. If false only LOB values will trigger the use of PreparedStatements. | true |
UseCommentsInSourceQuery | This will embed a leading comment with session/request id in source SQL query for informational purposes | false |
MaxPreparedInsertBatchSize | The max size of a prepared insert batch. | 2048 |
StructRetrieval | Struct retrieval mode can be one of OBJECT - getObject value returned, COPY - returned as a SerialStruct, ARRAY - returned as an Array) | OBJECT |
Importer Properties - shared by all JDBC Translators
Name | Description | Default |
---|---|---|
catalog | See DatabaseMetaData.getTablesFull [1] | null |
schemaPattern | See DatabaseMetaData.getTables [1] | null |
tableNamePattern | See DatabaseMetaData.getTables [1] | null |
procedureNamePattern | See DatabaseMetaData.getProcedures [1] | null |
tableTypes | Comma separated list - without spaces - of imported table types. See DatabaseMetaData.getTables [1] | null |
excludeTables |
A case-insensitive regular expression that when matched against a fully qualified Teiid table name will exclude it from import. Applied after table names are retrieved. Use a negative look-ahead (?!<inclusion pattern>).* to act as an inclusion filter. | null |
excludeProcedures |
A case-insensitive regular expression that when matched against a fully qualified Teiid procedure name will exclude it from import. Applied after procedure names are retrieved. Use a negative look-ahead (?!<inclusion pattern>).* to act as an inclusion filter. | null |
useFullSchemaName | When false, directs the importer to drop the source catalog/schema from the Teiid object name, so that the Teiid fully qualified name will be in the form of <model name>.<table name> - Note: when false this may lead to objects with duplicate names when importing from multiple schemas, which results in an exception. This option does not affect the name in source property. | true |
importKeys | true to import primary and foreign keys | true |
importIndexes | true to import index/unique key/cardinality information | true |
importApproximateIndexes | true to import approximate index information. See DatabaseMetaData.getIndexInfo [1] | true |
importProcedures | true to import procedures and procedure columns - Note that it is not always possible to import procedure result set columns due to database limitations. It is also not currently possible to import overloaded procedures. | true |
widenUnsignedTypes | true to convert unsigned types to the next widest type. For example SQL Server reports tinyint as an unsigned type. With this option enabled, tinyint would be imported as a short instead of a byte. | true |
quoteNameInSource | false will override the default and direct Teiid to create source queries using unquoted identifiers. | true |
useProcedureSpecificName | true will allow the import of overloaded procedures (which will normally result in a duplicate procedure error) by using the unique procedure specific name as the Teiid name. This option will only work with JDBC 4.0 compatible drivers that report specific names. | false |
useCatalogName | true will use any non-null/non-empty catalog name as part of the name in source, e.g. "catalog"."schema"."table"."column", and in the Teiid runtime name if useFullSchemaName is also true. false will not use the catalog name in either the name in source or the Teiid runtime name. Should be set to false for sources that do not fully support a catalog concept, but return a non-null catalog name in their metadata - such as HSQL. | true |
useQualifiedName | true will use name qualification for both the Teiid name and name in source as dictated by the useCatalogName and useFullSchemaName properties. Set to false to disable all qualification for both the Teiid name and the name in source, which effectively ignores the useCatalogName and useFullSchemaName properties. Note: when false this may lead to objects with duplicate names when importing from multiple schemas, which results in an exception. | true |
[1] JavaDoc for DatabaseMetaData
Warning The default import settings will crawl all available metadata. This import process is time consuming and full metadata import is not needed in most situations. Most commonly you'll want to limit the import by at least schemaPattern and tableTypes. |
Example importer settings to only import tables and views from my-schema.
... <property name="importer.tableTypes" value="TABLE,VIEW"/> <property name="importer.schemaPattern" value="my-schema"/> ...
Usage of a JDBC source is straight-forward. Using Teiid SQL, the source may be queried as if the tables and procedures were local to the Teiid system.
Both physical tables and procedures may optionally have native queries associated with them. No validation of the native query is performed, it is simply used in a straight-forward manner to generate the source SQL. For a physical table setting the teiid_rel:native-query extension metadata will execute the native query as an inline view in the source query. This feature should only be used against sources that support inline views. The native query is used as is and is not treated as a parameterized string. For example on a physical table y with nameInSource="x" and teiid_rel:native-query="select c from g", the Teiid source query"SELECT c FROM y" would generate the SQL query "SELECT c FROM (select c from g) as x". Note that the column names in the native query must match the nameInSource of the physical table columns for the resulting SQL to be valid.
For physical procedures you may also set the teiid_rel:native-query extension metadata to a desired query string with the added ability to positionally reference IN parameters - see Parameterizable Native Queries. The teiid_rel:non-prepared extension metadata property may be set to false to turn off parameter binding. Note this option should be used with caution as inbound may allow for SQL injection attacks if not properly validated. The native query does not need to call a stored procedure. Any SQL that returns a result set positionally matching the result set expected by the physical stored procedure metadata will work. For example on a stored procedure x with teiid_rel:native-query="select c from g where c1 = $1 and c2 = '$$1'", the Teiid source query "CALL x(?)" would generate the SQL query "select c from g where c1 = ? and c2 = '$1'". Note that ? in this example will be replaced with the actual value bound to parameter 1.
This feature is turned off by default because of the security risk this exposes to execute any command against the source. To enable this feature, override the translator property called "SupportsNativeQueries" to true. Look for Override Execution Properties above. |
JDBC translator also provides a procedure with name native that gives ability to execute any ad-hoc native SQL command that is specific to an underlying source directly against the source without any Teiid parsing or resolving. The metadata of this procedure's execution results are not known to the Teiid, and they are returned as object array. User can use ARRAYTABLE construct to build a tabular output for consumption by client applications. Example execution can be like below
SELECT x.* FROM (call pm1.native('select * from g1')) w, ARRAYTABLE(w.tuple COLUMNS "e1" integer , "e2" string) AS x
SELECT x.* FROM (call pm1.native('insert into g1 (e1,e2) values (?, ?)', 112, 'foo')) w, ARRAYTABLE(w.tuple COLUMNS "update_count" integer) AS x
SELECT x.* FROM (call pm1.native('update g1 set e2=? where e1 = ?','blah', 112)) w, ARRAYTABLE(w.tuple COLUMNS "update_count" integer) AS x
SELECT x.* FROM (call pm1.native('delete from g1 where e1 = ?', 112)) w, ARRAYTABLE(w.tuple COLUMNS "update_count" integer) AS x
By default the name of the procedure that executes the queries directly is called native, however user can set Override Execution Properties property on NativeQueryProcedureName in vdb.xml file to change it to any other procedure name. |
The resource adapter for this translator provided through data source in JBoss AS, Refer to Admin Guide for "JDBC Data Sources" configuration section.