Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9220079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:15:53+00:00 2026-06-18T03:15:53+00:00

in my android application I’m using the following code to copy the entire data

  • 0

in my android application I’m using the following code to copy the entire data in a particular table. But It seems to be generate duplicate values when I check with servlet output. You can verify this by running the following code. I don’t know why this happened. I need to pass the values from servlet to my application as JSON Object..

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;

public class vlgmas extends HttpServlet {

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
        // TODO output your page here
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Servlet vlgmas</title>");  
        out.println("</head>");
        out.println("<body>");
        out.println("<h1>Servlet vlgmas at " + request.getContextPath () + "</h1>");
        out.println("</body>");
        out.println("</html>");

    } finally {            
        out.close();
    }
}


@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
     try {

        out.println("<html>");
        out.println("<head>");
        out.println("<title>Servlet Pickvalue</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("<h1>Servlet Pick at " + request.getContextPath () + "</h1>");
        doPost(request,response);
        out.println("</body>");
        out.println("</html>");

    } finally
    {
        out.close();
    }
}

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    //processRequest(request, response);
    String vname = null,vcode=null,divsec=null;
    JSONObject obj = new JSONObject();
    List list = new ArrayList();
    JSONObject obj2 = new JSONObject();
    PrintWriter out = response.getWriter();
    String vn[]=new String[2000],vc[]=new String[2000],ds[]=new String[2000];
    int t,r1=0,r2=0,r3=0;
    try
    {
        Class.forName("oracle.jdbc.driver.OracleDriver");
    java.sql.Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.200:1521:pdsm", "test", "test");
    Statement stmt=conn.createStatement();

        {
        ResultSet rs = stmt.executeQuery("select * from cn_vlgmas");
        while(rs.next())
        {
            //vn[r1++]=rs.getString ("vlgname");
            //vc[r2++]=rs.getString("vlgcode");
            //ds[r3++]=rs.getString("divsec");
            vname=rs.getString ("vlgname");
            vcode=rs.getString("vlgcode");
            divsec=rs.getString("divsec");
            obj.put("vname",vname);
            obj.put("vcode",vcode);
            obj.put("divsec",divsec);
            list.add(obj);
            obj2.accumulate("get", list);
            out.println(obj2);
        }
       /*for(t=0;t<r1;t++)
           {
            //out.println(vn[t]+","+vc[t]+","+ds[t]+" ");
            obj.put("vname",vn[t]);
            obj.put("vcode",vc[t]);
            obj.put("divsec",ds[t]);
            list.add(obj);
            //obj.append("rec", obj);
            //out.println(list);
            //obj.accumulate("get", list);
            //out.println(obj);
            obj2.accumulate("get", obj);
            //out.println(obj2);
            }*/


        }

    }catch(Exception e)
    {
        out.println("error"+e.toString());
    }
}


@Override
public String getServletInfo() {
    return "Short description";
}// </editor-fold>
}

Can anyone help me please.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:15:55+00:00Added an answer on June 18, 2026 at 3:15 am

    change By user2021114

    Add

    obj = new JSONObject();
    

    in While Loop

    while(rs.next())
        {
                obj = new JSONObject();
                vname=rs.getString ("vlgname");
                vcode=rs.getString("vlgcode");
                divsec=rs.getString("divsec");
                obj.put("vname",vname);
                obj.put("vcode",vcode);
                obj.put("divsec",divsec);
                list.add(obj);
    
        }
    obj2.accumulate("get", list);
    out.println(obj2); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My android application is using the compatibility library quite heavily ( Loaders in particular).
My Android application uses a secret key to generate a token for authentication purposes.
My android application has several warnings of the following form when I run it
In android application we are using Bluetooth connectivity with some of medical devices. To
This Android application on Google uses the following method to refresh the database after
My Android application is expecting and array of usernames from my WCF Service using
in android application I am using the Google API for maps. I got the
My Android application does some calculations, but I noticed recently that if I were
I have Android application and own Application derived class holding some internal data. Among
In android application for data storing and sharing in app which one is good

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.