Dear friends
I am newbie to struts 1.2 and going to create simple example that insert the values into tables i write following simple Action servlet but it didn't work please tell
me or suggest me changes in that file
package com.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.*;
import org.apache.struts.actions.*;
import com.form.WorkOrderForm;
import java.sql.*;
import utility.ProjectUtility;
public class WorkOrderAction1 extends Action
{
String WONum=null,WODate=null;
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)throws Exception
{
javax.sql.DataSource dataSource;
java.sql.Connection myConnection=null;
try
{
dataSource = getDataSource(request);
myConnection = dataSource.getConnection();
Statement stmt=myConnection.createStatement();
WorkOrderForm woForm = (WorkOrderForm) form;
WONum=woForm.getwoNum();
WODate=woForm.getwoDate();
System.out.println("WONum : "+WONum);
System.out.println("WODate : "+WODate);
//String qry="insert into complete_erp.tbl_1_workorder (workorderno,wo_date) values('"+WONum+"','"+WODate+"')";
//int i=stmt.executeUpdate("insert tbl_1_workorder (workorderno,wo_date) values('"+WONum+"','"+WODate+"')");
int i=stmt.executeUpdate("insert into workorder (workorder_no,workorderDate) values('"+WONum+"','"+WODate+"')");
System.out.println(""+i);
stmt.close();
if(i==1)
{
return mapping.findForward("success");
}
else
{
return mapping.findForward("failure");
}
//stmt.executeUpdate(qry);
//System.out.println("execute"+stmt.executeUpdate(qry));
}
catch(SQLException sqle)
{
getServlet().log("Connection.process", sqle);
}
finally
{
//enclose this in a finally block to make
//sure the connection is closed
try
{
myConnection.close();
}
catch (SQLException e)
{
getServlet().log("Connection.close", e);
}
}
return mapping.findForward("failure");
}
}