Hi Jaikiran,
The connection which i mentioned in the post is a database connection,im getting the connection from the datasource whenever i need to display the popup window
JSP code is pasted below:
if (btnname == "viewral")
{
window.open('','viewral','scrollbars=yes,toolbar=no,menubar=yes,width=800,height=550,top=75,left=300');
document.reviewFrn.target="viewral";
document.reviewFrn.formtype.value="RAL";
document.reviewFrn.frn_action.value="viewforms";
document.reviewFrn.action="/usf/FundingRequestServlet";
document.reviewFrn.submit();
}
Portion of code from Servlet where the popup window is getting called:
String sJSPAction = (String) request.getParameter("frn_action");
if ( sJSPAction.equals("viewforms") )
{
Vector forms_vector = new Vector();
// Read the Form type for which view screen is needed.
if( request.getParameter("formtype").equals("RAL"))
{
// Obtaining the Value of the FRN from the JSP editfrn.jsp
frnNo = request.getParameter("formfrn");
USFEnv.getLog().writeDebug( "FRN #"+frnNo, this,null );
// Create db connection for EJB
frnInfoEJBean.connect();
// Get the FRN data
forms_vector = frnInfoEJBean.getRalDataByFrn(frnNo);
// Release db connection for EJB
frnInfoEJBean.release();
// Set the data that has been retreived.
request.setAttribute( "forms_vector",forms_vector);
request.setAttribute( "countForm","false");
// Include the JSP
includeJSP( request, response, FRN_JSP_PATH, "viewral" );
}
From the above code connect() and release() methods are pasted below:
public void connect() throws ConnectException,RemoteException
{
USFEnv.getLog().writeDebug( "creating db connection()" , this , null );
ejbConn = null;
ejbConn = dbconn.open();
if ( ejbConn == null )
{
throw new ConnectException( "Database connection failure" );
}
}
public void release() throws ConnectException,RemoteException
{
try
{
USFEnv.getLog().writeDebug( " release db connection()", this, null );
if ( ejbConn != null )
ejbConn.close();
ejbConn = null;
}
catch( Exception ex )
{
throw new ConnectException( "Database connection not released" );
}
}
The below method is getting called from servlet:
public Vector getRalDataByFrn( String frnNo )
{
StringBuffer query = new StringBuffer( "" );
Vector rals_vector = new Vector();
PreparedStatement pstmt = null;
ResultSet rs = null;
query.append( "select * from stage_ral_form where frn = ? order by email_date" );
USFEnv.getLog().writeDebug( " Get ral form by FRN Query: " + query.toString() , this, null );
try
{
USFEnv.getLog().writeDebug( " Get ral form by FRN Query conn obj: " +conn , this, null );
pstmt = conn.prepareStatement( query.toString() );
pstmt.setString(1,frnNo);
rs = pstmt.executeQuery();
while( rs.next() )
{……
}
Database Connection:
private static DataSource ds = null;
private static java.sql.Connection conn=null;
static {
// Load the type 2 driver
try {
ds = (DataSource)USFEnv.ic.lookup("java:/jboss/datasources/usfdev");
} catch (Exception e) {
USFEnv.getDefaultLog().writeWarn("DataSource could not be found using JNDI ",null,null);
}