org.teiid.jdbc
Class BaseDataSource

java.lang.Object
  extended by org.teiid.jdbc.WrapperImpl
      extended by 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 of DataSource and XADataSource.

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., getPropertyName() : PropertyType and setPropertyName(PropertyType) : void).

The XADataSource interface is almost identical to the DataSource interface, but rather than returning Connection instances, there are methods that return XAConnection instances that can be used with distributed transactions.

See Also:
Serialized Form

Field Summary
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
BaseDataSource()
          Constructor for MMDataSource.
 
Method Summary
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 underlying XADataSource or ConnectionPoolDataSource; 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()
          Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.
 PrintWriter getLogWriter()
          Get the log writer for this data source.
 String getPartialResultsMode()
           
 String getPassword()
          Returns the password.
 PooledConnection getPooledConnection()
           
 PooledConnection getPooledConnection(String userName, String password)
           
 int getQueryTimeout()
           
 String getResultSetCacheMode()
           
 String getShowPlan()
           
 String getTransactionAutoWrap()
          Deprecated.  
 boolean getUseJDBC4ColumnNameAndLabelSemantics()
           
 String getUser()
          Returns the user.
 XAConnection getXAConnection()
           
 XAConnection getXAConnection(String userName, String password)
          Attempt to establish a database connection that can be used with distributed transactions.
 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 underlying XADataSource or ConnectionPoolDataSource; 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)
          Sets the maximum time in seconds that this data source can wait while attempting to connect to a database.
 void setLogWriter(PrintWriter writer)
          Set the log writer for this data source.
 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 setTransactionAutoWrap(String transactionAutoWrap)
          Deprecated.  
 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.DataSource
getConnection
 
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
 

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
Constructor Detail

BaseDataSource

public BaseDataSource()
Constructor for MMDataSource.

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 interface DataSource
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 interface XADataSource
Throws:
SQLException
See Also:
XADataSource.getXAConnection()

getXAConnection

public XAConnection getXAConnection(String userName,
                                    String password)
                             throws SQLException
Attempt to establish a database connection that can be used with distributed transactions.

Specified by:
getXAConnection in interface XADataSource
Parameters:
userName - the database user on whose behalf the XAConnection is being made
password - the user's password
Returns:
an XAConnection to the database
Throws:
SQLException - if a database-access error occurs
See Also:
XADataSource.getXAConnection(java.lang.String, java.lang.String)

getPooledConnection

public PooledConnection getPooledConnection()
                                     throws SQLException
Specified by:
getPooledConnection in interface ConnectionPoolDataSource
Throws:
SQLException

getPooledConnection

public PooledConnection getPooledConnection(String userName,
                                            String password)
                                     throws SQLException
Specified by:
getPooledConnection in interface ConnectionPoolDataSource
Throws:
SQLException

getDisableLocalTxn

public String getDisableLocalTxn()

setDisableLocalTxn

public void setDisableLocalTxn(String disableLocalTxn)

getLogWriter

public PrintWriter getLogWriter()
                         throws SQLException
Get the log writer for this data source.

The log writer is a character output stream to which all logging and tracing messages for this data source object instance will be printed. This includes messages printed by the methods of this object, messages printed by methods of other objects manufactured by this object, and so on. Messages printed to a data source specific log writer are not printed to the log writer associated with the DriverManager class. When a DataSource object is created the log writer is initially null, in other words, logging is disabled.

Specified by:
getLogWriter in interface CommonDataSource
Returns:
the log writer for this data source, null if disabled
Throws:
SQLException - if a database-access error occurs
See Also:
CommonDataSource.getLogWriter()

getLoginTimeout

public int getLoginTimeout()
                    throws SQLException
Gets the maximum time in seconds that this data source can wait while attempting to connect to a database. A value of zero means that the timeout is the default system timeout if there is one; otherwise it means that there is no timeout. When a DataSource object is created the login timeout is initially zero.

Specified by:
getLoginTimeout in interface CommonDataSource
Returns:
the data source login time limit
Throws:
SQLException - if a database-access error occurs
See Also:
CommonDataSource.getLoginTimeout()

setLogWriter

public void setLogWriter(PrintWriter writer)
                  throws SQLException
Set the log writer for this data source.

The log writer is a character output stream to which all logging and tracing messages for this data source object instance will be printed. This includes messages printed by the methods of this object, messages printed by methods of other objects manufactured by this object, and so on. Messages printed to a data source specific log writer are not printed to the log writer associated with the DriverManager class. When a DataSource object is created the log writer is initially null, in other words, logging is disabled.

Specified by:
setLogWriter in interface CommonDataSource
Parameters:
writer - the log writer for this data source, null if disabled
Throws:
SQLException - if a database-access error occurs
See Also:
CommonDataSource.setLogWriter(java.io.PrintWriter)

setLoginTimeout

public void setLoginTimeout(int timeOut)
                     throws SQLException
Sets the maximum time in seconds that this data source can wait while attempting to connect to a database. A value of zero means that the timeout is the default system timeout if there is one; otherwise it means that there is no timeout. When a DataSource object is created the login timeout is initially zero.

Specified by:
setLoginTimeout in interface CommonDataSource
Parameters:
timeOut - the data source login time limit
Throws:
SQLException - if a database-access error occurs
See Also:
CommonDataSource.setLoginTimeout(int)

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 underlying XADataSource or ConnectionPoolDataSource; 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 underlying XADataSource or ConnectionPoolDataSource; 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()

getTransactionAutoWrap

public String getTransactionAutoWrap()
Deprecated. 

Returns:
See Also:
getAutoCommitTxn()

setTransactionAutoWrap

public void setTransactionAutoWrap(String transactionAutoWrap)
Deprecated. 

Parameters:
transactionAutoWrap -
See Also:
setAutoCommitTxn(String)

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:

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:
setTransactionAutoWrap(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)


Copyright © 2012. All Rights Reserved.