org.apache.commons.configuration
public class DatabaseConfiguration extends AbstractConfiguration
Since: 1.0
Version: $Revision: 514234 $, $Date: 2007-03-03 21:18:14 +0100 (Sa, 03 Mrz 2007) $
Field Summary | |
---|---|
DataSource | datasource The datasource to connect to the database. |
String | keyColumn The column containing the keys. |
String | name The name of the configuration. |
String | nameColumn The column containing the name of the configuration. |
String | table The name of the table containing the configurations. |
String | valueColumn The column containing the values. |
Constructor Summary | |
---|---|
DatabaseConfiguration(DataSource datasource, String table, String nameColumn, String keyColumn, String valueColumn, String name)
Build a configuration from a table containing multiple configurations.
| |
DatabaseConfiguration(DataSource datasource, String table, String keyColumn, String valueColumn)
Build a configuration from a table.-
|
Method Summary | |
---|---|
void | addProperty(String key, Object value)
Adds a property to this configuration. |
protected void | addPropertyDirect(String key, Object obj)
Adds a property to this configuration. |
void | clear()
Removes all entries from this configuration. |
void | clearProperty(String key)
Removes the specified value from this configuration. |
void | closeQuietly(Connection conn, Statement stmt)
Close a Connection and, Statement .
|
boolean | containsKey(String key)
Checks whether this configuration contains the specified key. |
protected Connection | getConnection()
Returns a Connection object. |
DataSource | getDatasource()
Returns the used DataSource object.
|
Iterator | getKeys()
Returns an iterator with the names of all properties contained in this
configuration. |
Object | getProperty(String key)
Returns the value of the specified property. |
boolean | isEmpty()
Checks if this configuration is empty. |
Parameters: datasource the datasource to connect to the database table the name of the table containing the configurations nameColumn the column containing the name of the configuration keyColumn the column containing the keys of the configuration valueColumn the column containing the values of the configuration name the name of the configuration
Parameters: datasource the datasource to connect to the database table the name of the table containing the configurations keyColumn the column containing the keys of the configuration valueColumn the column containing the values of the configuration
getProperty()
will take care about delimiters. So list delimiters are fully supported
by DatabaseConfiguration
, but internally treated a bit
differently.
Parameters: key the key of the new property value the value to be added
EVENT_ADD_PROPERTY
with the causing exception. The event's propertyName
is
set to the passed in property key, the propertyValue
points to the passed in value.
Parameters: key the property key obj the value of the property to add
EVENT_CLEAR
with the causing exception. Both the
event's propertyName
and the propertyValue
will be undefined.EVENT_CLEAR_PROPERTY
with the causing exception. The
event's propertyName
will be set to the passed in key, the
propertyValue
will be undefined.
Parameters: key the key of the property to be removed
Connection
and, Statement
.
Avoid closing if null and hide any SQLExceptions that occur.
Parameters: conn The database connection to close stmt The statement to close
EVENT_READ_PROPERTY
with the causing exception. The
event's propertyName
will be set to the passed in key, the
propertyValue
will be undefined.
Parameters: key the key to be checked
Returns: a flag whether this key is defined
Connection
object. This method is called when
ever the database is to be accessed. This implementation returns a
connection from the current DataSource
.
Returns: the Connection
object to be used
Throws: SQLException if an error occurs
Since: 1.4
DataSource
object.
Returns: the data source
Since: 1.4
EVENT_READ_PROPERTY
with the causing exception. Both the
event's propertyName
and the propertyValue
will be undefined.Returns: an iterator with the contained keys (an empty iterator in case of an error)
EVENT_READ_PROPERTY
with the causing exception. The
event's propertyName
is set to the passed in property key,
the propertyValue
is undefined.
Parameters: key the key of the desired property
Returns: the value of this property
EVENT_READ_PROPERTY
with the causing exception. Both the event's propertyName
and propertyValue
will be undefined.
Returns: a flag whether this configuration is empty.