filling arraylist with database values
<pre><code>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package XawalaManager;

import java.sql.*; // DB handling package
import java.util.*;
import javax.swing.table.*;
import javax.swing.table.AbstractTableModel;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.TableModelEvent;

/**
 *
 * @author Abdi Aden
 */
public class DBHandler extends AbstractTableModel {


    private static Connection connection;

    private static Statement stmt;
    Vector columnHeaders;
    Vector tableData;
    static int id;
   public static int autokey = -1;
    static String [] contactList;
    static  ArrayList senders =  new ArrayList();

    public DBHandler() {
        Vector rowData;
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            // Assumes Messages.mdb is in the same folder as MessageData.class
            String sourceURL = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=olympic.mdb;";
            connection = DriverManager.getConnection(sourceURL, "admin", "");
            stmt = connection.createStatement();           
            String sql = "Select * FROM senderTable";
            Statement stmt = connection.createStatement();
            ResultSet rs = stmt.executeQuery(sql);
            ResultSetMetaData md = rs.getMetaData();

            int count = md.getColumnCount();
            columnHeaders = new Vector(count);
           tableData = new Vector();
            for (int i = 1; i &lt;= count; i++) {
                columnHeaders.addElement(md.getColumnName(i));
            }
            while (rs.next()) {
                rowData = new Vector(count);
                for (int i = 1; i &lt;= count; i++) {
                    rowData.addElement(rs.getObject(i));
                }
               tableData.addElement(rowData);
            }


        } catch (Exception e) {
            System.out.println("There is an connection error:  " +e );
        }
    }

    public int getColumnCount() {
        return columnHeaders.size();
    }

    public int getRowCount() {
        return tableData.size();
    }

    public Object getValueAt(int row, int column) {
        Vector rowData = (Vector) (tableData.elementAt(row));
        return rowData.elementAt(column);
    }



    public boolean isCellEditable(int row, int column) {
        return false;
    }

    public String getColumnName(int column) {
        return (String) (columnHeaders.elementAt(column));
    }






    public static ArrayList getSend(){

        try{
            ResultSet res = stmt.executeQuery("SELECT * FROM senderTable");
            //ArrayList senders =  new ArrayList();
            while (res.next()){
                String send = res.getString(2);
                senders.add(send);

            }
        }catch (Exception e ){
            System.out.println("getSend "+e);
            return null;
        }
        return senders;
    }

    // close the database

    public static void close() {
        try {
            connection.close();
        } catch (Exception e) {
            // this shouldn't happen
            System.out.println("close"+e);
        }
    }
}
</code></pre>

<p>this my full code my table model words fine fills up my table just fine but the array doesn't full and give me a stack trace :</p>

<pre><code>getSend java.lang.NullPointerException
Exception in thread "main" java.lang.NullPointerException
        at XawalaManager.mainView.&lt;init&gt;(mainView.java:86)
        at XawalaManager.XawalaManager.&lt;init&gt;(XawalaManager.java:40)
        at XawalaManager.XawalaManager.main(XawalaManager.java:108)
Java Result: 1
</code></pre>

<p>like this</p>
