|
ContactCenters V. 0.9.9. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectumontreal.iro.lecuyer.xmlconfig.AbstractParam
umontreal.iro.lecuyer.xmlconfig.DBConnectionParam
public class DBConnectionParam
Represents the parameters for a database connection established using JDBC. A
connection can be established using a JNDI name corresponding to a
DataSource
, or using a JDBC URI intended for the
DriverManager
. Connection information is given using attributes. For
example, the following code gives parameters for a JDBC connection using
MySQL.
... <db jdbcDriverClass="com.mysql.jdbc.Driver" jdbcURI="jdbc:mysql://mysql.iro.umontreal.ca/database"> <property name="user" value="foo"/> <property name="password" value="bar"/> </db>
Constructor Summary | |
---|---|
DBConnectionParam()
Nullary constructor for the parameter reader. |
|
DBConnectionParam(Class<? extends Driver> jdbcDriverClass,
URI jdbcURI)
Constructs parameters for a JDBC connection using the driver manager, with URI jdbcURI, and driver class jdbcDriverClass. |
|
DBConnectionParam(String jndiDataSourceName)
Constructs parameters for a JDBC connection using a data source obtained via JNDI, with name jndiDataSourceName. |
Method Summary | |
---|---|
void |
addProperty(PropertyParam p)
Adds a new connection property. |
DBConnectionParam |
clone()
|
Connection |
createConnection()
Creates the database connection from the parameters stored in this object. |
Class<? extends Driver> |
getJdbcDriverClass()
Returns the JDBC driver class. |
URI |
getJdbcURI()
Returns the JDBC URI. |
String |
getJndiDataSourceName()
Returns the JNDI name of the data source that will be used to obtain the connection. |
Set<PropertyParam> |
getProperties()
Returns the properties used by this parameter object. |
void |
setJdbcDriverClass(Class<? extends Driver> jdbcDriverClass)
Sets the JDBC driver class to jdbcDriverClass. |
void |
setJdbcURI(URI jdbcURI)
Sets the JDBC URI to jdbcURI. |
void |
setJndiDataSourceName(String jndiDataSourceName)
Sets the JNDI name of the data source to jndiDataSourceName. |
Element |
toElement(ClassFinder finder,
Node parent,
String elementName,
int spc)
Converts this parameter object to a DOM element using the class finder finder for formatting class names, with parent node parent, element name elementName, and spc spaces for each indentation level. |
Methods inherited from class umontreal.iro.lecuyer.xmlconfig.AbstractParam |
---|
check, createDocument, getId, getXref, setId, setXref, toString, write, write, write, write, write, write, write, write |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DBConnectionParam()
public DBConnectionParam(String jndiDataSourceName)
jndiDataSourceName
- the name of the data source.
NullPointerException
- if jndiDataSourceName is null.public DBConnectionParam(Class<? extends Driver> jdbcDriverClass, URI jdbcURI)
jdbcDriverClass
- the driver class, can be null.jdbcURI
- the JDBC URI.
NullPointerException
- if jdbcURI is null.Method Detail |
---|
public Connection createConnection() throws SQLException
Properties
object from the
properties in this object. If a JNDI name is specified, these properties
are used as an environment for the InitialContext
constructor, the
constructed context is used to look for a data source, and the connection
is obtained. Otherwise, the driver is loaded if its class is not
null, and the connection is established using the URI and
properties.
SQLException
- if a connection error occurred.public Class<? extends Driver> getJdbcDriverClass()
public void setJdbcDriverClass(Class<? extends Driver> jdbcDriverClass)
jdbcDriverClass
- the new JDBC driver class.
IllegalArgumentException
- if the driver class is non-null, and does not
implement the Driver
interface.public URI getJdbcURI()
public void setJdbcURI(URI jdbcURI)
jdbcURI
- the new JDBC URI.public String getJndiDataSourceName()
public void setJndiDataSourceName(String jndiDataSourceName)
jndiDataSourceName
- public Set<PropertyParam> getProperties()
public void addProperty(PropertyParam p)
p
- the new property.public Element toElement(ClassFinder finder, Node parent, String elementName, int spc)
StorableParam
Element
instance with name elementName and add it to the
node parent of the DOM tree. It is recommended to use
DOMUtils
helper methods for this. After the element is created,
attributes can be set and nested contents can be added. The configured DOM
element is then returned.
toElement
in interface StorableParam
finder
- the class finder used to format class names.parent
- the parent of the new element.elementName
- the name of the constructed element.spc
- the number of spaces for each indentation level.
public DBConnectionParam clone()
clone
in class Object
|
ContactCenters V. 0.9.9. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |