org.apache.james.util
Class SqlResources
java.lang.Object
|
+--org.apache.james.util.SqlResources
- public class SqlResources
- extends java.lang.Object
Provides a set of SQL String resources (eg SQL Strings)
to use for a database connection.
This class allows SQL strings to be customised to particular
database products, by detecting product information from the
jdbc DatabaseMetaData object.
- Author:
- Darrell DeBoer
Method Summary |
java.lang.String |
getSqlString(java.lang.String name)
Returns a named SQL string for the specified connection,
replacing parameters with the values set. |
java.lang.String |
getSqlString(java.lang.String name,
boolean required)
Returns a named SQL string for the specified connection,
replacing parameters with the values set. |
void |
init(java.io.File sqlFile,
java.lang.String sqlDefsSection,
java.sql.Connection conn,
java.util.Map configParameters)
Configures a DbResources object to provide SQL statements from a file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SqlResources
public SqlResources()
init
public void init(java.io.File sqlFile,
java.lang.String sqlDefsSection,
java.sql.Connection conn,
java.util.Map configParameters)
throws java.lang.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.
- Parameters:
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 strings
getSqlString
public java.lang.String getSqlString(java.lang.String name)
- Returns a named SQL string for the specified connection,
replacing parameters with the values set.
- Parameters:
name
- the name of the SQL resource required.- Returns:
- the requested resource
getSqlString
public java.lang.String getSqlString(java.lang.String name,
boolean required)
- Returns a named SQL string for the specified connection,
replacing parameters with the values set.
- Parameters:
name
- the name of the SQL resource required.required
- true if the resource is required- Returns:
- the requested resource
- Throws:
org.apache.avalon.framework.configuration.ConfigurationException
- if a required resource cannot be found.
Copyright © 2001 Apache Jakarta Project. All Rights Reserved.