reduce complexity

reduce complexity

I want to make the logic simple.all suggestions welcomed servlet

//Update3
            int testid = Integer.parseInt(request.getParameter("testid"));
            int question1 = Integer.parseInt(request
                    .getParameter("questionid1"));
            int question2 = Integer.parseInt(request
                    .getParameter("questionid2"));
            int question3 = Integer.parseInt(request
                    .getParameter("questionid3"));
            int question4 = Integer.parseInt(request
                    .getParameter("questionid4"));
            int question5 = Integer.parseInt(request
                    .getParameter("questionid5"));
            int question6 = Integer.parseInt(request
                    .getParameter("questionid6"));
            int question7 = Integer.parseInt(request
                    .getParameter("questionid7"));
            int question8 = Integer.parseInt(request
                    .getParameter("questionid8"));
            int question9 = Integer.parseInt(request
                    .getParameter("questionid9"));
            int question10 = Integer.parseInt(request
                    .getParameter("questionid10"));

        TestVO question = new TestVO();

        question.setTestId(testid);
        question.setQuestionId1(question1);
        question.setQuestionId2(question2);
        question.setQuestionId3(question3);
        question.setQuestionId4(question4);
        question.setQuestionId5(question5);
        question.setQuestionId6(question6);
        question.setQuestionId7(question7);
        question.setQuestionId8(question8);
        question.setQuestionId9(question9);
        question.setQuestionId10(question10);

        UpdateQntoTestService upques = new UpdateQntoTestService();
        int count = upques.updateQuestion(question);
        // Success Page
        if (count >= 1) {
            request.setAttribute("mycount", count);
            RequestDispatcher rd1 = getServletContext()
                    .getRequestDispatcher("/JSP/UpdateQntoTestSuccess.jsp");
            rd1.forward(request, response);
            // ErrorPage
        } else {
            RequestDispatcher rd1 = getServletContext()
                    .getRequestDispatcher("/JSP/UpdateQntoTestFailure.jsp");
            rd1.forward(request, response);
        }
    }
    // Servlet for UpdateTest
    else if (pagename.equalsIgnoreCase("update1")) {

        int testId = Integer.parseInt(request.getParameter("testId"));
        ViewQnfromTest1Service vqs = new ViewQnfromTest1Service();

        HashMap<Integer, TestVO> ar = null;
        try {
            ar = vqs.viewQuestions(testId);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


        log.info(ar);
        request.setAttribute("arr", ar);
        RequestDispatcher rd1 = getServletContext().getRequestDispatcher(
                "/JSP/UpdateQuestiontoTestDB.jsp");
        rd1.forward(request, response);

    }
    // Servlet for UpdateQuestion
    else if (pagename.equals("update2")) {
        log.info(pagename);

        RequestDispatcher rd1 = getServletContext().getRequestDispatcher(
                "/JSP/UpdateQuestiontoTestFinal.jsp");
        String test1 = request.getParameter("testId1");
        String qn1 = request.getParameter("questionId1");
        String qn2 = request.getParameter("questionId2");
        String qn3 = request.getParameter("questionId3");
        String qn4 = request.getParameter("questionId4");
        String qn5 = request.getParameter("questionId5");
        String qn6 = request.getParameter("questionId6");
        String qn7 = request.getParameter("questionId7");
        String qn8 = request.getParameter("questionId8");
        String qn9 = request.getParameter("questionId9");
        String qn10 = request.getParameter("questionId10");
        request.setAttribute("testId1", test1);
        request.setAttribute("qid1", qn1);
        request.setAttribute("qid2", qn2);
        request.setAttribute("qid3", qn3);
        request.setAttribute("qid4", qn4);
        request.setAttribute("qid5", qn5);
        request.setAttribute("qid6", qn6);
        request.setAttribute("qid7", qn7);
        request.setAttribute("qid8", qn8);
        request.setAttribute("qid9", qn9);
        request.setAttribute("qid10", qn10);

        try {
            rd1.forward(request, response);
        } catch (ServletException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

service

public class ViewQnfromTestService {

public List<TestVO> calculate(int testId) {
    List ls = null;

    ViewQnfromTest1DAO daoobject = new ViewQnfromTest1DAO();
    try {
        ls = daoobject.count(testId);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        ls = null;
    }

    return ls;

service3

public class UpdateQntoTestService {

TestVO question;
int choice = 1;
int count = 0;

public int updateQuestion(TestVO question) {
    this.question = question;
    UpdateQntoTestDAO qud = new UpdateQntoTestDAO();
    try {
        count = qud.QuestionUpdate(question);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return count;

}

dao

public class ViewQnfromTest1DAO {

public List<TestVO> count(int testId) throws SQLException {
    TestVO ts = new TestVO();
    PreparedStatement pst = null;
    ConnectOracle conn = new ConnectOracle();
    Connection con = null;
    System.out.println("Ajs qqq");
    List ls = new ArrayList();
    try {
        con = conn.getConnectionOra();
        pst = con.prepareStatement(QueryConstants.VIEWQNFROMTEST);
        pst.setInt(1, testId);
        ResultSet rs1 = null;
        rs1 = pst.executeQuery();

        if(rs1 == null)
            return null;
        while (rs1.next()) {
            System.out.println(rs1.getInt(1));
            ts.setTestId(testId);
            ts.setQuestionId1(rs1.getInt(1));
            ts.setQuestionId2(rs1.getInt(2));
            ts.setQuestionId3(rs1.getInt(3));
            ts.setQuestionId4(rs1.getInt(4));
            ts.setQuestionId5(rs1.getInt(5));
            ts.setQuestionId6(rs1.getInt(6));
            ts.setQuestionId7(rs1.getInt(7));
            ts.setQuestionId8(rs1.getInt(8));
            ts.setQuestionId9(rs1.getInt(9));
            ts.setQuestionId10(rs1.getInt(10));
            ls.add(ts);
            System.out.println(ts);
        }
        if(ls == null)
            return null;

    } catch (Exception e) {
        e.printStackTrace();

        ls=null;
    }

    finally
    {
        con.close();
    }
    return ls;
}

dao2

public class UpdateQntoTestDAO {

int count = 0;
Connection conn = null;

@SuppressWarnings("finally")
public int QuestionUpdate(TestVO question) throws SQLException {
    ConnectOracle connect = new ConnectOracle();

    try {
        // Creation of Connection instance.

        conn = connect.getConnectionOra();

        // PreparedStatement usage for inserting Question Details.

        PreparedStatement pst = conn
                .prepareStatement(QueryConstants.UPDATEQNTOTEST);

        pst.setInt(1, question.getQuestionId1());
        pst.setInt(2, question.getQuestionId2());
        pst.setInt(3, question.getQuestionId3());
        pst.setInt(4, question.getQuestionId4());
        pst.setInt(5, question.getQuestionId5());
        pst.setInt(6, question.getQuestionId6());
        pst.setInt(7, question.getQuestionId7());
        pst.setInt(8, question.getQuestionId8());
        pst.setInt(9, question.getQuestionId9());
        pst.setInt(10, question.getQuestionId10());
        pst.setInt(11, question.getTestId());

        // Execute statement
        count = pst.executeUpdate();

    } catch (Exception ex) {
        ex.printStackTrace();
    }
    finally {
        conn.close();
    }
    return count;

}

}

View Answers

April 2, 2012 at 3:37 PM









Related Tutorials/Questions & Answers:
reduce complexity
reduce complexity  I want to make the logic simple.all suggestions welcomed servlet //Update3 int testid = Integer.parseInt(request.getParameter("testid")); int question1 = Integer.parseInt(request
how to reduce width of jbutton ?
how to reduce width of jbutton ?  how to reduce width of jbutton ? thanks in advancwe
Advertisements
ModuleNotFoundError: No module named 'complexity'
ModuleNotFoundError: No module named 'complexity'  Hi, My Python... 'complexity' How to remove the ModuleNotFoundError: No module named 'complexity' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'complexity'
ModuleNotFoundError: No module named 'complexity'  Hi, My Python... 'complexity' How to remove the ModuleNotFoundError: No module named 'complexity' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'async-reduce'
ModuleNotFoundError: No module named 'async-reduce'  Hi, My Python... 'async-reduce' How to remove the ModuleNotFoundError: No module named 'async-reduce' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'neuron-reduce'
ModuleNotFoundError: No module named 'neuron-reduce'  Hi, My... 'neuron-reduce' How to remove the ModuleNotFoundError: No module named 'neuron-reduce' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'pyshell-reduce'
ModuleNotFoundError: No module named 'pyshell-reduce'  Hi, My... named 'pyshell-reduce' How to remove the ModuleNotFoundError: No module named 'pyshell-reduce' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'reduce-print'
ModuleNotFoundError: No module named 'reduce-print'  Hi, My Python... 'reduce-print' How to remove the ModuleNotFoundError: No module named 'reduce-print' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'astro-reduce'
ModuleNotFoundError: No module named 'astro-reduce'  Hi, My Python... 'astro-reduce' How to remove the ModuleNotFoundError: No module named 'astro-reduce' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'async-reduce'
ModuleNotFoundError: No module named 'async-reduce'  Hi, My Python... 'async-reduce' How to remove the ModuleNotFoundError: No module named 'async-reduce' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'complexity-estimate'
ModuleNotFoundError: No module named 'complexity-estimate'  Hi, My... named 'complexity-estimate' How to remove the ModuleNotFoundError: No module named 'complexity-estimate' error? Thanks   Hi
ModuleNotFoundError: No module named 'complexity_estimator'
ModuleNotFoundError: No module named 'complexity_estimator'  Hi...: No module named 'complexity_estimator' How to remove the ModuleNotFoundError: No module named 'complexity_estimator' error? Thanks   Hi
ModuleNotFoundError: No module named 'complexity-science'
ModuleNotFoundError: No module named 'complexity-science'  Hi, My... named 'complexity-science' How to remove the ModuleNotFoundError: No module named 'complexity-science' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'pordego-complexity'
ModuleNotFoundError: No module named 'pordego-complexity'  Hi, My... named 'pordego-complexity' How to remove the ModuleNotFoundError: No module named 'pordego-complexity' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'cognitive-complexity'
ModuleNotFoundError: No module named 'cognitive-complexity'  Hi...: No module named 'cognitive-complexity' How to remove the ModuleNotFoundError: No module named 'cognitive-complexity' error? Thanks   Hi
ModuleNotFoundError: No module named 'complexity-estimate'
ModuleNotFoundError: No module named 'complexity-estimate'  Hi, My... named 'complexity-estimate' How to remove the ModuleNotFoundError: No module named 'complexity-estimate' error? Thanks   Hi
ModuleNotFoundError: No module named 'complexity_estimator'
ModuleNotFoundError: No module named 'complexity_estimator'  Hi...: No module named 'complexity_estimator' How to remove the ModuleNotFoundError: No module named 'complexity_estimator' error? Thanks   Hi
ModuleNotFoundError: No module named 'complexity-science'
ModuleNotFoundError: No module named 'complexity-science'  Hi, My... named 'complexity-science' How to remove the ModuleNotFoundError: No module named 'complexity-science' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'flake8-adjustable-complexity'
ModuleNotFoundError: No module named 'flake8-adjustable-complexity'  ...: No module named 'flake8-adjustable-complexity' How to remove the ModuleNotFoundError: No module named 'flake8-adjustable-complexity' error
ModuleNotFoundError: No module named 'flake8-annotations-complexity'
ModuleNotFoundError: No module named 'flake8-annotations-complexity'  ...: No module named 'flake8-annotations-complexity' How to remove the ModuleNotFoundError: No module named 'flake8-annotations-complexity' error
ModuleNotFoundError: No module named 'flake8-cognitive-complexity'
ModuleNotFoundError: No module named 'flake8-cognitive-complexity'  ...: No module named 'flake8-cognitive-complexity' How to remove the ModuleNotFoundError: No module named 'flake8-cognitive-complexity' error? Thanks
ModuleNotFoundError: No module named 'flake8-expression-complexity'
ModuleNotFoundError: No module named 'flake8-expression-complexity'  ...: No module named 'flake8-expression-complexity' How to remove the ModuleNotFoundError: No module named 'flake8-expression-complexity' error
ModuleNotFoundError: No module named 'jones-complexity'
ModuleNotFoundError: No module named 'jones-complexity'  Hi, My... named 'jones-complexity' How to remove the ModuleNotFoundError: No module named 'jones-complexity' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-url-reduce'
ModuleNotFoundError: No module named 'django-url-reduce'  Hi, My... named 'django-url-reduce' How to remove the ModuleNotFoundError: No module named 'django-url-reduce' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-url-reduce'
ModuleNotFoundError: No module named 'django-url-reduce'  Hi, My... named 'django-url-reduce' How to remove the ModuleNotFoundError: No module named 'django-url-reduce' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-url-reduce'
ModuleNotFoundError: No module named 'django-url-reduce'  Hi, My... named 'django-url-reduce' How to remove the ModuleNotFoundError: No module named 'django-url-reduce' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'lempel-ziv-complexity'
ModuleNotFoundError: No module named 'lempel-ziv-complexity'  Hi...: No module named 'lempel-ziv-complexity' How to remove the ModuleNotFoundError: No module named 'lempel-ziv-complexity' error? Thanks   Hi
ModuleNotFoundError: No module named 'time_complexity_estimator'
ModuleNotFoundError: No module named 'time_complexity_estimator'  Hi...: No module named 'time_complexity_estimator' How to remove the ModuleNotFoundError: No module named 'time_complexity_estimator' error? Thanks  
how can u reduce the size of textfield?
how can u reduce the size of textfield?  how can u reduce the size of textfield? thanks in advance   import javax.swing.*; public class ReduceTextField extends JFrame { public static void main(String
time and space complexity
Reduce Java Code commenting effort using JAutodoc (eclipse plugin)
Reduce Java Code commenting effort using JAutodoc (eclipse plugin)       INTRODUCTION Summary JAutodoc is a very useful eclipse plugin which
Ant4Eclipse
Ant4Eclipse       The aim of the ant4eclipse project is to avoid (or at least: to reduce) the redundancy of Eclipse and Ant configurations. More precisly: it consists
DEMOS
DEMOS       The DEMOS tool originated in the context of two research projects (FACTORS and DASCOM) dealing with software complexity. The DEMOS tool is based on a new
Weight Loss
to control your weight. Yogic exercises are best way to reduce and control
RefactorIt
RefactorIt         RefactorIT is a tool for Java developers. A developer can take source code of any size and complexity and rework it into well-designed code
Getting a Property value in jsp
Getting a Property value in jsp       This section illustrates you how to use <jsp:getProperty> tag.ADS_TO_REPLACE_1 To reduce the the scriplet code with jsp
Design patterns interview questions3
. This pattern hides the complexity of business components and centralizes the workflow... their complexity. It provides a single point of control and it also improves performance... the complexity of Data persistence layer. This pattern provides for loose
eUML2 Studio edition
UML in action at the development level: ensure the software quality and reduce
PaperClips
PaperClips       A simple, light weight, extensible Java printing plug-in for SWT. PaperClips hides the complexity of laying out and rendering documents on the printer
PHP Function
of functions we can reduce time and effort, all we need to do is create
GPS Tracking for Cars
to reduce the security issues which is a prime concern of the car owners due... to reduce the risk of accidents to a great extent. ADS_TO_REPLACE_1 Another
Eclipse Plunging/Web Services
. Whether visually programming with Java? frameworks that reduce development
Software Testing Services, Application Testing Solutions, Testing Services from Rose India
in software testing is branched out from the complexity of software. Testing is more
Extreme Project Management
in the software industry where the complexity of projects is very high and the nature
TruStudio Foundation
of extensible frameworks designed to reduce the complexity of building full
TruStudioPHP
. DLTK is comprised of a set of extensible frameworks designed to reduce the complexity of building full featured development environments for dynamic languages
Mobile Application Development
Controler as JSP - JSP-Interview Questions
dat it will be more easier to know n also it will reduce the complexity of code
The application will assist surgeon offices to make prioritize surgery bookings.
and availability, reduce guesswork and lower the complexity of booking. I am
The application will assist surgeon offices to make prioritize surgery bookings.
and availability, reduce guesswork and lower the complexity of booking. I am

Ads