|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.iplanet.jato.SQLConnectionManagerBase
A base implementation of the SQLConnectionManager
interface.
This implementation goes beyond that specified by the SQLConnectionManager
interface to provide static methods that can be used outside the
scope of a request. This is helpful for initialization of certain JATO objects.
Developers need not create any instances of this class. A single instance is automatically created at the beginning of the request and stored in the request context.
This class supports two alternative, mutually exclusive policies for obtaining
connection objects. The preferred policy is to use JNDI lookups as specified by
the JDBC 2.0 Standard Extension to obtain connections. The other less prefered
policy is to obtain connections directly from the JDBC DriverManager
using datasource to JDBC URL mappings. This policy may be very useful during
development, but once an application is running in a properly configured J2EE
container, the JNDI policy should always be used for performance reasons.
The actual mapping of datasource names to their respective connection strings
can only be done at the application level. Therefore, this class is designed
to be the base class implementation for an application-specific
SQLConnectionManagerImpl
class.
Constructor Summary | |
SQLConnectionManagerBase()
Default constructor |
Method Summary | |
static void |
addDataSourceMapping(java.lang.String dataSourceName,
java.lang.String mappedValue)
Adds a datasource name mapping. |
java.sql.Connection |
getConnection(java.lang.String dataSource)
Return a JDBC Connection for the specified datasource. |
java.sql.Connection |
getConnection(java.lang.String dataSource,
java.lang.String user,
java.lang.String password)
Return a JDBC Connection from the specified datasource
with the provided user and password. |
protected static java.lang.String |
getMappedDataSourceName(java.lang.String dataSourceName)
Returns the mapped value for a datasource name, if any |
static boolean |
isUsingJNDI()
Return whether or not the JNDI lookup is the current connection retreival policy |
static java.sql.Connection |
obtainConnection(java.lang.String dataSource)
Return a JDBC Connection for the specified datasource. |
static java.sql.Connection |
obtainConnection(java.lang.String dataSource,
java.lang.String user,
java.lang.String password)
Return a JDBC Connection for the specified datasource. |
static void |
setUsingJNDI(boolean value)
Set whether or not the JNDI lookup is the current connection retreival policy |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SQLConnectionManagerBase()
Method Detail |
public java.sql.Connection getConnection(java.lang.String dataSource) throws java.sql.SQLException
Connection
for the specified datasource.
This method will attempt to map the provided datasource name to
the actual datasource name using the existing datasource mappings.
If a mapping doesn't exist for the provided name, the name will be
used to obtain a connection.getConnection
in interface SQLConnectionManager
com.iplanet.jato.SQLConnectionManager
dataSource
- The desired datasource name. This parameter may either be the
actual JNDI lookup string or an arbitrary logical name.java.sql.SQLException
- Thrown if there is a problem getting a connectionpublic java.sql.Connection getConnection(java.lang.String dataSource, java.lang.String user, java.lang.String password) throws java.sql.SQLException
Connection
from the specified datasource
with the provided user and password. This method will attempt to map
the provided datasource name to the actual datasource name using the
existing datasource mappings. If a mapping doesn't exist for the
provided name, the name will be used to obtain a connection.getConnection
in interface SQLConnectionManager
com.iplanet.jato.SQLConnectionManager
dataSource
- The desired datasource name. This parameter may either be the
actual JNDI lookup string or an arbitrary logical name.user
- The user ID for the desired connectionpassword
- The password for the desired connectionjava.sql.SQLException
- Thrown if there is a problem getting a connectionpublic static java.sql.Connection obtainConnection(java.lang.String dataSource) throws java.sql.SQLException
Connection
for the specified datasource.
This method is comparable to the non-static getConnection(
String dataSource)
method.
This static method provides a way to obtain a JDBC connection outside
the scope of a request. This is useful for objects that retrieve data
outside the scope of a request, for example during static initialization.
Objects within the scope of a request should use the non-static method
equivalent.dataSource
- The desired datasource name. This parameter may either be the
actual JNDI lookup string or an arbitrary logical name.java.sql.SQLException
- Thrown if there is a problem getting a connectionpublic static java.sql.Connection obtainConnection(java.lang.String dataSource, java.lang.String user, java.lang.String password) throws java.sql.SQLException
Connection
for the specified datasource.
This method is comparable to the non-static getConnection(
String dataSource, String user, String password)
method.
This static method provides a way to obtain a JDBC connection outside
the scope of a request. This is useful for objects that retrieve data
outside the scope of a request, for example during static initialization.
Objects within the scope of a request should use the non-static method
equivalent.dataSource
- The desired datasource name. This parameter may either be the
actual JNDI lookup string or an arbitrary logical name.user
- The user ID for the desired connectionpassword
- The password for the desired connectionjava.sql.SQLException
- Thrown if there is a problem getting a connectionpublic static void addDataSourceMapping(java.lang.String dataSourceName, java.lang.String mappedValue)
dataSourceName
- The desired datasource name. This parameter may either be the
actual JNDI lookup string or an arbitrary logical name.value
- This value can be a JNDI datasource name or a JDBC URL. The
appropriate value depends on the current policy for obtaining
connections.protected static java.lang.String getMappedDataSourceName(java.lang.String dataSourceName)
dataSourceName
- The desired datasource name. This parameter may either be the
actual JNDI lookup string or an arbitrary logical name.null
if one does not existpublic static boolean isUsingJNDI()
public static void setUsingJNDI(boolean value)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |