Newsgroup: it.comp.java
Titolo: Caricare i dati da un recordset a una Jtable

Come posso fare a mostrare su una Jtable o altro componente i dati
restituiti da una query(e quindi in un recordset) . in caso specifico ho
creato una jtable con una estenzione pero non riesco aindividuare come poter
fare a restiuire i dati.
Ecco cosa ho fatto
import java.sql.*;
import java.awt.*;
public class Risultati extends javax.swing.JDialog{
    public Risultati(java.sql.ResultSet Rs){
        setModal(true);
        initComponents();
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {
        jButton1 = new javax.swing.JButton();
        try {
            jScrollPane1
=(javax.swing.JScrollPane)java.beans.Beans.instantiate(getClass().getClassLo
ader(), "Auser.Tesseramento.Risultati_jScrollPane1");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (java.io.IOException e) {
            e.printStackTrace();
        }
        jTable1 = new javax.swing.JTable();
        getContentPane().setLayout(null);
        setTitle("Risultati della ricerca");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });
        jButton1.setText("jButton1");
        getContentPane().add(jButton1);
        jButton1.setBounds(560, 260, 73, 25);
        jTable1.setModel(new Auser.Tesseramento.extenzione());
        jScrollPane1.setViewportView(jTable1);
        getContentPane().add(jScrollPane1);
        jScrollPane1.setBounds(0, 0, 550, 340);
        java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-655)/2, (screenSize.height-379)/2, 655,
379);
    }
    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {
    }
    private void costruisci(){
    }
    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    // End of variables declaration
}
***---- Estenzione del modello -----
import java.sql.*;
public class extenzione extends javax.swing.table.AbstractTableModel{
    /* private String[] columnNames = {"First Name",
        "Last Name",
        "Sport",
        "# of Years",
        "Vegetarian"};
        */
        private String[] columnNames = {};
        private Object[][] data = {};
       /* private Object[][] data = {
            {"Mary", "Campione","Snowboarding", new Integer(5), new
Boolean(false)},
             {"Alison", "Huml","Rowing", new Integer(3), new Boolean(true)},
              {"Kathy", "Walrath","Knitting", new Integer(2), new
Boolean(false)},
               {"Sharon", "Zakhour","Speed reading", new Integer(20), new
Boolean(true)},
                {"Philip", "Milne","Pool", new Integer(10), new
Boolean(false)}};
       */
    /** Creates a new instance of extenzione */
    public extenzione(java.sql.ResultSet Rs) {
    }
    public int getColumnCount() {
        return columnNames.length;
    }
    public int getRowCount() {
        return data.length;
    }
    public Object getValueAt(int row, int col) {
        return data[row][col];
    }
    public String getColumnName(int col) {
        return columnNames[col];
    }
    }
Nonb riesco a lavarci le gambe. qualcuno ha qualche idea??
Grazie anticipatamente

 ha scritto nel messaggio 
news:369cl8F...@individual.net...
