29.01.2013 Views

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

In order to run the application using the data source connection, one more step<br />

needs to be taken. The application server configuration will need to be updated<br />

so that it has the information it needs to access the database. In the case of a<br />

data source connection, this basically consists of defining a JDBC provider (that<br />

is, the JDBC driver class to be used to access the database) and creating a data<br />

source definition (thereby updating the JNDI namespaces) with information on<br />

how to access the database. We will show you how to do this in 6.2.9, “Testing”<br />

on page 200.<br />

Note: In this situation, the password used to access the database is stored<br />

unencrypted. An alternative to storing the user ID and password as servlet<br />

initialization parameters is to store them as JAAS authentication alias entries<br />

(where the password is encrypted). The wizard does not give this option, but<br />

you can easily update the code and create the definitions required for this. For<br />

information on this method, see 16.5, “JAAS security” on page 570.<br />

Driver manager connection<br />

The driver manager connection is defined in much the same way as the data<br />

source connection. Example 6-2 shows the code.<br />

Example 6-2 Driver manager connection code<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

SELECT DB2ADMIN.ITEM.ITEM_NUMBER, DB2ADMIN.ITEM.ITEM_SHORT_DESC,<br />

DB2ADMIN.ITEM.ITEM_LONG_DESC, DB2ADMIN.ITEM.QUANTITY, DB2ADMIN.ITEM.PRICE,<br />

DB2ADMIN.ITEM.SOTD_FLAG FROM DB2ADMIN.ITEM WHERE DB2ADMIN.ITEM.ITEM_LONG_DESC<br />

LIKE :item_desc ORDER BY PRICE ASC<br />

<br />

<br />

<br />

196 <strong>IBM</strong> <strong>WebSphere</strong> <strong>Application</strong> <strong>Server</strong> - Express V5.0.2 Developer Handbook

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!