public interface DatabaseResourceBundle
java.util.ResourceBundle
in form
and function, but is designed to supply SQL language translations
rather than spoken language translations.
Like java.util.PropertyResourceBundle
, DatabaseResourceBundle
resources are specified in Properties
files. Unlike
PropertyResourceBundle
, DatabaseResourceBundle
uses the
EProperties
enhanced Properties package, which extends the standard
java.util.Properties
and syntax to include things like:
variable substitution, nesting, inclusion and lists.
For instance:
table.name = connector_instances getvalue.query = "SELECT ${column.connector.name} FROM ${table.name} ..."Variables may be defined in the
DatabaseResourceBundle
in which they
are used, or any of the ancestor DatabaseResourceBundles
(see below).
Variable substitution is done at the time of the call to
getString(String)
or getStringArray(String)
, so the
returned string(s) have all known substitutions resolved.create.table.ddl = ( "CREATE TABLE ...", "CREATE TRIGGER ...", "CREATE INDEX ..." )which can be retrieved using
getStringArray(String)
:
String[] ddlStatements = bundle.getStringArray("create.table.ddl");
These features allow the connector developer to write very powerful resource property files.
Connectors must locate the DatabaseResourceBundle property files in their
config
package. The properties files have a base name derived from
the ConnectorType name (with any instances of '.' replaced with '_')
concatenated with "_sql".
Vendor-specific SQL syntax variations are formed by adding the
product name, major and minor versions to the base name. So resource
property file names would look like:
<ConnectorTypeName>_sql[_productName][_majorVersion][_minorVersion].propertiesFor instance, suppose the ConnectorType name as defined in
connectorType.xml
is "File.List", and the configured JDBC
DataSource
is MySQL v5.1. The Connector Manager will attempt to
load DatabaseResourceBundles
from the following resources:
File_List_sql_mysql.properties
may refer to a property defined in File_List_sql.properties
,
but not one defined in File_List_sql_mysql_5_1.properties
.Modifier and Type | Method and Description |
---|---|
java.lang.String |
getString(java.lang.String key)
Gets a resource that is specific to the active database implementation.
|
java.lang.String[] |
getStringArray(java.lang.String key)
The same comments apply as {
getString(String) , only this
API corresponds to ResourceBundle.getStringArray(String) . |
java.lang.String getString(java.lang.String key)
ResourceBundle.getString(String)
and is
intended to be used in a similar way. That is, it may return a String
(typically, SQL) into which parameter substitution may be done using
Format.format(Object)
, JDBC PreparedStatement
and similar techniques.
The implementation will assure that the correct resource is returned for this connector type and for the active database implementation.
If there is no resource defined for this key, null
is returned
(unlike ResourceBundle.getString(String)
, which throws an
exception).
key
- as ResourceBundle.getString(String)
ResourceBundle.getString(String)
java.lang.String[] getStringArray(java.lang.String key)
getString(String)
, only this
API corresponds to ResourceBundle.getStringArray(String)
.
If there is no resource defined for this key, an array of length zero is
returned (unlike ResourceBundle.getString(String)
, which throws an
exception).
key
- as ResourceBundle.getStringArray(String)
ResourceBundle.getStringArray(String)