1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
public class TestFormation extends DispatchAction
{
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse res) throws Exception
{
Connection connection = null ;
String forward = "success";
String param1 = request.getParameter("facilityList");
String param2 = request.getParameter("lot_nbmList");
String param3 = request.getParameter("prd_nameList");
DataSource datasource = null;
HttpSession session = request.getSession();
/***************connection BDD*************/
try
{
connection = ((DataSource)(new InitialContext()).lookup("java:jdbc/xxxxxxxxx")).getConnection();
} catch (NamingException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
if (request.getParameter("reqcode") != null)
{
if (request.getParameter("reqcode").equals("toto"))
{
System.out.println("toto");
log.warn("TechnoAction: execute starts...\n");
TechnoForm tform = (TechnoForm) form;
tform.setIdx("Veuillez saisir une yyyyy");
tform.setyyyyy("");
tform.setzzzzzz("");
tform.setwwww("");
session.setAttribute("TechnoForm",tform);
}
if (request.getParameter("reqcode").equals("form"))
{
if (datasource != null)
{
try
{
connection = datasource.getConnection();
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("select yyyyy,zzzzzz,wwwww from fcm_wip where yyyyyyyLIKE 'R8%'"
+ param1 + "'"+ param2 + "'"+ param3 +"'");
while (resultSet.next())
{
param1 = resultSet.getString(1);
param2 = resultSet.getString(2);
param3 = resultSet.getString(3);
}
connection.close();
}
catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
return mapping.findForward(forward);
}
} |
Partager