Query

 

 

Properties

 

 

-JdbcDriver

 

 

-LoginID

 

 

-Password

 

 

-JdbcServer

 

 

-Statement

 

 

-Format

 

 

-Recurse

Servlet

instantiate

SQLToXML

 

 

 

 

execute

 

 

XML Document

Figure 11-8

SQLToXML

 

Initializing the SQLToXML class

We created a separate initQueryProperties method to setup the property. Since we use same property during this application running, we initialize this property in the init method.

￿Add QueryProperties as a global variable:

private QueryProperties queryProperties;

￿Add initQueryProperties method (Example 11-7).

￿In the init method, add a statement to invoke the initQueryProperties method.

initQueryProperties();

￿Also, we instantiated SQLToXML in the init method:

sql2xml = new SQLToXML(queryProperties);

Example 11-7 initQueryProperties method

private void initQueryProperties()

{

queryProperties = new QueryProperties(); queryProperties.setJdbcDriver(

"COM.ibm.db2.jdbc.app.DB2Driver");

queryProperties.setLoginId("db2admin");

queryProperties.setPassword("db2admin");

queryProperties.setJdbcServer("jdbc:db2:AIRLINE");

queryProperties.setStatement(

"SELECT * FROM CUSTOMER WHERE SERIAL = :membership");

Chapter 11. Light weight XML-based Enterprise Application 271

Page 287
Image 287
IBM Version 5 manual Initializing the SQLToXML class, Example 11-7 initQueryProperties method