public class SqlResources extends Object
Constructor and Description |
---|
SqlResources() |
Modifier and Type | Method and Description |
---|---|
String |
getDbOption(String name)
Returns the dbOption string value set for the specified dbOption name.
|
String |
getSqlString(String name)
Returns a named SQL string for the specified connection, replacing
parameters with the values set.
|
String |
getSqlString(String name,
boolean required)
Returns a named SQL string for the specified connection, replacing
parameters with the values set.
|
protected void |
init(Document sqlDoc,
String sqlDefsSection,
Connection conn,
Map<String,String> configParameters)
Configures a SqlResources object from an xml document.
|
void |
init(File sqlFile,
String sqlDefsSection,
Connection conn,
Map<String,String> configParameters)
Configures a DbResources object to provide SQL statements from a file.
|
void |
init(InputStream input,
String sqlDefsSection,
Connection conn,
Map<String,String> configParameters)
Configures a DbResources object to provide SQL statements from an
InputStream.
|
public void init(File sqlFile, String sqlDefsSection, Connection conn, Map<String,String> configParameters) throws Exception
Configures a DbResources object to provide SQL statements from a file.
SQL statements returned may be specific to the particular type and version of the connected database, as well as the database driver.
Parameters encoded as $(parameter} in the input file are replace by values from the parameters Map, if the named parameter exists. Parameter values may also be specified in the resourceSection element.
sqlFile
- the input file containing the string definitionssqlDefsSection
- the xml element containing the strings to be usedconn
- the Jdbc DatabaseMetaData, taken from a database connectionconfigParameters
- a map of parameters (name-value string pairs) which are
replaced where found in the input stringsException
public void init(InputStream input, String sqlDefsSection, Connection conn, Map<String,String> configParameters) throws Exception
Configures a DbResources object to provide SQL statements from an InputStream.
SQL statements returned may be specific to the particular type and version of the connected database, as well as the database driver.
Parameters encoded as $(parameter} in the input file are replace by values from the parameters Map, if the named parameter exists. Parameter values may also be specified in the resourceSection element.
input
- the input stream containing the xmlsqlDefsSection
- the xml element containing the strings to be usedconn
- the Jdbc DatabaseMetaData, taken from a database connectionconfigParameters
- a map of parameters (name-value string pairs) which are
replaced where found in the input stringsException
protected void init(Document sqlDoc, String sqlDefsSection, Connection conn, Map<String,String> configParameters) throws SQLException
sqlDoc
- sqlDefsSection
- conn
- configParameters
- SQLException
public String getSqlString(String name)
name
- the name of the SQL resource required.public String getSqlString(String name, boolean required)
name
- the name of the SQL resource required.required
- true if the resource is requiredRuntimeException
- if a required resource cannot be found.Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.