|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jnetdirect.datasource.BaseDatasource
public class BaseDatasource
A Datasource is a factory for connections to a physical data source.
Since JDBC 2.0 a DataSource object is the preferred means of creating a database
connection. An object that implements the DataSource interface will typically be registered
with a naming service based on the JavaTM Naming and Directory (JNDI) API. It will be
instantiated in the application code via a JNDI lookup.
Data source properties are set and retrieved using the setXXX() and getXXX() methods. This
API reference documents properties specific to this datasource. For frequently used properties
common to all datasources (such as serverName, databaseName etc) please see the documentation for
the super class BaseDatasource.
A plain datasource does not implement connection pooling directly. If connection
pooling is required there are two cases:-
Managed Environment - If the application runs in a managed environment that
already supports integrated connection pooling (EG an application server) then you should
use that built in connection pooling implemenation. The application server will
typically only require a third party vendor's datasource to create physical connections for its
connection pool. Check the application server documentation
to determine what type of datasource is required to create the physical connections.
This datasource is a javax.sql.DataSource object.
No Managed Environment - If your application does not run in a managed environment and
require connection pooling do not use this
datasource. Use the pooling datasource instead. Your application code requires no changes
and the pooling datasource will perform connection pooling automatically.
Please Note:The BaseDatasource implements frequently used properties common to all
datasources. However you should not instantiate this datasource directly but always instantiate
a datasource specific to the driver you are using. The driver specific datasource provides
additional properties available only for that driver.
Please see the API documentation for the driver specific datasource in use
for a list of all driver specifc properties.
Field Summary | |
---|---|
static boolean |
debugLog
|
Method Summary | |
---|---|
java.sql.Connection |
getConnection()
Obtain a database connection using the datasource user and password properties. |
java.sql.Connection |
getConnection(java.lang.String username,
java.lang.String password)
Obtain a database connection using the supplied user and password properties. |
java.lang.String |
getConnectionVerifyTable()
Get the verify table. |
java.lang.String |
getDatabase()
Deprecated. - Use getDatabaseName. |
java.lang.String |
getDatabaseName()
Get the database name for the datasource. |
java.lang.String |
getDescription()
Get the description of the datasource. |
int |
getInitialPoolSize()
Get the initial pool size. |
java.lang.String |
getLogfile()
Retrieves the log file for this DataSource. |
int |
getLoginTimeout()
Gets the maximum time that the data source will wait while attempting to connect to a database. |
java.io.PrintWriter |
getLogWriter()
Retrieves the log writer for this DataSource. |
int |
getManagementCycleTime()
Deprecated. - use getPropertyCycle() |
java.lang.String |
getMaxConnectionBacklog()
Get the connection retry wait time. |
int |
getMaxIdleTime()
Get the maximum idle time. |
int |
getMaxPoolSize()
Get the maximum number of connections allowed in the connection pool. |
int |
getMinPoolSize()
Get the minimum number of connections allowed in the connection pool. |
java.lang.String |
getPassword()
Get the password for this datasource. |
int |
getPortNumber()
Get the port number for the connection |
java.util.Properties |
getProperties()
Get property values for the datasource. |
int |
getPropertyCycle()
Get the property cycle interval for the datasource. |
javax.naming.Reference |
getReference()
|
java.lang.String |
getServerName()
Get the server name for the datasource. |
java.lang.String |
getUrl()
Get the url for the datasource. |
java.lang.String |
getURL()
Synonymous with getUrl(); |
java.lang.String |
getUser()
Get the user name for this datasource. |
void |
setConnectionVerifyTable(java.lang.String table)
Set the connection verification table. |
void |
setDatabase(java.lang.String databaseName)
changed to use setDatabaseName. |
void |
setDatabaseName(java.lang.String databaseName)
Set the database name for the datasource. |
void |
setDescription(java.lang.String description)
Set the description of the datasource. |
void |
setInitialPoolSize(int size)
Set the initial pool size of the connection pool. |
void |
setLogfile(java.lang.String file)
Sets the log file for this DataSource. |
void |
setLoginTimeout(int seconds)
Sets the maximum time the data source will wait while attempting to connect to a database. |
void |
setLogWriter(java.io.PrintWriter out)
Sets the log writer for this DataSource. |
void |
setManagementCycleTime(int seconds)
changed to use the setPropertyCycle() |
void |
setMaxConnectionBacklog(java.lang.String number)
|
void |
setMaxIdleTime(int seconds)
Set the maximum idle time that controls when idle connections are removed from the pool. |
void |
setMaxPoolSize(int maxConnections)
Set the maximum number of connections allowed in the connection pool. |
void |
setMinPoolSize(int minSize)
Set the minimum number of connections required in the connection pool. |
void |
setPassword(java.lang.String password)
Set the password for the connection. |
void |
setPortNumber(int portNumber)
Set the port number for the connection |
void |
setProperties(java.util.Properties properties)
Set property values from a set of properties. |
void |
setProperty(java.lang.String propertyName,
java.lang.String propertyValue)
Set the value of any datasource property. |
void |
setPropertyCycle(int seconds)
Sets the interval that the pool should wait before enforcing the current policy defined by the values of connection pool properties. |
void |
setServerName(java.lang.String serverName)
Set the server name for the machine running the database |
void |
setUrl(java.lang.String url)
Set property values from a driver URL. |
void |
setURL(java.lang.String url)
Synonymous with setUrl(); |
void |
setUser(java.lang.String user)
Set the user name for the connection. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final boolean debugLog
Method Detail |
---|
public java.sql.Connection getConnection() throws java.sql.SQLException
java.sql.SQLException
- The database connection failed.public java.sql.Connection getConnection(java.lang.String username, java.lang.String password) throws java.sql.SQLException
username
- The user name for the connectionpassword
- The password for the connection
java.sql.SQLException
- The database connection failed.public void setProperty(java.lang.String propertyName, java.lang.String propertyValue)
propertyName
- The property name, must be a valid property name for the driverpropertyValue
- The property valuepublic void setProperties(java.util.Properties properties)
properties
- The property name-value pairspublic void setUrl(java.lang.String url)
url
- Any legal URL for the underlying driver.public java.lang.String getUrl()
public void setURL(java.lang.String url)
public java.lang.String getURL()
public java.util.Properties getProperties()
public void setServerName(java.lang.String serverName)
serverName
- The name (or IP address) of the machine running the database to connect to. Used 'localhost' (or 127.0.0.1) for the local machinepublic java.lang.String getServerName()
public void setPortNumber(int portNumber)
portNumber
- The port number for the connection.
The port number only needs to be set if you have changed the default configuration
to use a port number other than the driver's default.public int getPortNumber()
portNumber
- The port number for the connection.
The port number only needs to be set if you have changed the default configuration
to use a port number other than the driver's default.public void setDatabaseName(java.lang.String databaseName)
databaseName
- The name of the database, catalog or other configured datasource for the connectionpublic java.lang.String getDatabaseName()
public void setDatabase(java.lang.String databaseName)
public java.lang.String getDatabase()
public void setUser(java.lang.String user)
userName
- The user name for authentication.public java.lang.String getUser()
public void setPassword(java.lang.String password)
password
- The user name for authentication.public java.lang.String getPassword()
public void setDescription(java.lang.String description)
description
- The description.public java.lang.String getDescription()
public void setLoginTimeout(int seconds)
seconds
- The maximum time in seconds. Zero means no maximum is set.public int getLoginTimeout()
public void setLogWriter(java.io.PrintWriter out)
out
- The given java.io.PrintWriter object.public java.io.PrintWriter getLogWriter()
public void setLogfile(java.lang.String file)
file
- The file name and path for the JDBC log file.public java.lang.String getLogfile()
public void setMaxPoolSize(int maxConnections)
maxConnections
- The maximum number. Zero means no maximum and is the default.public int getMaxPoolSize()
public void setMinPoolSize(int minSize)
minConnections
- The minimum number. Zero means no minimum and is the default.public int getMinPoolSize()
public void setMaxIdleTime(int seconds)
seconds
- The idle time in seconds. Zero means no maximum and is the default.public int getMaxIdleTime()
public void setInitialPoolSize(int size)
size
- The initial number of connections. Zero means no connections are created.public int getInitialPoolSize()
public void setPropertyCycle(int seconds)
seconds
- The time in secondspublic int getPropertyCycle()
public void setManagementCycleTime(int seconds)
public int getManagementCycleTime()
public void setConnectionVerifyTable(java.lang.String table)
public java.lang.String getConnectionVerifyTable()
public void setMaxConnectionBacklog(java.lang.String number)
public java.lang.String getMaxConnectionBacklog()
public javax.naming.Reference getReference()
getReference
in interface javax.naming.Referenceable
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |