2014년 4월 22일 화요일

[Recommanded Resources] A simple servlet application for testing database connectivity from a datasource configured within WebSphere Application Server

A simple servlet application for testing database connectivity from a datasource configured within WebSphere Application Server

Recommended Resources


Abstract

This technote provides an application which can be deployed to WebSphere Application Server 6.1, 7.0, 8.0 or above for testing database connectivity via a data source.

Content

An application EAR, SimpleServletEar.ear (SimpleServletEar61.ear for V6.1), is provided to obtain a connection from the connection pool and test the connectivity to the database. Sometimes it is desired to test connectivity from an application because the "Test Connection" function in Admin Console is done using the deployment manager or a nodeagent, rather than an application server, and a JNDI lookup of the data source is not done with "Test Connection". This application is not meant to be used in a production environment.

The application is provided in two versions. SimpleServletEar61.ear is for V6.1 and SimpleServletEar.ear is for V7.0 and above.
The Java code in these two application ears are the same. The only difference is in the deployment descriptors. Starting in WAS 7, the ibm-web-bnd.xmi and ibm-web-ext.xmi which were used in WAS 6.1 and earlier releases have been replaced by ibm-web-bnd.xml and ibm-web-ext.xml. The XML format in these two files have changed too in WAS 7.

Install the application to your application server in the administrative console. Select "Detailed" path instead of "Fast Path" for V7.0 and above. In the step "Map resource references to resources", select the JNDI name of the data source which will be tested under "Target Resource JNDI Name".

After you have successfully installed the application, start it. Use the following URL in a web browser to invoke the servlet which will then connect to the database:

http://<host name>:<port>/SimpleServlet
One of the following two messages will be returned to the browser:
1. "We are in simple servlet - successfully connected to the database" - this message indicates that the connection has been successful.
2. "We are in simple servlet - failed to connect to the database. Error: " - this message indicates that the connection failed. The detailed error message and stack trace is returned to the browser.

댓글 없음:

댓글 쓰기