OpenNMS API 1.2.9

## org.opennms.netmgt.config
Class DatabaseConnectionFactory

    java.lang.Object
      org.opennms.netmgt.config.DatabaseConnectionFactory

public final class DatabaseConnectionFactory
extends java.lang.Object

This is the singleton class used to load the OpenNMS database configuration from the opennms-database.xml. This provides convenience methods to create database connections to the database configured in this default xml

Note: Users of this class should make sure the init() is called before calling any other method to ensure the config is loaded before accessing other convenience methods

Author:
  Brian Weaver , OpenNMS

Field Summary
`private static boolean` `m_legacy` Use the old Legacy code or the C3P0 based classes
`private static boolean` `m_loaded` This member is set to true if the configuration file has been loaded.
`private static DbConnectionFactory` `m_singleton` The singleton instance of this factory

Constructor Summary
`DatabaseConnectionFactory()`

Method Summary
`static DbConnectionFactory` `getInstance()` Return the singleton instance of this factory.
`static void` `init()` Load the config from the default config file and create the singleton instance of this factory.
`static void` `setInstance(DbConnectionFactory singleton)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### m_singleton

    private static DbConnectionFactory m_singleton

  The singleton instance of this factory

### m_loaded

    private static boolean m_loaded

  This member is set to true if the configuration file has been loaded.

### m_legacy

    private static boolean m_legacy

  Use the old Legacy code or the C3P0 based classes

Constructor Detail

### DatabaseConnectionFactory

    public DatabaseConnectionFactory()

Method Detail

### init

    public static void init()
                     throws java.io.IOException,
                            org.exolab.castor.xml.MarshalException,
                            org.exolab.castor.xml.ValidationException,
                            java.lang.ClassNotFoundException

  Load the config from the default config file and create the singleton instance of this factory.

  Throws:
    `java.io.IOException` - Thrown if the specified config file cannot be read
    `org.exolab.castor.xml.MarshalException` - Thrown if the file does not conform to the schema.
    `org.exolab.castor.xml.ValidationException` - Thrown if the contents do not match the required schema.
    `java.lang.ClassNotFoundException`

### getInstance

    public static DbConnectionFactory getInstance()

  Return the singleton instance of this factory. This is the instance of the factory that was last created when the `init` or `reload` method was invoked. The instance will not change unless a `reload` method is invoked.

  Returns:
    The current factory instance.
  Throws:
    `java.lang.IllegalStateException` - Thrown if the factory has not yet been initialized.

### setInstance

    public static void setInstance(DbConnectionFactory singleton)

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.