complexType "ssj:DBConnectionParams"

Namespace: | http://www.iro.umontreal.ca/lecuyer/ssj
Content: | complex, 3 attributes, 1 element
Defined: | globally in ssj.xsd, see XML source
Includes: | definitions of 3 attributes and 1 element
Used: | at 1 location

XML Representation Summary
<...
| jdbcDriverClass | = | xsd:string
| jdbcURI | = | xsd:anyURI
| jndiDataSourceName | = | xsd:string
| >
Content: | properties?
</...>

Content Elements (1):

  properties (type ssj:PropertiesParams) |

All Direct / Indirect Based Elements (1):

  database (type ssj:DBConnectionParams) |

Known Usage Locations

- As direct type of elements (1):

  database (type ssj:DBConnectionParams) |

Annotation
Represents the parameters for a database connection established using JDBC. A connection can be established using a JDBC URI intended for the `DriverManager` or using a JNDI name corresponding to a `DataSource.` Connection information is given using attributes, and possibly properties.

Interacting with a database using Java requires a JDBC driver in addition to the database management system (DBMS). Major database vendors provide or are working on such a JDBC driver. For example, MySQL requires MySQL Connector/J while Oracle provides its own JDBC driver.

After the DBMS and the JDBC driver are determined, one can set up the parameters for the JDBC connection. This can be done two ways: using a JDBC URI, or a Java Naming and Directory Interface (JNDI) server.

All JDBC URIs start with `jdbc:` and depend on the JDBC driver used. Additionally, a driver class has to be loaded, and additional properties, e.g., user name and password, usually need to be specified. For example, the URI `jdbc:mysql://mysql.iro.umontreal.ca/database` can be used to establish a connection on the MySQL database named `database` and hosted by `mysql.iro.umontreal.ca.` The corresponding name for the driver class is `com.mysql.jdbc.Driver.`

The URI `jdbc:odbc:datasource` represents a connection to the ODBC data source named `datasource` and the corresponding driver is `sun.jdbc.odbc.JdbcOdbcDriver.`

The `jdbcURI` attribute gives the JDBC URI being used while the fully qualified name of the driver class to be loaded is given by the `jdbcDriverClass` attribute. Moreover, one can use the `properties` element to specify properties, e.g., a user name and a password, for the connection. The given properties are passed to JDBC so the supported properties also depend on the JDBC driver used.

The following example describes a connection to a MySQL database, and requires the MySQL JDBC Connector.

    <database jdbcDriverClass="com.mysql.jdbc.Driver"
       jdbcURI="jdbc:mysql://mysql.iro.umontreal.ca/database">
       <properties>
          <string name="user" value="foo"/>
          <string name="password" value="bar"/>
        </properties>
     </database>

Alternatively, one can use JNDI to establish the connection to a database. A JNDI server, which maps names to Java objects, is usually embedded into an application server such as JBoss Application Server. When using JNDI, one at least needs to set the `jndiDataSourceName` attribute to a name the JNDI server in use can map to an object implementing `java.sql.DataSource.` This data source is used to retrieve a connection to the database when parameters are read. The JNDI-specific parameters, e.g., the address of the name server, can be encoded into the `properties` nested element. If no property is specified in the database parameters, JNDI looks for the properties in a file named `jndi.properties.` See the documentation of JNDI for more information on how to set up and use JNDI.

The method `createConnection` in class `ParamReadHelper` can be used to turn an instance of the class derived from this complex type by JAXB into a `Connection` object representing the JDBC connection.

XML Source (w/o annotations (6); see schema source)

<xsd:complexType name="DBConnectionParams"> <xsd:sequence> <xsd:element maxOccurs="1" minOccurs="0" name="properties" type="ssj:PropertiesParams"> <xsd:key name="DBUniquePropertyName"> <xsd:selector xpath="*"/> <xsd:field xpath="@name"/> </xsd:key> </xsd:element> </xsd:sequence> <xsd:attribute name="jndiDataSourceName" type="xsd:string"> </xsd:attribute> <xsd:attribute name="jdbcDriverClass" type="xsd:string"> </xsd:attribute> <xsd:attribute name="jdbcURI" type="xsd:anyURI"> </xsd:attribute> </xsd:complexType>

Attribute Detail
jdbcDriverClass

  Gives the fully qualified name of the JDBC driver class to load before attempting to establish a connection using a JDBC URI. This attribute might not be needed with recent Java versions and JDBC drivers.

  Type: | xsd:string
  Use: | optional
  Defined: | locally, within (this) ssj:DBConnectionParams complexType

  XML Source (w/o annotations (1); see schema source)

  <xsd:attribute name="jdbcDriverClass" type="xsd:string"> </xsd:attribute>

jdbcURI

  Gives the URI used to establish a connection with the JDBC driver manager.

  Type: | xsd:anyURI
  Use: | optional
  Defined: | locally, within (this) ssj:DBConnectionParams complexType

  XML Source (w/o annotations (1); see schema source)

  <xsd:attribute name="jdbcURI" type="xsd:anyURI"> </xsd:attribute>

jndiDataSourceName

  Gives the JNDI name of the data source that will be used to obtain the connection.

  Type: | xsd:string
  Use: | optional
  Defined: | locally, within (this) ssj:DBConnectionParams complexType

  XML Source (w/o annotations (1); see schema source)

  <xsd:attribute name="jndiDataSourceName" type="xsd:string"> </xsd:attribute>

Content Element Detail
properties

  Represents properties for the database connection. If the connection is established using a JDBC driver, these properties are given to the driver manager, and complements the given JDBC URI. If the connection is established using JNDI, these properties become the environment used for constructing the initial JNDI context.

  Note that the values of the given properties are converted to strings before they are given to JDBC or JNDI.

  Type: | ssj:PropertiesParams, complex content
  Defined: | locally, within (this) ssj:DBConnectionParams complexType

  XML Source (w/o annotations (2); see schema source)

  <xsd:element maxOccurs="1" minOccurs="0" name="properties" type="ssj:PropertiesParams"> <xsd:key name="DBUniquePropertyName"> <xsd:selector xpath="*"/> <xsd:field xpath="@name"/> </xsd:key> </xsd:element>

XML Schema documentation generated with DocFlex/XML (Kit) v1.6.8 DocFlex/XML (Kit) is a freeware edition of DocFlex/XML, which is a powerful template-driven documentation and report generator from any data stored in XML files. Based on an innovative technology developed by FILIGRIS WORKS, this new tool offers virtuoso data querying and formatting capabilities not found in anything else! Need to convert your XML data into a clear nice-looking documentation or reports? Web-ready hypertext HTML or printable MS Word / OpenOffice.org friendly RTF? DocFlex/XML may be a cheap, quick and effective solution exactly for this task! Have questions? Not sure how to use it? Just send us e-mail to contact@filigris.com and we are always happy to help you! See also our services at www.filigris.com