Namespace: |
|
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 | |||
> | |||||
|
|||||
</...> |
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.
<xsd:complexType name="DBConnectionParams"> <xsd:sequence> <xsd:key name="DBUniquePropertyName"> <xsd:selector xpath="*"/> <xsd:field xpath="@name"/> </xsd:key> </xsd:element> </xsd:sequence> </xsd:attribute> </xsd:attribute> </xsd:attribute> </xsd:complexType> |
Type: |
xsd:string |
Use: |
optional |
Defined: |
<xsd:attribute name="jdbcDriverClass" type="xsd:string"> </xsd:attribute> |
Type: |
xsd:anyURI |
Use: |
optional |
Defined: |
<xsd:attribute name="jdbcURI" type="xsd:anyURI"> </xsd:attribute> |
Type: |
xsd:string |
Use: |
optional |
Defined: |
<xsd:attribute name="jndiDataSourceName" type="xsd:string"> </xsd:attribute> |
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: |
<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 |