Results 1 to 3 of 3
  1. #1
    yurixd is offline Member
    Join Date
    Oct 2014
    Posts
    1
    Rep Power
    0

    Default JTable Repeat Result

    My problem is that I have a JTable that always prints the first line repeatedly, and ignores the following data. I think that is the problem code.

    JTable Repeat Result-sem-t-tulo.png

    I do a query and converts it to a list to populate my JTable. I ask you to analyze my code to see if it is right.

    Java Code:
     try{
            EntityManager em = EntityManagerUtil.getEntityManager();
            em.getTransaction().begin();
    
            Query query_resultados = em.createQuery("FROM "
            + "Resultados WHERE res_codigo LIKE "+aux);
    
            List<Resultados> lista_resultados = 
                    (List<Resultados>) query_resultados.getResultList();
    
            for(int i=0; i<lista_resultados.size(); i++){
    
                Resultados resultado = lista_resultados.get(i);
    
                System.out.println("Teste: "+lista_resultados.get(i).getRes_anti_hbc_hbs());
                System.out.println("i= "+i);
    
                model.addRow(new Object[] {resultado.getRes_anti_hbc_hbs(), 
                    resultado.getRes_anticorpos_irregulares(),
                resultado.getRes_chagas(), resultado.getRes_codigo(), 
                resultado.getRes_data(), resultado.getRes_ggpd(), 
                resultado.getRes_hbs_aq(), resultado.getRes_hcv(),
                resultado.getRes_hiv(), resultado.getRes_htlv_i_ii(), 
                resultado.getRes_malaria(), resultado.getRes_responsavel(), 
                resultado.getRes_sifilis(), resultado.getRes_t_mancha(),
                resultado.getRes_tpg()});
            }
        }catch(Exception e){
            JOptionPane.showMessageDialog(null,"Erro: "+e);
        }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: JTable Repeat Result

    /gazes into crystal ball

    The problem is in the getResultList() method

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: JTable Repeat Result

    And you get nothing more here until you post links to all cross posts in all threads on all forums where you've asked this.

    I've already wasted my time telling you what MadProgrammer had said in SO.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Using jTable to display query result
    By zenith666 in forum New To Java
    Replies: 2
    Last Post: 01-13-2012, 02:29 AM
  2. Struts 2 error : No result defined for action / result
    By sameerk in forum Web Frameworks
    Replies: 1
    Last Post: 05-17-2011, 10:15 AM
  3. problem in get result than SQL to jtable
    By MS_Dark in forum New To Java
    Replies: 0
    Last Post: 12-13-2008, 12:52 PM
  4. result select sql in jtable
    By herfnai in forum JDBC
    Replies: 0
    Last Post: 08-17-2008, 12:20 PM
  5. result select sql in jtable
    By herfnai in forum JDBC
    Replies: 0
    Last Post: 08-17-2008, 12:20 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •