Results 1 to 2 of 2
  1. #1
    denonth is offline Member
    Join Date
    Jan 2011
    Posts
    2
    Rep Power
    0

    Question Putting data into table - BIG PROBLEM

    Hi guys I have a problem.
    So I am making a phonebook for my college project. So I have few java files, one of them is database connection which is giving me back an array of object that I have made.
    So problem is: I want to put data into table but I get arrayindexout of bound:0;
    I have tried all things but it seems that index is not good...
    so here is a piece of code:

    naziviStupaca = new Object[5];
    String[] nazivStupaca ={"Identifikator", "Ime", "Prezime", "Adresa","Broj Telefona"};
    for (int i = 0; i < nazivStupaca.length; i++) {
    naziviStupaca[i]=nazivStupaca[i];
    } //these part is for columns, so there is 5 of them

    //stupac is Object[][]
    stupac = new Object[koris.size()][nazivStupaca.length];
    /koris is an arraylist of query that I get back
    koris = queryKorisnici("select * from domagoj.KORISNICI");

    for (int i = 0; i < koris.size(); i++) {
    for(int j=0;j< nazivStupaca.length;j++){
    if(j==0){ //this is ID
    stupac[i][j] = koris.get(j).getIdentifikatorKorisnika();
    }
    if(j==1){ //this is first name
    stupac[i][j]=koris.get(j).getIme();
    }
    if(j==2){ //this is last name
    stupac[i][j]=koris.get(j).getPrezime();
    }
    if(j==3){ //adress
    stupac[i][j]= koris.get(j).getAdresa();
    }
    if(j==4){ //phone number
    stupac[i][j]=koris.get(j).getBrojTelefona();
    }

    }


    }
    //
    tablica.setModel(new DefaultTableModel(stupac, naziviStupaca));

    If anyone could please help I would be very thankfull. If you need anything else let me know.

  2. #2
    denonth is offline Member
    Join Date
    Jan 2011
    Posts
    2
    Rep Power
    0

Similar Threads

  1. Putting image in pdf problem
    By WimHaar in forum New To Java
    Replies: 0
    Last Post: 01-08-2011, 05:52 PM
  2. Rich data table problem
    By learner23 in forum New To Java
    Replies: 1
    Last Post: 11-11-2010, 06:23 PM
  3. Replies: 3
    Last Post: 06-02-2010, 06:58 PM
  4. What do you use for saving data from table?
    By ocean in forum New To Java
    Replies: 1
    Last Post: 11-21-2009, 07:08 PM
  5. Jsf, Filtering Data In A Table
    By Freddie in forum JavaServer Faces (JSF)
    Replies: 2
    Last Post: 05-11-2007, 12:59 AM

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
  •