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 ofDataSource
andXADataSource
.The
DataSource
interface 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.,get
PropertyName() :
PropertyType andset
PropertyName(
PropertyType) : void
). TheXADataSource
interface is almost identical to theDataSource
interface, but rather than returningConnection
instances, there are methods that returnXAConnection
instances that can be used with distributed transactions.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
APP_NAME
static String
DEFAULT_APP_NAME
protected static int
DEFAULT_FETCH_SIZE
protected static int
DEFAULT_LOG_LEVEL
protected static String
DEFAULT_PARTIAL_RESULTS_MODE
protected static String
DEFAULT_RESULT_SET_CACHE_MODE
protected static int
DEFAULT_TIMEOUT
static String
JDBC
static String
PASSWORD
static String
TXN_WRAP_AUTO
Transaction auto wrap constant - checks if a command requires a transaction and will be automatically wrap it.static 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.static String
TXN_WRAP_ON
Transaction auto wrap constant - always wrap every non-transactional command execution in a transaction.static String
USER_NAME
static String
VDB_NAME
static String
VDB_VERSION
static String
VERSION
-
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 Properties
buildProperties(String userName, String password)
String
getAdditionalProperties()
String
getApplicationName()
Returns the name of the application.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.Connection
getConnection()
Attempt to establish a database connection.String
getDatabaseName()
Returns the name of the virtual database on a particular Teiid Server.String
getDatabaseVersion()
Returns the databaseVersion.String
getDataSourceName()
Returns the logical name for the underlyingXADataSource
orConnectionPoolDataSource
; used only when pooling connections or distributed transactions are implemented.String
getDescription()
Returns the description of this data source.String
getDisableLocalTxn()
int
getFetchSize()
int
getLoginTimeout()
PrintWriter
getLogWriter()
String
getPartialResultsMode()
String
getPassword()
Returns the password.PooledConnection
getPooledConnection()
PooledConnection
getPooledConnection(String userName, String password)
int
getQueryTimeout()
String
getResultSetCacheMode()
String
getShowPlan()
boolean
getUseJDBC4ColumnNameAndLabelSemantics()
String
getUser()
Returns the user.XAConnection
getXAConnection()
boolean
isAnsiQuotedIdentifiers()
boolean
isNoExec()
static String
reasonWhyInvalidApplicationName(String applicationName)
Return the reason why the supplied application name may be invalid, or null if it is considered valid.static String
reasonWhyInvalidDatabaseName(String databaseName)
Return the reason why the supplied virtual database name may be invalid, or null if it is considered valid.static String
reasonWhyInvalidDatabaseVersion(String databaseVersion)
Return the reason why the supplied virtual database version may be invalid, or null if it is considered valid.static String
reasonWhyInvalidDataSourceName(String dataSourceName)
Return the reason why the supplied data source name may be invalid, or null if it is considered valid.static String
reasonWhyInvalidDescription(String description)
Return the reason why the supplied description may be invalid, or null if it is considered valid.static String
reasonWhyInvalidFetchSize(int fetchSize)
The reason why fetchSize is invalid.static String
reasonWhyInvalidPartialResultsMode(String partialMode)
The reason why partialResultsMode is invalid.static String
reasonWhyInvalidPassword(String pwd)
Return the reason why the supplied password may be invalid, or null if it is considered valid.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.static String
reasonWhyInvalidUser(String userName)
Return the reason why the supplied user name may be invalid, or null if it is considered valid.void
setAdditionalProperties(String additionalProperties)
void
setAnsiQuotedIdentifiers(boolean ansiQuotedIdentifiers)
void
setApplicationName(String applicationName)
Sets the name of the application.void
setAutoCommitTxn(String transactionAutoWrap)
Sets the setting for how connections are created by this DataSource manage transactions for client requests with autoCommit = true.void
setDatabaseName(String databaseName)
Sets the name of the virtual database on a particular Teiid Server.void
setDatabaseVersion(String databaseVersion)
Sets the databaseVersion.void
setDataSourceName(String dataSourceName)
Sets the logical name for the underlyingXADataSource
orConnectionPoolDataSource
; used only when pooling connections or distributed transactions are implemented.void
setDescription(String description)
Sets the description of this data source.void
setDisableLocalTxn(String disableLocalTxn)
void
setFetchSize(int fetchSize)
void
setLoginTimeout(int timeOut)
void
setLogWriter(PrintWriter writer)
void
setNoExec(boolean noExec)
void
setPartialResultsMode(String partialResultsMode)
void
setPassword(String password)
Sets the password.void
setQueryTimeout(int queryTimeout)
void
setResultSetCacheMode(String resultSetCacheMode)
void
setShowPlan(String showPlan)
void
setUseJDBC4ColumnNameAndLabelSemantics(boolean useJDBC4ColumnNameAndLabelSemantics)
void
setUser(String user)
Sets the user.protected void
validateProperties(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:
getConnection
in 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:
getXAConnection
in interfaceXADataSource
- Throws:
SQLException
- See Also:
XADataSource.getXAConnection()
-
getPooledConnection
public PooledConnection getPooledConnection() throws SQLException
- Specified by:
getPooledConnection
in interfaceConnectionPoolDataSource
- Throws:
SQLException
-
getPooledConnection
public PooledConnection getPooledConnection(String userName, String password) throws SQLException
- Specified by:
getPooledConnection
in interfaceConnectionPoolDataSource
- Throws:
SQLException
-
getDisableLocalTxn
public String getDisableLocalTxn()
-
setDisableLocalTxn
public void setDisableLocalTxn(String disableLocalTxn)
-
getLogWriter
public PrintWriter getLogWriter() throws SQLException
- Specified by:
getLogWriter
in interfaceCommonDataSource
- Throws:
SQLException
-
getLoginTimeout
public int getLoginTimeout()
- Specified by:
getLoginTimeout
in interfaceCommonDataSource
-
setLogWriter
public void setLogWriter(PrintWriter writer) throws SQLException
- Specified by:
setLogWriter
in interfaceCommonDataSource
- Throws:
SQLException
-
setLoginTimeout
public void setLoginTimeout(int timeOut) throws SQLException
- Specified by:
setLoginTimeout
in 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 underlyingXADataSource
orConnectionPoolDataSource
; 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 underlyingXADataSource
orConnectionPoolDataSource
; 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_OFF
constant value is provided for convenience. - "
ON
" - Always wrap every command in a transaction. This is most safe but lowest performance. TheTXN_WRAP_ON
constant 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_AUTO
constant 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)
-
-