user manual

240 BES Developers Guide
Advanced Topics for Defining JDBC Datasources
Advanced Topics for Defining JDBC Datasources
Whether you choose to use the server's graphical tools or not, defining a
datasource means providing some information to the container in XML format.
Let's look at what it takes to define a JDBC datasource and bind it to JNDI.
Let's start by examining the DTD of the jndi-definitions.xml file. The elements
in bold are the main elements specific to JDBC datasources.
<!ELEMENT jndi-definitions (visitransact-datasource*, driver-datasource*,
jndi-object*)>
<!ELEMENT visitransact-datasource (jndi-name, driver-datasource-jndiname,
property*)>
<!ELEMENT driver-datasource (jndi-name, datasource-class-name,
log-writer?, property* )>
<!ELEMENT jndi-object (jndi-name, class-name, property* )>
<!ELEMENT property (prop-name, prop-type, prop-value)>
<!ELEMENT prop-name (#PCDATA)>
<!ELEMENT prop-type (#PCDATA)>
<!ELEMENT prop-value (#PCDATA)>
<!ELEMENT jndi-name (#PCDATA)>
<!ELEMENT driver-datasource-jndiname (#PCDATA)>
<!ELEMENT datasource-class-name (#PCDATA)>
<!ELEMENT log-writer (#PCDATA)>
<!ELEMENT class-name (#PCDATA)>
Defining a JDBC datasource involves two XML elements. The first is the
<visitransact-datasource> element. This is where you define the datasource
your application code will look up. You include the following information:
jndi-name: this is the name of the datasource as it will be referenced by
JNDI. It is also the name found in the resource references of your
enterprise beans.
driver-datasource-jndiname: this is the JNDI name of the driver class
supplied by the database or JMS vendor that you deployed as a library to
your Partitions. It is also the name that will be referenced by the <driver-
datasource> element discussed next.
properties: these are the properties for the datasource's role in its
connection pool. We'll discuss these properties in a little more detail in the
Defining the Connection Pool Properties for a JDBC Datasource on
page 232.
So, let's look at an example of this portion of the datasource definition in the
XML. In the following example, we'll look at an example using Oracle:
<jndi-definitions>
<visitransact-datasource>
<jndi-name>serial://datasources/Oracle</jndi-name>
<driver-datasource-jndiname>serial://datasources/OracleDriver</driver-
datasource-jndiname>
<property>