|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.metamatrix.jdbc.WrapperImpl
com.metamatrix.jdbc.BaseDataSource
public abstract class BaseDataSource
The MetaMatrix 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., 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.
The following are the properties for this DataSource:
Property Name | Type | Description | ||||||||
applicationName | String | The optional name of the application using the DataSource. | ||||||||
clientToken | Serializable | The optional client token that will be passed directly
through to the connectors, which may use it and/or pass it
down to their underlying data source.
The form and type of the client token is up to the client but it must implement the
| ||||||||
databaseName | String | The name of a particular virtual database on a MetaMatrix Server. | ||||||||
databaseVersion | String | The optional version of a particular virtual database on a MetaMatrix Server; if not supplied, then the latest version is assumed. | ||||||||
dataSourceName | String | The optional logical name for the underlying
XADataSource or ConnectionPoolDataSource ;
used only when pooling connections or distributed transactions
are implemented. | ||||||||
description | String | The optional description of this data source. | ||||||||
logFile | String | The optional path and file name to which JDBC Log Statements will be written; if none is specified, then no Log Statements will be written. | ||||||||
logLevel | int | The optional level for logging, which only applies
if the logFile property is set. Value must be
one of the following:
| ||||||||
password | String | The user's password. | ||||||||
user | String | The user name to use for the connection. | ||||||||
partialResultsMode | boolean | Support partial results mode or not. | ||||||||
fetchSize | int | Set default fetch size for statements, default=500. | ||||||||
sqlOptions | String | Set sql options to use on every command. default=null |
Field Summary | |
---|---|
static java.lang.String |
APP_NAME
|
protected static int |
DEFAULT_FETCH_SIZE
|
protected static int |
DEFAULT_LOG_LEVEL
|
protected static java.lang.String |
DEFAULT_PARTIAL_RESULTS_MODE
|
protected static java.lang.String |
DEFAULT_RESULT_SET_CACHE_MODE
|
protected static int |
DEFAULT_TIMEOUT
|
static java.lang.String |
JDBC
|
static java.lang.String |
METAMATRIX_PROTOCOL
|
static java.lang.String |
PASSWORD
|
static java.lang.String |
TXN_AUTO_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 java.lang.String |
TXN_AUTO_WRAP_ON
Transaction auto wrap constant - always wrap every non-transactional command execution in a transaction. |
static java.lang.String |
TXN_AUTO_WRAP_OPTIMISTIC
Transaction auto wrap constant - optimistic mode assumes that non-transactional commands typically do not require a transaction due to a multi-source update, so no transaction is created. |
static java.lang.String |
TXN_AUTO_WRAP_PESSIMISTIC
Transaction auto wrap constant - pessimistic mode assumes that any command execution might require a transaction to be wrapped around it. |
static java.lang.String |
USER_NAME
|
static java.lang.String |
VDB_NAME
|
static java.lang.String |
VDB_VERSION
|
static java.lang.String |
VERSION
|
Constructor Summary | |
---|---|
BaseDataSource()
Constructor for MMDataSource. |
Method Summary | |
---|---|
protected java.util.Properties |
buildProperties(java.lang.String userName,
java.lang.String password)
|
java.lang.String |
getAdditionalProperties()
|
java.lang.String |
getApplicationName()
Returns the name of the application. |
java.io.Serializable |
getClientToken()
Get the Serializable client token that will be passed directly
through to the connectors, which may use it and/or pass it down to their underlying data source. |
java.sql.Connection |
getConnection()
Attempt to establish a database connection. |
java.lang.String |
getDatabaseName()
Returns the name of the virtual database on a particular MetaMatrix Server. |
java.lang.String |
getDatabaseVersion()
Returns the databaseVersion. |
java.lang.String |
getDataSourceName()
Returns the logical name for the underlying XADataSource or
ConnectionPoolDataSource ;
used only when pooling connections or distributed transactions are implemented. |
java.lang.String |
getDescription()
Returns the description of this data source. |
java.lang.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. |
java.io.PrintWriter |
getLogWriter()
Get the log writer for this data source. |
java.lang.String |
getPartialResultsMode()
|
java.lang.String |
getPassword()
Returns the password. |
javax.sql.PooledConnection |
getPooledConnection()
|
javax.sql.PooledConnection |
getPooledConnection(java.lang.String userName,
java.lang.String password)
|
java.lang.String |
getResultSetCacheMode()
|
java.lang.String |
getSqlOptions()
Get special sqlOptions string, which can currently be set only to SHOWPLAN |
java.lang.String |
getTransactionAutoWrap()
Returns the current setting for how connections are created by this DataSource manage transactions for client requests when client applications do not use transactions. |
java.lang.String |
getUser()
Returns the user. |
javax.sql.XAConnection |
getXAConnection()
|
javax.sql.XAConnection |
getXAConnection(java.lang.String userName,
java.lang.String password)
Attempt to establish a database connection that can be used with distributed transactions. |
static java.lang.String |
reasonWhyInvalidApplicationName(java.lang.String applicationName)
Return the reason why the supplied application name may be invalid, or null if it is considered valid. |
static java.lang.String |
reasonWhyInvalidClientToken(java.io.Serializable clientToken)
Return the reason why the supplied client token may be invalid, or null if it is considered valid. |
static java.lang.String |
reasonWhyInvalidDatabaseName(java.lang.String databaseName)
Return the reason why the supplied virtual database name may be invalid, or null if it is considered valid. |
static java.lang.String |
reasonWhyInvalidDatabaseVersion(java.lang.String databaseVersion)
Return the reason why the supplied virtual database version may be invalid, or null if it is considered valid. |
static java.lang.String |
reasonWhyInvalidDataSourceName(java.lang.String dataSourceName)
Return the reason why the supplied data source name may be invalid, or null if it is considered valid. |
static java.lang.String |
reasonWhyInvalidDescription(java.lang.String description)
Return the reason why the supplied description may be invalid, or null if it is considered valid. |
static java.lang.String |
reasonWhyInvalidFetchSize(int fetchSize)
The reason why fetchSize is invalid. |
static java.lang.String |
reasonWhyInvalidPartialResultsMode(java.lang.String partialMode)
The reason why partialResultsMode is invalid. |
static java.lang.String |
reasonWhyInvalidPassword(java.lang.String pwd)
Return the reason why the supplied password may be invalid, or null if it is considered valid. |
static java.lang.String |
reasonWhyInvalidTransactionAutoWrap(java.lang.String autoWrap)
Return the reason why the supplied transaction auto wrap value may be invalid, or null if it is considered valid. |
static java.lang.String |
reasonWhyInvalidUser(java.lang.String userName)
Return the reason why the supplied user name may be invalid, or null if it is considered valid. |
void |
setAdditionalProperties(java.lang.String additionalProperties)
|
void |
setApplicationName(java.lang.String applicationName)
Sets the name of the application. |
void |
setClientToken(java.io.Serializable clientToken)
Set the Serializable client token that will be passed directly
through to the connectors, which may use it and/or pass it down to their underlying data source. |
void |
setDatabaseName(java.lang.String databaseName)
Sets the name of the virtual database on a particular MetaMatrix Server. |
void |
setDatabaseVersion(java.lang.String databaseVersion)
Sets the databaseVersion. |
void |
setDataSourceName(java.lang.String dataSourceName)
Sets the logical name for the underlying XADataSource or
ConnectionPoolDataSource ;
used only when pooling connections or distributed transactions are implemented. |
void |
setDescription(java.lang.String description)
Sets the description of this data source. |
void |
setDisableLocalTxn(java.lang.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(java.io.PrintWriter writer)
Set the log writer for this data source. |
void |
setPartialResultsMode(java.lang.String partialResultsMode)
|
void |
setPassword(java.lang.String password)
Sets the password. |
void |
setResultSetCacheMode(java.lang.String resultSetCacheMode)
|
void |
setSqlOptions(java.lang.String sqlOptions)
Sets special sqlOptions that should be used with each command. |
void |
setTransactionAutoWrap(java.lang.String transactionAutoWrap)
Sets the setting for how connections are created by this DataSource manage transactions for client requests when client applications do not use transactions. |
void |
setUser(java.lang.String user)
Sets the user. |
protected void |
validateProperties(java.lang.String userName,
java.lang.String password)
|
Methods inherited from class com.metamatrix.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 |
---|
public static final java.lang.String VDB_NAME
public static final java.lang.String VDB_VERSION
public static final java.lang.String VERSION
public static final java.lang.String APP_NAME
public static final java.lang.String USER_NAME
public static final java.lang.String PASSWORD
protected static final int DEFAULT_TIMEOUT
protected static final int DEFAULT_LOG_LEVEL
public static final java.lang.String METAMATRIX_PROTOCOL
public static final java.lang.String JDBC
protected static final int DEFAULT_FETCH_SIZE
protected static final java.lang.String DEFAULT_PARTIAL_RESULTS_MODE
protected static final java.lang.String DEFAULT_RESULT_SET_CACHE_MODE
public static final java.lang.String TXN_AUTO_WRAP_OFF
public static final java.lang.String TXN_AUTO_WRAP_ON
public static final java.lang.String TXN_AUTO_WRAP_PESSIMISTIC
public static final java.lang.String TXN_AUTO_WRAP_OPTIMISTIC
TXN_AUTO_WRAP_OFF
. However, these modes differ because if we
discover during server execution that multiple sources will be updated by
a particular command, an exception is thrown to indicate that the command
cannot be executed. This is the default mode.
Constructor Detail |
---|
public BaseDataSource()
Method Detail |
---|
protected java.util.Properties buildProperties(java.lang.String userName, java.lang.String password)
protected void validateProperties(java.lang.String userName, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
public java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
- if a database-access error occursDataSource.getConnection()
public javax.sql.XAConnection getXAConnection() throws java.sql.SQLException
getXAConnection
in interface javax.sql.XADataSource
java.sql.SQLException
XADataSource.getXAConnection()
public javax.sql.XAConnection getXAConnection(java.lang.String userName, java.lang.String password) throws java.sql.SQLException
getXAConnection
in interface javax.sql.XADataSource
userName
- the database user on whose behalf the XAConnection is being madepassword
- the user's password
java.sql.SQLException
- if a database-access error occursXADataSource.getXAConnection(java.lang.String, java.lang.String)
public javax.sql.PooledConnection getPooledConnection() throws java.sql.SQLException
getPooledConnection
in interface javax.sql.ConnectionPoolDataSource
java.sql.SQLException
public javax.sql.PooledConnection getPooledConnection(java.lang.String userName, java.lang.String password) throws java.sql.SQLException
getPooledConnection
in interface javax.sql.ConnectionPoolDataSource
java.sql.SQLException
public java.lang.String getDisableLocalTxn()
public void setDisableLocalTxn(java.lang.String disableLocalTxn)
public java.io.PrintWriter getLogWriter() throws java.sql.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 javax.sql.CommonDataSource
java.sql.SQLException
- if a database-access error occursCommonDataSource.getLogWriter()
public int getLoginTimeout() throws java.sql.SQLException
getLoginTimeout
in interface javax.sql.CommonDataSource
java.sql.SQLException
- if a database-access error occursCommonDataSource.getLoginTimeout()
public void setLogWriter(java.io.PrintWriter writer) throws java.sql.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 javax.sql.CommonDataSource
writer
- the log writer for this data source, null if disabled
java.sql.SQLException
- if a database-access error occursCommonDataSource.setLogWriter(java.io.PrintWriter)
public void setLoginTimeout(int timeOut) throws java.sql.SQLException
setLoginTimeout
in interface javax.sql.CommonDataSource
timeOut
- the data source login time limit
java.sql.SQLException
- if a database-access error occursCommonDataSource.setLoginTimeout(int)
public java.lang.String getApplicationName()
public java.lang.String getDatabaseName()
public java.lang.String getDatabaseVersion()
public java.lang.String getDataSourceName()
XADataSource
or
ConnectionPoolDataSource
;
used only when pooling connections or distributed transactions are implemented.
public java.lang.String getDescription()
public java.lang.String getUser()
public java.lang.String getPassword()
public java.io.Serializable getClientToken()
Serializable
client token that will be passed directly
through to the connectors, which may use it and/or pass it down to their underlying data source.
This property is optional.
The form and type of the client token is up to the client but it must implement the
Serializabe
interface. MetaMatrix does nothing with this token except to make it
available for authentication/augmentation/replacement upon authentication to the system and to
connectors that may require it at the data source level.
null
.public void setApplicationName(java.lang.String applicationName)
applicationName
- The applicationName to setpublic void setDatabaseName(java.lang.String databaseName)
databaseName
- The name of the virtual databasepublic void setDatabaseVersion(java.lang.String databaseVersion)
databaseVersion
- The version of the virtual databasepublic void setDataSourceName(java.lang.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(java.lang.String user)
user
- The user to setpublic void setPassword(java.lang.String password)
password
- The password for this data sourcepublic void setClientToken(java.io.Serializable clientToken)
Serializable
client token that will be passed directly
through to the connectors, which may use it and/or pass it down to their underlying data source.
This property is optional.
The form and type of the client token is up to the client but it must implement the
Serializabe
interface. MetaMatrix does nothing with this token except to make it
available for authentication/augmentation/replacement upon authentication to the system and to
connectors that may require it at the data source level.
clientToken
- The client token that will be passed with this user's requests.public void setDescription(java.lang.String description)
description
- The description for this data source; may be nullpublic void setPartialResultsMode(java.lang.String partialResultsMode)
public java.lang.String getPartialResultsMode()
public void setFetchSize(int fetchSize)
public int getFetchSize()
public void setResultSetCacheMode(java.lang.String resultSetCacheMode)
public java.lang.String getResultSetCacheMode()
public java.lang.String getSqlOptions()
public void setSqlOptions(java.lang.String sqlOptions)
sqlOptions
- SQL options, only "SHOWPLAN" is currently acceptedpublic java.lang.String getTransactionAutoWrap()
public void setTransactionAutoWrap(java.lang.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_AUTO_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_AUTO_WRAP_ON
constant value is provided for convenience.PESSIMISTIC
" - Assume that any command might require a transaction. Make a server
call to check whether the command being executed needs a transaction and wrap the command in a
transaction if necessary. This will auto wrap in exactly the cases where it is needed but requires
an extra server call on every command execution (including queries). This is as safe as ON, but
lower performance than OFF for cases where no transaction is actually needed (like queries).
The TXN_AUTO_WRAP_PESSIMISTIC
constant value is provided for convenience.OPTIMISTIC
" - same as OFF but assume that no command not in a transaction actually
needs one. In other words, we're letting the user decide when to use and not use a transaction and
assuming they are doing it correctly. Only difference from OFF is that if the user executes a command
that requires a transaction but they don't use one, we will detect this and throw an exception. This
provides the safety of ON or PESSIMISTIC mode but better performance in the common case of queries
that are not multi-source.
The TXN_AUTO_WRAP_OPTIMISTIC
constant value is provided for convenience.This property is important only if connecting to a MetaMatrix XA Server.
transactionAutoWrap
- The transactionAutoWrap to setpublic static java.lang.String reasonWhyInvalidApplicationName(java.lang.String applicationName)
applicationName
- a possible value for the property
setApplicationName(String)
public static java.lang.String reasonWhyInvalidClientToken(java.io.Serializable clientToken)
clientToken
- a possible value for the property
setClientToken(Serializable)
public static java.lang.String reasonWhyInvalidDatabaseName(java.lang.String databaseName)
databaseName
- a possible value for the property
setDatabaseName(String)
public static java.lang.String reasonWhyInvalidUser(java.lang.String userName)
userName
- a possible value for the property
setUser(String)
public static java.lang.String reasonWhyInvalidTransactionAutoWrap(java.lang.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 java.lang.String reasonWhyInvalidDatabaseVersion(java.lang.String databaseVersion)
databaseVersion
- a possible value for the property
setDatabaseVersion(String)
public static java.lang.String reasonWhyInvalidDataSourceName(java.lang.String dataSourceName)
dataSourceName
- a possible value for the property
setDataSourceName(String)
public static java.lang.String reasonWhyInvalidPassword(java.lang.String pwd)
pwd
- a possible value for the property
setPassword(String)
public static java.lang.String reasonWhyInvalidDescription(java.lang.String description)
description
- a possible value for the property
setDescription(String)
public static java.lang.String reasonWhyInvalidPartialResultsMode(java.lang.String partialMode)
partialMode
- boolean flag
public static java.lang.String reasonWhyInvalidFetchSize(int fetchSize)
fetchSize
- Number of rows per batch
public void setAdditionalProperties(java.lang.String additionalProperties)
public java.lang.String getAdditionalProperties()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |