public abstract class DataSourceFactory extends Object
This is the singleton class used to load the OpenNMS database configuration from the opennms-datasources.xml. This provides convenience methods to create database connections to the database configured in this default XML.
Constructor and Description |
---|
DataSourceFactory() |
Modifier and Type | Method and Description |
---|---|
static void |
close()
close
|
static DataSource |
getInstance()
Return the singleton instance of this factory.
|
static DataSource |
getInstance(String name)
getInstance
|
static void |
init()
Deprecated.
This function is no longer necessary for DataSourceFactory initialization
|
static void |
init(String dsName)
init
|
static void |
setDataSourceConfigurationFactory(DataSourceConfigurationFactory factory) |
static void |
setInstance(DataSource ds)
setInstance
|
static void |
setInstance(String dsName,
DataSource ds)
setInstance
|
public static void init() throws IOException, ClassNotFoundException, PropertyVetoException, SQLException
public static DataSource 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.
IllegalStateException
- Thrown if the factory has not yet been initialized.public static DataSource getInstance(String name)
getInstance
name
- a String
object.DataSource
object.public static void setInstance(DataSource ds)
setInstance
ds
- a DataSource
object.public static void setInstance(String dsName, DataSource ds)
setInstance
dsName
- a String
object.ds
- a DataSource
object.public static void setDataSourceConfigurationFactory(DataSourceConfigurationFactory factory)
public static void close()
close
SQLException
- if any.Copyright © 2020. All rights reserved.