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 6323657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:33:35+00:00 2026-05-24T16:33:35+00:00

i want to add all my data from DB to jtable, but using this

  • 0

i want to add all my data from DB to jtable, but using this code i get only the last row from DB, added to the table severelal times.
Can someone tell where is mistake?

public Vector getOrder() throws Exception
{ 
    DbConnection();
    Statement st = null;
    ResultSet res =null;
    String query="Select * From Orders;";

try{
    st=connect.createStatement();
    res=st.executeQuery(query);
    Vector v =new Vector();
    Vector<String> record = new Vector<String>();
    int i=0;
    while(res.next())
    { 
    record.clear();
        uzsakNr=res.getString("Uzsakymo_nr");           
        priemDat=res.getString("Priemimo_data");
        irengPav=res.getString("Irenginio_pavadinimas");
        model=res.getString("Modelis");
        status=res.getString("Statusas");
        grazDat=res.getString("Grazinimo_data");
        clientId=Long.toString(res.getLong("ClientId"));

        //record.addElement(i);
        record.addElement(uzsakNr);
        record.addElement(priemDat);
        record.addElement(irengPav);
        record.addElement(model);
        record.addElement(status);
        record.addElement(grazDat);
        record.addElement(clientId);
        //record.addElement("");
        v.addElement(record);       
        i++;
    }
    //Zle vydaji, daji tyko trzy takiesame ostatnie
    System.out.println(v);
    return v;
}finally {
    if(res!=null) res.close();
    if(st!=null) st.close();
}

}

in another class

        try{
        Vector ve=db.getOrder();

        String heading[]={"uzsakNr","priemDat","irengPav","model","status","grazDat","ClientID"};
        Vector columnHeads= new Vector();
        for (int i=0;i<heading.length; i++)
            columnHeads.addElement(heading[i]);

        table = new JTable(ve,columnHeads);
        table.addMouseListener(new TableMouseListener());
        scrollPane.setViewportView(table);
        UzsakPanel.add(scrollPane);
        scrollPane.setBounds(10, 10, 901, 200);
        }catch(Exception e2){e2.printStackTrace();}
  • 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-05-24T16:33:35+00:00Added an answer on May 24, 2026 at 4:33 pm

    Firstly,

    Replace the line containing clear() with Vector<String> record = new Vector<String>();

    Secondly, I think what you’re doing is probably correct but your printing is the problem.

    Since you have a vector of vectors containing strings, I would print it like so

    for(Vector stringVect : v) {
        for(String s : stringVect) {
            System.out.print(s+ '\t');
      }
      System.out.println();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What if I want not only to add events for all future added, but
I want to add all the keys from the dictionary to the array. This
I do this to query all data from the database $query=$this->db->get('tablename', $num, $offset); I
I want to display/add/delete data from several table in MVC component, in JTable class:
OK, I want to get all the data from the first column of a
I'm developing web-application, in this I want to add all months values on the
I want add my custom sidebar next right column all page. Please check this
This is my xml file. I want to add a new element to all
I have a button with a jquery code that clears all data from a
I am trying to get all the data from a combo-box in vb. Lets

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.