Hi,
I am using
Struts and
jsp for my Screens. My Main Screen contains 8 buttons.
button.name= Name
button.address=Address
button.ids=IDs
button.url=URL....
When i press name button , it works fine .After that when i went for url or address or ids button iam getting error like
java.sql.SQLException: Closed Connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.jdbc.driver.PhysicalConnection.prepareCall(PhysicalConnection.java:919)
at oracle.jdbc.driver.PhysicalConnection.prepareCall(PhysicalConnection.java:885)
at com.avox.struts.action.ButtonsAction.ids_button(ButtonsAction.java:185)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)
at org.apache.struts.actions.LookupDispatchAction.execute
........
But when i stop and strt my
tomcat, then another button works fine remaining are not working..
In struts-config.xml, my code look like this
<form-beans >
<form-bean name="ButtonsForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="names" type="java.util.ArrayList" />
<form-property name="addresses" type="java.util.ArrayList" />
<form-property name="legalnames" type="java.util.ArrayList" />
<form-property name="urls" type="java.util.ArrayList" />
<form-property name="ids" type="java.util.ArrayList" />
</form-bean>
....
<action
attribute="ButtonsForm"
input="/jsp/clientList.jsp"
name="ButtonsForm"
parameter="method"
path="/ButtonsAction"
scope="request"
type="com.avox.struts.action.ButtonsAction">
<forward
name="button_address"
path="/jsp/buttons/Address.jsp"
contextRelative="true" />
<forward
name="button_name"
path="/jsp/buttons/Name.jsp"
contextRelative="true" />
<forward
name="button_ids"
path="/jsp/buttons/Ids.jsp"
contextRelative="true" />
<forward
name="button_url"
path="/jsp/buttons/Url.jsp"
contextRelative="true" />
My action class
public class ButtonsAction extends LookupDispatchAction {
DBConnection db = new DBConnection();
CommonData cd = new CommonData();
OracleCallableStatement cstmt = null;
DataTGenericData genericData = null;
Connection conn = null;ResultSet rs=null;
public ButtonsAction() throws Exception{
db.init(); conn=db.getConnection();cd.init();
}
// Name Button
public ActionForward name_button(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
DynaActionForm ButtonsForm = (DynaActionForm) form;
. try {
mnames= new ArrayList(); int j=0;
cstmt =(OracleCallableStatement)conn.prepareCall
( "begin ? := pkg_csr_data.get_data2(?,?,?,?); end;" );
cstmt.registerOutParameter( 1,OracleTypes.STRUCT,"DATA_T_GENERIC_DATA");
........
........
mclients.add(new Mclient(result.toString()));
ButtonsForm.set("names",mnames);
}
cstmt.close();cstmt = null;
db.close(conn);
} catch (Exception e) {e.printStackTrace();}
finally {
if (cstmt != null) {
try {
cstmt.close();
} catch (SQLException e) {;}
}
}
return (mapping.findForward("button_name"));
}
public ActionForward address_button(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException, Exception
{
DynaActionForm ButtonsForm = (DynaActionForm) form;
try {
maddress= new ArrayList(); int j=0;
cstmt =(OracleCallableStatement)conn.prepareCall
( "begin ? := pkg_csr_data.get_data2(?,?,?,?); end;" );
cstmt.registerOutParameter( 1,OracleTypes.STRUCT,"DATA_T_GENERIC_DATA");
........
........
mclients.add(new Mclient(result.toString()));
ButtonsForm.set("addresses",maddress);
}
cstmt.close();cstmt = null;
db.close(conn);
} catch (Exception e) {e.printStackTrace();}
finally {
if (cstmt != null) {
try {
cstmt.close();
} catch (SQLException e) {;}
}
}
return (mapping.findForward("button_address"));
}
protected Map getKeyMethodMap()
{
Map map = new HashMap();
map.put("button.name","name_button");
map.put("button.address","address_button");
map.put("button.ids","ids_button");
map.put("button.url","url_button");
return map;
}
}
In my action class, i am instatiating my dynaction form every time. i think my error is due to that re-instatiation.i have to store all of my buttons data globally in diferent arraylists. i am trying to that but iam unable to retrive those data.
how can i solve this problem. I have spent 2 days for this error.still iam not getting right data.
Thanks in advance