Package org.teiid.jdbc
Class BaseDataSource
- java.lang.Object
-
- org.teiid.jdbc.WrapperImpl
-
- org.teiid.jdbc.BaseDataSource
-
- All Implemented Interfaces:
Serializable,Wrapper,CommonDataSource,ConnectionPoolDataSource,DataSource,XADataSource
- Direct Known Subclasses:
TeiidDataSource
public abstract class BaseDataSource extends WrapperImpl implements DataSource, XADataSource, ConnectionPoolDataSource, Serializable
The Teiid JDBC DataSource implementation class ofDataSourceandXADataSource.The
DataSourceinterface follows the JavaBean design pattern, meaning the implementation class has properties that are accessed with getter methods and set using setter methods, and where the getter and setter methods follow the JavaBean naming convention (e.g.,getPropertyName() :PropertyType andsetPropertyName(PropertyType) : void). TheXADataSourceinterface is almost identical to theDataSourceinterface, but rather than returningConnectioninstances, there are methods that returnXAConnectioninstances that can be used with distributed transactions.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringAPP_NAMEstatic StringDEFAULT_APP_NAMEprotected static intDEFAULT_FETCH_SIZEprotected static intDEFAULT_LOG_LEVELprotected static StringDEFAULT_PARTIAL_RESULTS_MODEprotected static StringDEFAULT_RESULT_SET_CACHE_MODEprotected static intDEFAULT_TIMEOUTstatic StringJDBCstatic StringPASSWORDstatic StringTXN_WRAP_AUTOTransaction auto wrap constant - checks if a command requires a transaction and will be automatically wrap it.static StringTXN_WRAP_OFFTransaction auto wrap constant - never wrap a command execution in a transaction and allow multi-source updates to occur outside of a transaction.static StringTXN_WRAP_ONTransaction auto wrap constant - always wrap every non-transactional command execution in a transaction.static StringUSER_NAMEstatic StringVDB_NAMEstatic StringVDB_VERSIONstatic StringVERSION
-
Constructor Summary
Constructors Constructor Description BaseDataSource()Constructor for MMDataSource.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected PropertiesbuildProperties(String userName, String password)StringgetAdditionalProperties()StringgetApplicationName()Returns the name of the application.StringgetAutoCommitTxn()Returns the current setting for how connections are created by this DataSource manage transactions for client requests when client applications do not use transactions.ConnectiongetConnection()Attempt to establish a database connection.StringgetDatabaseName()Returns the name of the virtual database on a particular Teiid Server.StringgetDatabaseVersion()Returns the databaseVersion.StringgetDataSourceName()Returns the logical name for the underlyingXADataSourceorConnectionPoolDataSource; used only when pooling connections or distributed transactions are implemented.StringgetDescription()Returns the description of this data source.StringgetDisableLocalTxn()intgetFetchSize()intgetLoginTimeout()PrintWritergetLogWriter()StringgetPartialResultsMode()StringgetPassword()Returns the password.PooledConnectiongetPooledConnection()PooledConnectiongetPooledConnection(String userName, String password)intgetQueryTimeout()StringgetResultSetCacheMode()StringgetShowPlan()booleangetUseJDBC4ColumnNameAndLabelSemantics()StringgetUser()Returns the user.XAConnectiongetXAConnection()booleanisAnsiQuotedIdentifiers()booleanisNoExec()static StringreasonWhyInvalidApplicationName(String applicationName)Return the reason why the supplied application name may be invalid, or null if it is considered valid.static StringreasonWhyInvalidDatabaseName(String databaseName)Return the reason why the supplied virtual database name may be invalid, or null if it is considered valid.static StringreasonWhyInvalidDatabaseVersion(String databaseVersion)Return the reason why the supplied virtual database version may be invalid, or null if it is considered valid.static StringreasonWhyInvalidDataSourceName(String dataSourceName)Return the reason why the supplied data source name may be invalid, or null if it is considered valid.static StringreasonWhyInvalidDescription(String description)Return the reason why the supplied description may be invalid, or null if it is considered valid.static StringreasonWhyInvalidFetchSize(int fetchSize)The reason why fetchSize is invalid.static StringreasonWhyInvalidPartialResultsMode(String partialMode)The reason why partialResultsMode is invalid.static StringreasonWhyInvalidPassword(String pwd)Return the reason why the supplied password may be invalid, or null if it is considered valid.static StringreasonWhyInvalidTransactionAutoWrap(String autoWrap)Return the reason why the supplied transaction auto wrap value may be invalid, or null if it is considered valid.static StringreasonWhyInvalidUser(String userName)Return the reason why the supplied user name may be invalid, or null if it is considered valid.voidsetAdditionalProperties(String additionalProperties)voidsetAnsiQuotedIdentifiers(boolean ansiQuotedIdentifiers)voidsetApplicationName(String applicationName)Sets the name of the application.voidsetAutoCommitTxn(String transactionAutoWrap)Sets the setting for how connections are created by this DataSource manage transactions for client requests with autoCommit = true.voidsetDatabaseName(String databaseName)Sets the name of the virtual database on a particular Teiid Server.voidsetDatabaseVersion(String databaseVersion)Sets the databaseVersion.voidsetDataSourceName(String dataSourceName)Sets the logical name for the underlyingXADataSourceorConnectionPoolDataSource; used only when pooling connections or distributed transactions are implemented.voidsetDescription(String description)Sets the description of this data source.voidsetDisableLocalTxn(String disableLocalTxn)voidsetFetchSize(int fetchSize)voidsetLoginTimeout(int timeOut)voidsetLogWriter(PrintWriter writer)voidsetNoExec(boolean noExec)voidsetPartialResultsMode(String partialResultsMode)voidsetPassword(String password)Sets the password.voidsetQueryTimeout(int queryTimeout)voidsetResultSetCacheMode(String resultSetCacheMode)voidsetShowPlan(String showPlan)voidsetUseJDBC4ColumnNameAndLabelSemantics(boolean useJDBC4ColumnNameAndLabelSemantics)voidsetUser(String user)Sets the user.protected voidvalidateProperties(String userName, String password)-
Methods inherited from class org.teiid.jdbc.WrapperImpl
isWrapperFor, unwrap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.sql.CommonDataSource
getParentLogger
-
Methods inherited from interface javax.sql.DataSource
getConnection
-
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
-
Methods inherited from interface javax.sql.XADataSource
getXAConnection
-
-
-
-
Field Detail
-
DEFAULT_APP_NAME
public static final String DEFAULT_APP_NAME
- See Also:
- Constant Field Values
-
VDB_NAME
public static final String VDB_NAME
- See Also:
- Constant Field Values
-
VDB_VERSION
public static final String VDB_VERSION
- See Also:
- Constant Field Values
-
VERSION
public static final String VERSION
- See Also:
- Constant Field Values
-
APP_NAME
public static final String APP_NAME
- See Also:
- Constant Field Values
-
USER_NAME
public static final String USER_NAME
- See Also:
- Constant Field Values
-
PASSWORD
public static final String PASSWORD
- See Also:
- Constant Field Values
-
DEFAULT_TIMEOUT
protected static final int DEFAULT_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_LOG_LEVEL
protected static final int DEFAULT_LOG_LEVEL
- See Also:
- Constant Field Values
-
JDBC
public static final String JDBC
- See Also:
- Constant Field Values
-
DEFAULT_FETCH_SIZE
protected static final int DEFAULT_FETCH_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_PARTIAL_RESULTS_MODE
protected static final String DEFAULT_PARTIAL_RESULTS_MODE
- See Also:
- Constant Field Values
-
DEFAULT_RESULT_SET_CACHE_MODE
protected static final String DEFAULT_RESULT_SET_CACHE_MODE
- See Also:
- Constant Field Values
-
TXN_WRAP_OFF
public static final String TXN_WRAP_OFF
Transaction auto wrap constant - never wrap a command execution in a transaction and allow multi-source updates to occur outside of a transaction.- See Also:
- Constant Field Values
-
TXN_WRAP_ON
public static final String TXN_WRAP_ON
Transaction auto wrap constant - always wrap every non-transactional command execution in a transaction.- See Also:
- Constant Field Values
-
TXN_WRAP_AUTO
public static final String TXN_WRAP_AUTO
Transaction auto wrap constant - checks if a command requires a transaction and will be automatically wrap it.- See Also:
- Constant Field Values
-
-
Method Detail
-
buildProperties
protected Properties buildProperties(String userName, String password)
-
validateProperties
protected void validateProperties(String userName, String password) throws SQLException
- Throws:
SQLException
-
getConnection
public Connection getConnection() throws SQLException
Attempt to establish a database connection.- Specified by:
getConnectionin interfaceDataSource- Returns:
- a Connection to the database
- Throws:
SQLException- if a database-access error occurs- See Also:
DataSource.getConnection()
-
getXAConnection
public XAConnection getXAConnection() throws SQLException
- Specified by:
getXAConnectionin interfaceXADataSource- Throws:
SQLException- See Also:
XADataSource.getXAConnection()
-
getPooledConnection
public PooledConnection getPooledConnection() throws SQLException
- Specified by:
getPooledConnectionin interfaceConnectionPoolDataSource- Throws:
SQLException
-
getPooledConnection
public PooledConnection getPooledConnection(String userName, String password) throws SQLException
- Specified by:
getPooledConnectionin interfaceConnectionPoolDataSource- Throws:
SQLException
-
getDisableLocalTxn
public String getDisableLocalTxn()
-
setDisableLocalTxn
public void setDisableLocalTxn(String disableLocalTxn)
-
getLogWriter
public PrintWriter getLogWriter() throws SQLException
- Specified by:
getLogWriterin interfaceCommonDataSource- Throws:
SQLException
-
getLoginTimeout
public int getLoginTimeout()
- Specified by:
getLoginTimeoutin interfaceCommonDataSource
-
setLogWriter
public void setLogWriter(PrintWriter writer) throws SQLException
- Specified by:
setLogWriterin interfaceCommonDataSource- Throws:
SQLException
-
setLoginTimeout
public void setLoginTimeout(int timeOut) throws SQLException- Specified by:
setLoginTimeoutin interfaceCommonDataSource- Throws:
SQLException
-
getApplicationName
public String getApplicationName()
Returns the name of the application. Supplying this property may allow an administrator of a Teiid Server to better identify individual connections and usage patterns. This property is optional.- Returns:
- String the application name; may be null or zero-length
-
getDatabaseName
public String getDatabaseName()
Returns the name of the virtual database on a particular Teiid Server.- Returns:
- String
-
getDatabaseVersion
public String getDatabaseVersion()
Returns the databaseVersion.- Returns:
- String
-
getDataSourceName
public String getDataSourceName()
Returns the logical name for the underlyingXADataSourceorConnectionPoolDataSource; used only when pooling connections or distributed transactions are implemented.- Returns:
- the logical name for the underlying data source; may be null
-
getDescription
public String getDescription()
Returns the description of this data source.- Returns:
- the description; may be null
-
getUser
public String getUser()
Returns the user.- Returns:
- the name of the user for this data source
-
getPassword
public String getPassword()
Returns the password.- Returns:
- the password for this data source.
-
setApplicationName
public void setApplicationName(String applicationName)
Sets the name of the application. Supplying this property may allow an administrator of a Teiid Server to better identify individual connections and usage patterns. This property is optional.- Parameters:
applicationName- The applicationName to set
-
setDatabaseName
public void setDatabaseName(String databaseName)
Sets the name of the virtual database on a particular Teiid Server.- Parameters:
databaseName- The name of the virtual database
-
setDatabaseVersion
public void setDatabaseVersion(String databaseVersion)
Sets the databaseVersion.- Parameters:
databaseVersion- The version of the virtual database
-
setDataSourceName
public void setDataSourceName(String dataSourceName)
Sets the logical name for the underlyingXADataSourceorConnectionPoolDataSource; used only when pooling connections or distributed transactions are implemented.- Parameters:
dataSourceName- The dataSourceName for this data source; may be null
-
setUser
public void setUser(String user)
Sets the user.- Parameters:
user- The user to set
-
setPassword
public void setPassword(String password)
Sets the password.- Parameters:
password- The password for this data source
-
setDescription
public void setDescription(String description)
Sets the description of this data source.- Parameters:
description- The description for this data source; may be null
-
setPartialResultsMode
public void setPartialResultsMode(String partialResultsMode)
-
getPartialResultsMode
public String getPartialResultsMode()
-
setFetchSize
public void setFetchSize(int fetchSize)
-
getFetchSize
public int getFetchSize()
-
setResultSetCacheMode
public void setResultSetCacheMode(String resultSetCacheMode)
-
getResultSetCacheMode
public String getResultSetCacheMode()
-
getShowPlan
public String getShowPlan()
-
setShowPlan
public void setShowPlan(String showPlan)
-
setNoExec
public void setNoExec(boolean noExec)
-
isNoExec
public boolean isNoExec()
-
getAutoCommitTxn
public String getAutoCommitTxn()
Returns the current setting for how connections are created by this DataSource manage transactions for client requests when client applications do not use transactions. Because a virtual database will likely deal with multiple underlying information sources, Teiid will execute all client requests within the contexts of transactions. This method determines the semantics of creating such transactions when the client does not explicitly do so.- Returns:
- the current setting, or null if the property has not been set and the default mode will be used.
-
setAutoCommitTxn
public void setAutoCommitTxn(String transactionAutoWrap)
Sets the setting for how connections are created by this DataSource manage transactions for client requests with autoCommit = true. Because a virtual database will likely deal with multiple underlying information sources, Teiid will execute all client requests within the contexts of transactions. This method determines the semantics of creating such transactions when the client does not explicitly do so.The allowable values for this property are:
- "
OFF" - Nothing is ever wrapped in a transaction and the server will execute multi-source updates happily but outside a transaction. This is least safe but highest performance. TheTXN_WRAP_OFFconstant value is provided for convenience. - "
ON" - Always wrap every command in a transaction. This is most safe but lowest performance. TheTXN_WRAP_ONconstant value is provided for convenience. - "
AUTO" - checks if a command requires a transaction and will be automatically wrap it. This is the default mode. TheTXN_WRAP_AUTOconstant value is provided for convenience.
- Parameters:
transactionAutoWrap- The transactionAutoWrap to set
- "
-
getUseJDBC4ColumnNameAndLabelSemantics
public boolean getUseJDBC4ColumnNameAndLabelSemantics()
-
setUseJDBC4ColumnNameAndLabelSemantics
public void setUseJDBC4ColumnNameAndLabelSemantics(boolean useJDBC4ColumnNameAndLabelSemantics)
-
reasonWhyInvalidApplicationName
public static String reasonWhyInvalidApplicationName(String applicationName)
Return the reason why the supplied application name may be invalid, or null if it is considered valid.- Parameters:
applicationName- a possible value for the property- Returns:
- the reason why the property is invalid, or null if it is considered valid
- See Also:
setApplicationName(String)
-
reasonWhyInvalidDatabaseName
public static String reasonWhyInvalidDatabaseName(String databaseName)
Return the reason why the supplied virtual database name may be invalid, or null if it is considered valid.- Parameters:
databaseName- a possible value for the property- Returns:
- the reason why the property is invalid, or null if it is considered valid
- See Also:
setDatabaseName(String)
-
reasonWhyInvalidUser
public static String reasonWhyInvalidUser(String userName)
Return the reason why the supplied user name may be invalid, or null if it is considered valid.- Parameters:
userName- a possible value for the property- Returns:
- the reason why the property is invalid, or null if it is considered valid
- See Also:
setUser(String)
-
reasonWhyInvalidTransactionAutoWrap
public static String reasonWhyInvalidTransactionAutoWrap(String autoWrap)
Return the reason why the supplied transaction auto wrap value may be invalid, or null if it is considered valid.This method checks to see that the value is one of the allowable values.
- Parameters:
autoWrap- a possible value for the auto wrap property.- Returns:
- the reason why the property is invalid, or null if it is considered valid
- See Also:
setAutoCommitTxn(String)
-
reasonWhyInvalidDatabaseVersion
public static String reasonWhyInvalidDatabaseVersion(String databaseVersion)
Return the reason why the supplied virtual database version may be invalid, or null if it is considered valid.- Parameters:
databaseVersion- a possible value for the property- Returns:
- the reason why the property is invalid, or null if it is considered valid
- See Also:
setDatabaseVersion(String)
-
reasonWhyInvalidDataSourceName
public static String reasonWhyInvalidDataSourceName(String dataSourceName)
Return the reason why the supplied data source name may be invalid, or null if it is considered valid.- Parameters:
dataSourceName- a possible value for the property- Returns:
- the reason why the property is invalid, or null if it is considered valid
- See Also:
setDataSourceName(String)
-
reasonWhyInvalidPassword
public static String reasonWhyInvalidPassword(String pwd)
Return the reason why the supplied password may be invalid, or null if it is considered valid.- Parameters:
pwd- a possible value for the property- Returns:
- the reason why the property is invalid, or null if it is considered valid
- See Also:
setPassword(String)
-
reasonWhyInvalidDescription
public static String reasonWhyInvalidDescription(String description)
Return the reason why the supplied description may be invalid, or null if it is considered valid.- Parameters:
description- a possible value for the property- Returns:
- the reason why the property is invalid, or null if it is considered valid
- See Also:
setDescription(String)
-
reasonWhyInvalidPartialResultsMode
public static String reasonWhyInvalidPartialResultsMode(String partialMode)
The reason why partialResultsMode is invalid.- Parameters:
partialMode- boolean flag- Returns:
- String reason
-
reasonWhyInvalidFetchSize
public static String reasonWhyInvalidFetchSize(int fetchSize)
The reason why fetchSize is invalid.- Parameters:
fetchSize- Number of rows per batch- Returns:
- the reason why the property is invalid, or null if it is considered valid
-
setAdditionalProperties
public void setAdditionalProperties(String additionalProperties)
-
getAdditionalProperties
public String getAdditionalProperties()
-
setAnsiQuotedIdentifiers
public void setAnsiQuotedIdentifiers(boolean ansiQuotedIdentifiers)
-
isAnsiQuotedIdentifiers
public boolean isAnsiQuotedIdentifiers()
-
getQueryTimeout
public int getQueryTimeout()
-
setQueryTimeout
public void setQueryTimeout(int queryTimeout)
-
-