public abstract class BaseDataSource extends WrapperImpl implements DataSource, XADataSource, ConnectionPoolDataSource, Serializable
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., get
PropertyName() :
PropertyType
and set
PropertyName(
PropertyType) : void
).
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.Modifier and Type | Field and 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 and Description |
---|
BaseDataSource()
Constructor for MMDataSource.
|
Modifier and Type | Method and 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 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) |
isWrapperFor, unwrap
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConnection
isWrapperFor, unwrap
getParentLogger
public static final String DEFAULT_APP_NAME
public static final String VDB_NAME
public static final String VDB_VERSION
public static final String VERSION
public static final String APP_NAME
public static final String USER_NAME
public static final String PASSWORD
protected static final int DEFAULT_TIMEOUT
protected static final int DEFAULT_LOG_LEVEL
public static final String JDBC
protected static final int DEFAULT_FETCH_SIZE
protected static final String DEFAULT_PARTIAL_RESULTS_MODE
protected static final String DEFAULT_RESULT_SET_CACHE_MODE
public static final String TXN_WRAP_OFF
public static final String TXN_WRAP_ON
public static final String TXN_WRAP_AUTO
protected Properties buildProperties(String userName, String password)
protected void validateProperties(String userName, String password) throws SQLException
SQLException
public Connection getConnection() throws SQLException
getConnection
in interface DataSource
SQLException
- if a database-access error occursDataSource.getConnection()
public XAConnection getXAConnection() throws SQLException
getXAConnection
in interface XADataSource
SQLException
XADataSource.getXAConnection()
public XAConnection getXAConnection(String userName, String password) throws SQLException
getXAConnection
in interface XADataSource
userName
- the database user on whose behalf the XAConnection is being madepassword
- the user's passwordSQLException
- if a database-access error occursXADataSource.getXAConnection(java.lang.String, java.lang.String)
public PooledConnection getPooledConnection() throws SQLException
getPooledConnection
in interface ConnectionPoolDataSource
SQLException
public PooledConnection getPooledConnection(String userName, String password) throws SQLException
getPooledConnection
in interface ConnectionPoolDataSource
SQLException
public String getDisableLocalTxn()
public void setDisableLocalTxn(String disableLocalTxn)
public PrintWriter getLogWriter() throws SQLException
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.
getLogWriter
in interface CommonDataSource
SQLException
- if a database-access error occursCommonDataSource.getLogWriter()
public int getLoginTimeout() throws SQLException
getLoginTimeout
in interface CommonDataSource
SQLException
- if a database-access error occursCommonDataSource.getLoginTimeout()
public void setLogWriter(PrintWriter writer) throws SQLException
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.
setLogWriter
in interface CommonDataSource
writer
- the log writer for this data source, null if disabledSQLException
- if a database-access error occursCommonDataSource.setLogWriter(java.io.PrintWriter)
public void setLoginTimeout(int timeOut) throws SQLException
setLoginTimeout
in interface CommonDataSource
timeOut
- the data source login time limitSQLException
- if a database-access error occursCommonDataSource.setLoginTimeout(int)
public String getApplicationName()
public String getDatabaseName()
public String getDatabaseVersion()
public String getDataSourceName()
XADataSource
or
ConnectionPoolDataSource
;
used only when pooling connections or distributed transactions are implemented.public String getDescription()
public String getUser()
public String getPassword()
public void setApplicationName(String applicationName)
applicationName
- The applicationName to setpublic void setDatabaseName(String databaseName)
databaseName
- The name of the virtual databasepublic void setDatabaseVersion(String databaseVersion)
databaseVersion
- The version of the virtual databasepublic void setDataSourceName(String dataSourceName)
XADataSource
or
ConnectionPoolDataSource
;
used only when pooling connections or distributed transactions are implemented.dataSourceName
- The dataSourceName for this data source; may be nullpublic void setUser(String user)
user
- The user to setpublic void setPassword(String password)
password
- The password for this data sourcepublic void setDescription(String description)
description
- The description for this data source; may be nullpublic void setPartialResultsMode(String partialResultsMode)
public String getPartialResultsMode()
public void setFetchSize(int fetchSize)
public int getFetchSize()
public void setResultSetCacheMode(String resultSetCacheMode)
public String getResultSetCacheMode()
public String getShowPlan()
public void setShowPlan(String showPlan)
public void setNoExec(boolean noExec)
public boolean isNoExec()
public String getTransactionAutoWrap()
getAutoCommitTxn()
public void setTransactionAutoWrap(String transactionAutoWrap)
transactionAutoWrap
- setAutoCommitTxn(String)
public String getAutoCommitTxn()
public void setAutoCommitTxn(String transactionAutoWrap)
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.
The TXN_WRAP_OFF
constant value is provided for convenience.ON
" - Always wrap every command in a transaction. This is most safe but lowest
performance.
The TXN_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.
The TXN_WRAP_AUTO
constant value is provided for convenience.transactionAutoWrap
- The transactionAutoWrap to setpublic boolean getUseJDBC4ColumnNameAndLabelSemantics()
public void setUseJDBC4ColumnNameAndLabelSemantics(boolean useJDBC4ColumnNameAndLabelSemantics)
public static String reasonWhyInvalidApplicationName(String applicationName)
applicationName
- a possible value for the propertysetApplicationName(String)
public static String reasonWhyInvalidDatabaseName(String databaseName)
databaseName
- a possible value for the propertysetDatabaseName(String)
public static String reasonWhyInvalidUser(String userName)
userName
- a possible value for the propertysetUser(String)
public static String reasonWhyInvalidTransactionAutoWrap(String autoWrap)
This method checks to see that the value is one of the allowable values.
autoWrap
- a possible value for the auto wrap property.setTransactionAutoWrap(String)
public static String reasonWhyInvalidDatabaseVersion(String databaseVersion)
databaseVersion
- a possible value for the propertysetDatabaseVersion(String)
public static String reasonWhyInvalidDataSourceName(String dataSourceName)
dataSourceName
- a possible value for the propertysetDataSourceName(String)
public static String reasonWhyInvalidPassword(String pwd)
pwd
- a possible value for the propertysetPassword(String)
public static String reasonWhyInvalidDescription(String description)
description
- a possible value for the propertysetDescription(String)
public static String reasonWhyInvalidPartialResultsMode(String partialMode)
partialMode
- boolean flagpublic static String reasonWhyInvalidFetchSize(int fetchSize)
fetchSize
- Number of rows per batchpublic void setAdditionalProperties(String additionalProperties)
public String getAdditionalProperties()
public void setAnsiQuotedIdentifiers(boolean ansiQuotedIdentifiers)
public boolean isAnsiQuotedIdentifiers()
public int getQueryTimeout()
public void setQueryTimeout(int queryTimeout)
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.