> List of tutorials

Table of contents for this tutorial

Base lesson 2, step 3: Read parameters for the connection to the database

For this document and all references (links) please obey the hints and regulations concerning copyright, disclaimer and trademarks.

Last revision of this document:
2006-02-16

This step of the tutorial integrates an externals JAR-file (jdom.jar) into the buildpath and reads the parameters for the connection to the database from a file in XML-format (XML = Extented Markup Language).

Preface:

The code written in this tutorial is far away from being optimized.
Emphasis of this tutorial is to develop the application in small steps where the completion of each step allows the application to be run eror-free and showing the result aimed by the step.
Therefore the code is written to be understandable in favor of being optimized
.

Credits:

A tutorial for reading a XML-structure in JAVA can be found under http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/dom/index.html .

Prerequisites:

Preparation:

Methods for reading data out of XML-formated structures are contained in an (external) Java-ARchive named 'jdom.jar'.
As a preparation this lesoon, 'jdom.jar' has to be downloaded.

Depending on the folder under which 'jdom.jar' should be stored, your user rights may not be sufficient.
If you experience problems during saving the file either do the download with 'root'-rights or save to a folder you are allowed to save.

Code to read a XML-structure:

In the following explanations all new code is written in bold letters.
Code generated by the template or entered in previous steps (old code) is in italics.
Larger blocks of old code may be skipped.

top.

Enter the database-parameters in the file DBParms.xml:

top.

Code the derivation of the values from the XML-structure in DBParms.xml:

top.

Next Step: