|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.uwyn.rife.database.Datasource
public class Datasource
Contains all the information required to connect to a database and centralizes the creation of connections to a database. These connections can optionally be pooled.
The initial connection will only be made and the pool will only be initialized when a connection is obtained for the first time. The instantiation only stores the connection parameters.
A Datasource also defines the type of database that is used for
all database-independent logic such as sql to java and java to sql type
mappings, query builders, database-based authentication, database-based
scheduling, ... The key that identifies a supported type is the class name of
the jdbc driver.
A Datasource instance can be created through it's constructor,
but it's recommended to work with a Datasources collection
that is created and populated through XML. This can easily be achieved by
using a ParticipantDatasources which participates in the
application-wide repository.
Once a connection has been obtained from a pooled datasource, modifying its connection parameters is not possible anymore, a new instance has to be created to set the parameters to different values.
Datasources,
Xml2Datasources,
Rep,
ParticipantDatasources| Constructor Summary | |
|---|---|
Datasource()
Instantiates a new Datasource object with no connection
information. |
|
Datasource(DataSource dataSource,
int poolsize)
Instantiates a new Datasource object from a standard
javax.sql.DataSource. |
|
Datasource(DataSource dataSource,
String driver,
String user,
String password,
int poolsize)
Instantiates a new Datasource object from a standard
javax.sql.DataSource. |
|
Datasource(String driver,
String url,
String user,
String password,
int poolsize)
Instantiates a new Datasource object with all the
connection parameters that are required. |
|
| Method Summary | |
|---|---|
void |
cleanup()
Cleans up all connections that have been reserved by this datasource. |
Datasource |
clone()
Simply clones the instance with the default clone method. |
boolean |
equals(Object object)
Indicates whether some other object is "equal to" this one. |
String |
getAliasedDriver()
Retrieves the fully qualified class name of the jdbc driver that's used by this Datasource. |
com.uwyn.rife.database.capabilities.CapabilitiesCompensator |
getCapabilitiesCompensator()
Retrieves a CapabilitiesCompensator instance that is able to
compensate for certain missing database features |
DbConnection |
getConnection()
Retrieves a free database connection. |
DataSource |
getDataSource()
Retrieves the standard datasource that is used by this RIFE datasource to obtain a database connection. |
String |
getDriver()
Retrieves the fully qualified class name of the jdbc driver that's used by this Datasource. |
String |
getPassword()
Retrieves the password that's used by this Datasource. |
ConnectionPool |
getPool()
Retrieves the instance of the connection pool that is provided by this dtaasource. |
int |
getPoolsize()
Retrieves the size of the pool that's used by this Datasource. |
SqlConversion |
getSqlConversion()
Retrieves the sql to java and java to sql type mapping logic that corresponds to the provide driver class name. |
String |
getUrl()
Retrieves the connection url that's used by this Datasource. |
String |
getUser()
Retrieves the user that's used by this Datasource. |
int |
hashCode()
Returns a hash code value for the Datasource. |
boolean |
isPooled()
Indicates whether the Datasource uses a connection pool or
not |
void |
setDataSource(DataSource dataSource)
Sets the standard datasource that will be used to connect to the database. |
void |
setDriver(String driver)
Sets the jdbc driver that will be used to connect to the database. |
void |
setPassword(String password)
Sets the password that will be used to connect to the database. |
void |
setPoolsize(int poolsize)
Sets the size of the connection pool that will be used to connect to the database. |
void |
setUrl(String url)
Sets the connection url that will be used to connect to the database. |
void |
setUser(String user)
Sets the user that will be used to connect to the database. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Datasource()
Datasource object with no connection
information. The setters need to be used afterwards to provide each
required parameter before the Datasource can be used.
setDriver(String),
setUrl(String),
setUser(String),
setPassword(String),
setPoolsize(int),
setDataSource(DataSource)
public Datasource(String driver,
String url,
String user,
String password,
int poolsize)
Datasource object with all the
connection parameters that are required.
driver - the fully-qualified classname of the jdbc driver that will
be used to connect to the databaseurl - the connection url which identifies the database to which the
connection will be made, this is entirely driver-dependentuser - the user that will be used to connect to the databasepassword - the password that will be used to connect to the databasepoolsize - the size of the connection pool, 0 means
that the connections will not be pooled
public Datasource(DataSource dataSource,
int poolsize)
Datasource object from a standard
javax.sql.DataSource.
The driver will be detected from the connection that is provided by this
DataSource. If the driver couldn't be detected, an exception
will be thrown upon connect.
dataSource - the standard datasource that will be used to obtain the
connectionpoolsize - the size of the connection pool, 0 means
that the connections will not be pooled
public Datasource(DataSource dataSource,
String driver,
String user,
String password,
int poolsize)
Datasource object from a standard
javax.sql.DataSource.
dataSource - the standard datasource that will be used to obtain the
connectiondriver - the fully-qualified classname of the jdbc driver that will
be used to provide an identifier for the database abstraction functionalities,
null will let RIFE try to figure it out by itselfuser - the user that will be used to connect to the databasepassword - the password that will be used to connect to the databasepoolsize - the size of the connection pool, 0 means
that the connections will not be pooled| Method Detail |
|---|
public DbConnection getConnection()
throws DatabaseException
DbConnection will always be created, otherwise the first
available connection in the pool will be returned.
DbConnection instance which can be used to
create an execute statements
DatabaseException - when errors occured during the creation of a
new connection or during the obtainance of a connection from the poolpublic String getDriver()
Datasource.
String with the name of the jdbc driver; or
null if the driver hasn't been set
setDriver(String),
getAliasedDriver()public String getAliasedDriver()
Datasource. Instead of straight retrieval of the
internal value, it looks for jdbc driver aliases and changes the driver
classname if it's not supported by RIFE, but its alias is.
String with the name of the jdbc driver; or
null if the driver hasn't been set
getDriver(),
setDriver(String)public void setDriver(String driver)
If the class name can't be resolved, an exception is thrown during the creation of the first connection.
driver - a String with the fully qualified class name
of the jdbc driver that will be usedgetDriver()public DataSource getDataSource()
DataSource; or
null if the standard datasource hasn't been set
setDataSource(DataSource)public void setDataSource(DataSource dataSource)
dataSource - a standard DataSource that will be used
by this RIFE datasource to obtain a database connection.getDataSource()public String getUrl()
Datasource.
String with the connection url; or
null if the url hasn't been set
setUrl(String)public void setUrl(String url)
url - a String with the connection url that will be
usedgetUrl()public String getUser()
Datasource.
String>/code> with the user; or
null if the user hasn't been set
- Since:
- 1.0
- See Also:
setUser(String)public void setUser(String user)
user - a String with the user that will be usedgetUser()public String getPassword()
Datasource.
String>/code> with the password; or
null if the password hasn't been set
- Since:
- 1.0
- See Also:
setPassword(String)public void setPassword(String password)
password - a String with the password that will be usedgetPassword()public int getPoolsize()
Datasource.
int with the size of the pool; or
0 if no pool is being used
isPooled(),
setPoolsize(int)public boolean isPooled()
Datasource uses a connection pool or
not
true if a pool is being used by this
Datasource; or
false otherwise
getPoolsize(),
setPoolsize(int)public void setPoolsize(int poolsize)
poolsize - a positive int with the size of the pool,
providing 0 will disable the use of a connection pool for
this Datasource.getPoolsize(),
isPooled()
public SqlConversion getSqlConversion()
throws UnsupportedJdbcDriverException
SqlConversion instance that is able to perform
the required type conversions for the provided jdbc driver
UnsupportedJdbcDriverException - when the provided jdbc isn't
supported
public com.uwyn.rife.database.capabilities.CapabilitiesCompensator getCapabilitiesCompensator()
throws UnsupportedJdbcDriverException
CapabilitiesCompensator instance that is able to
compensate for certain missing database features
CapabilitiesCompensator instance
UnsupportedJdbcDriverException - when the provided jdbc isn't
supportedpublic int hashCode()
Datasource. This method is
supported for the benefit of hashtables such as those provided by
java.util.Hashtable.
hashCode in class Objectint with the hash code value for this
Datasource.equals(Object)public boolean equals(Object object)
equals in class Objectobject - the reference object with which to compare.
true if this object is the same as the object
argument; or
false otherwise
hashCode()public Datasource clone()
clone in class Object
public void cleanup()
throws DatabaseException
DatabaseException - when an error occured during the cleanuppublic ConnectionPool getPool()
ConnectionPool
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||