im am attempt to fetch data from MS Access database right into a JTable.After i run this code snippet in console its working fine however when i actually do it on the button event in netbeans it is not showing any factor.I'm using following code and my table title is table1.

     private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {                                          

    Vector columnNames = new Vector();
    Vector data = new Vector();

    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:rrr");
    String sql = "Select * from client";
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery( sql );
    ResultSetMetaData md = rs.getMetaData();
    int columns = md.getColumnCount();
    for (int i = 1; i <= columns; i++) {
      columnNames.addElement( md.getColumnName(i) );
    }
    while (rs.next()) {
    Vector row = new Vector(columns);
    for (int i = 1; i <= columns; i++){
      row.addElement( rs.getObject(i) );
    }
    data.addElement( row );
    }
    rs.close();
    stmt.close();
    }
    catch(Exception e){
   System.out.println(e);
    }
    JTable table = new JTable(data, columnNames);
    TableColumn col;
    for (int i = 0; i < table.getColumnCount(); i++) {
    col = table.getColumnModel().getColumn(i);
     col.setMaxWidth(250);
    }


    }          

First you'll need a top level window, that ought to be possible using the Netbeans framework (that we guess you are using).

Adding the table and also the button to that particular window and register an Action or ActionListener towards the button. For the reason that action you spawn a brand new worker thread (e.g. SwingWorker), load the date within that thread increase the table's model when finished.

Inside your current solution, you are making a brand new JTable instance once the button is pressed. However, that JTable isn't put into any component, so when your actionPerformed method returns, the mention of JTable sheds and it'll not show.

JTable table = new JTable(data, columnNames);
TableColumn col;
for (int i = 0; i < table.getColumnCount(); i++) {
  col = table.getColumnModel().getColumn(i);
   col.setMaxWidth(250);
}
//here is a missing statement, like panel.add( table );

If you have a current table, it may be easier to update the type of that existing table rather than creating a replacement, as Thomas already recommended. Also, consider creating the table model on another thread then your EDT using a SwingWorker. This eliminates a blocked UI as the database is queried and also the table built. Example usages from the SwingWorker are available in the Swing Concurrency tutorial