How Ebase Accesses Databases
Add
a database connection (using the web application context)
See also: Database Connections
These notes are intended for someone configuring a database
connection with an application server other than Tomcat, and with configuration
knowledge of the J2EE application server under which Ebase is installed. If you
experience difficulties, please contact Ebase Technology for support.
According to the J2EE specification, the recommended
technique for a J2EE application such as Ebase to access a database is via the web
application context. This works as follows: the application provides a list
of database resources that it needs to access in resource reference entries
within its .war file. When the application is installed, these resource
references are mapped to the "real" resource connections defined to
the J2EE application server. However, while this technique is recommended by
the specification, it is not mandated. Application servers differ in their
requirements for adding a database connection to an application after it has
been installed; some allow this to be done by editing configuration files,
whereas others require that the .war file is changed and then re-installed.
Because of these differences, Ebase attempts a number of
different options when looking up a datasource
connection. When a connection is first made, Ebase tries these options in the
following order:
where RESOURCE NAME is the datasource
id taken from the Ebase Database Connection
which is configured with connection type: Pooled
connection configured in application server.
1.
Add the database to the web application context.
Add a definition like the one below to the web.xml
file in the Web-Inf directory for the Ebase web
application.
<resource-ref
id="ResourceRef_1">
<description>Your database</description>
<res-ref-name>jdbc/YOURDBNAME</res-ref-name>
<res-type>javax.sql.XADataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Ensure that the prefix jdbc/ is used in the resource reference name.
2.
Add the datasource
connection definition to the application server. Details vary according to the
application server.
Note: if creating a
connection to a MySQL database, include the parameter
'autoReconnect=true' in the JDBC URL. Failure to do
this can lead to lost connections reported as SocketException
errors.
3.
Map the web application resource reference to
the datasource definition. Details vary according to
the application server.
Note that some application servers do not give you access to the xml files
to allow you to complete the third step. You may need to expand and modify the
supplied UFS.war file to add the resource definition
in step 1 above, and then re-deploy this into your application server.