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
|
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
NewStrutsActionForm newStrutsActionForm = (NewStrutsActionForm)form;
String[] title = newStrutsActionForm.getTitle();
String columns = null;
int i = 0;
DataSource dataSource;
Connection myConnection=null;
if (isCancelled(request)){
return mapping.findForward(CANCEL);
}
if (title.length!=0){
/***DataSource***/
try {
dataSource = getDataSource(request);
myConnection = dataSource.getConnection();
Statement stmt=myConnection.createStatement();
ResultSet rst=stmt.executeQuery("select title from CT_EIB_ARCHIVES");
System.out.println("******************************************");
System.out.println("********Out Put from TestDataSource ******");
while(rst.next()){
System.out.println("Title is " + rst.getString("TITLE"));
System.out.println("******************************************");
}
catch (SQLException sqle) {
sqle.printStackTrace();
getServlet().log("Connection.process", sqle);
}
}
finally {
try {
rst.close();
stmt.close();
myConnection.close();
}
catch (SQLException e) {
getServlet().log("Connection.close", e);
}
}
/***end DataSource***/
return mapping.findForward(PRINT);
} else {
ActionMessages errors = new ActionMessages();
ActionMessage error = new ActionMessage("errors.login.invalid");
errors.add("loginWrong",error);
saveErrors(request.getSession(),errors);
return mapping.getInputForward();
}
}
} |
Partager