Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC reduce complexity

Have Programming Question? Ask it here!
 
 
 


rajesh
reduce complexity
1 Answer(s)      2 years and 4 months ago
Posted in : JDBC


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;

}

}


Advertisement
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
Java: Language Complexity
Java: Language Complexity Many programming language features are designed reduce program complexity, with varying success. Don't confuse programming language complexity with user program complexity. From the student programmer's
Advertisements
how to reduce width of jbutton ?
how to reduce width of jbutton ?  how to reduce width of jbutton ? thanks in advancwe
Complexity is your enemy
Java: Complexity is your enemy Complexity is to software as Heat is to Chips Much of programming is about reducing software complexity. Entire software... be viewed as techniques to control complexity. Complexity can be seen as similar
Complexity Measurement
Java: Complexity Measurement Because complexity depends on many variable human characteristics, achieving automatic complexity measurement is probably... a reasonable job of suggesting ways to avoid complexity. Flow Complexity
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
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. To reduce the the scriplet code with jsp, there is an easier way
Design patterns interview questions3
. This pattern hides the complexity of business components and centralizes the workflow... and locating services and encapsulating their complexity. It provides a single..., abstracts the data sources and hides the complexity of Data persistence layer
C and C++ books-page5
C and C++ books-page5       The GNU C Programming Tutorial The terms low level and high level are often used to describe these layers of complexity in computers. The low
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. Another emerging and advance
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
TruStudioPHP
. DLTK is comprised of a set of extensible frameworks designed to reduce the complexity of building full featured development environments for dynamic languages
TruStudio Foundation
of extensible frameworks designed to reduce the complexity of building full
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
Shortcomings And Restrictions of RIAs
developers can reduce the delay time by compressing the scripts, and by staging... complex and difficult to handle. The additional complexity of RIA makes them
Database books
allows various applications to communicate across the enterprise as well as reduce the time and the complexity of developing and maintaining integration links
Database books Page13
various applications to communicate across the enterprise as well as reduce the time and the complexity of developing and maintaining integration links. An adapter
Shortcomings And Restrictions of RIAs
reduce the delay time by compressing the scripts, and by staging their delivery over... and difficult to handle. The additional complexity of RIA makes them harder to design
Flex - Development process
Flex   hi All, In flex how to reduce the spaces between the column in column chart. My ColumnWidthRation is 0.4 without changing this value how to reduce the spaces between the bar? Thanks, aravindakumarThangaraju
java
java  which has the high time complexity??? a program having 100 lines of code or a program which goes to its loop 100 times
Algorithms: Big-Oh Notation
an algorithm requires. This "complexity analysis" attempts to characterize... Complexity analysis can be very useful, but there are problems with it too. Too... a time-as-function-of-distance big-oh complexity of O(N). Altho they have
interface
interface  sir/mam, pls tell me how interfaces reduce duplicasy in java.. atul
Java Encapsulation Example
the application robust because, it can reduce the complexity of system
Eclipse Plugin- J2EE Development Platform
without the need for technical expertise. The complexity of Java and J2EE programming... Studio helps companies to reduce time and effort to build enterprise J2ee
DECESION MAKING STATEMENTS
DECESION MAKING STATEMENTS  The Decision Making statements may be implemented in different forms depending on the complexity of the condition to be tested. Describe various forms of decision making statements in java
Insertion Sort Timer
Insertion Sort Timer  Welcome all I wanna program in java find the timer of insertion sort and find time complexity for random value thanks all
JAVA certification effort - Framework
JAVA certification effort  Estimated time to certify JAVA on the following platforms? 1. WindRiver Linux PNE LE 2.0 2. RedHat Linux 5.2 What is the complexity of this effort? Thanks. Hans
javascript - Development process
javascript  how to reduce the pageloading time in javascript? can you give example code for the way of executing homepage with css and javascript
java program
java program  Hi, I got interview question like this.Coding should be in java. String input: TTSAAS Step 1: Reduce the consecutive same word SAAS Step 2: SS Step 3: -1
ArrayList and Vector
ArrayList and Vector  hello, Why ArrayList is faster than Vector?   hii, ArrayList is faster than Vector, because ArrayList is not synchronized. Synchronization will reduce the performance of Vector
VoIP Resellers
Studio, Envox CT Connect, and Envox CT ADE, all of which aim to reduce the time, cost and complexity of developing and deploying voice solutions into new markets.... I was looking to reduce monthly expenses," Bruemmer explains. "Originally, we
Hibernate Tutorial
application server. Reduce database access complexity by easy fetching techniques
Parasoft Jtest
allows us to reduce errors at the source, adjust our practices as necessary..., Cyclomatic Complexity, Nested Blocks Depth, Number Of Children Identifies
 

 

 

DMCA.com