org.apache.james.util
Class SqlResources

java.lang.Object
  extended by 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.


Constructor Summary
SqlResources()
           
 
Method Summary
 java.lang.String getDbOption(java.lang.String name)
          Returns the dbOption string value set for the specified dbOption name.
 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
 

Constructor Detail

SqlResources

public SqlResources()
Method Detail

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 definitions
sqlDefsSection - the xml element containing the strings to be used
conn - the Jdbc DatabaseMetaData, taken from a database connection
configParameters - a map of parameters (name-value string pairs) which are replaced where found in the input strings
Throws:
java.lang.Exception

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:
ConfigurationException - if a required resource cannot be found.

getDbOption

public java.lang.String getDbOption(java.lang.String name)
Returns the dbOption string value set for the specified dbOption name.

Parameters:
name - the name of the dbOption required.
Returns:
the requested dbOption value


Copyright © 2002-2007 The Apache Software Foundation. All Rights Reserved.