[Java] codice per inserimento sql

Discussione in 'Java' iniziata da nunzio.rizzo74, 11 Novembre 2017.

Tag (etichette):
  1. nunzio.rizzo74

    nunzio.rizzo74 Nuovo Utente

    Registrato:
    11 Novembre 2017
    Messaggi:
    1
    Mi Piace Ricevuti:
    0
    Punteggio:
    1
    Salve ragazzi mi servirebbe un codice in java per aggiungere una JTable o una JList in un JPane in modo da visualizzare la seguente query: select * from amici
    So che è una richiesta assurda ma chiedo il vostro aiuto poichè ho iniziato ad usare netbeans e non riesco proprio a farlo funzionare.
    Grazie in anticipo.

    vi lascio il codice:

    package main;

    import javax.swing.JScrollPane;

    /**
    *
    *
    */
    public class Home_Data extends javax.swing.JFrame {

    /**
    * Creates new form Home_Data
    */
    public Home_Data() {
    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.
    */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

    jPanel1 = new javax.swing.JPanel();
    jLabel15 = new javax.swing.JLabel();
    exit = new javax.swing.JLabel();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setBackground(new java.awt.Color(255, 255, 255));

    jPanel1.setBackground(new java.awt.Color(45, 118, 232));

    jLabel15.setFont(new java.awt.Font("Verdana", 1, 24));
    jLabel15.setForeground(new java.awt.Color(255, 255, 255));
    jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/main/images/home_48px_1.png")));
    jLabel15.setText("Home");

    exit.setFont(new java.awt.Font("Verdana", 0, 18));
    exit.setForeground(new java.awt.Color(255, 255, 255));
    exit.setText("X");
    exit.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mousePressed(java.awt.event.MouseEvent evt) {
    exitMousePressed(evt);
    }
    });

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addGap(69, 69, 69)
    .addComponent(jLabel15)
    .addContainerGap(751, Short.MAX_VALUE))
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
    .addGap(0, 0, Short.MAX_VALUE)
    .addComponent(exit, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
    );
    jPanel1Layout.setVerticalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addComponent(exit)
    .addGap(17, 17, 17)
    .addComponent(jLabel15)
    .addContainerGap(50, Short.MAX_VALUE))
    );

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(416, Short.MAX_VALUE))
    );

    pack();
    }// </editor-fold>

    private void exitMousePressed(java.awt.event.MouseEvent evt) {
    // TODO add your handling code here:
    System.exit(0);
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
    * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
    */
    try {
    for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
    if ("Nimbus".equals(info.getName())) {
    javax.swing.UIManager.setLookAndFeel(info.getClassName());
    break;
    }
    }
    } catch (ClassNotFoundException ex) {
    java.util.logging.Logger.getLogger(Home_Data.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
    java.util.logging.Logger.getLogger(Home_Data.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
    java.util.logging.Logger.getLogger(Home_Data.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
    java.util.logging.Logger.getLogger(Home_Data.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>
    //</editor-fold>
    //</editor-fold>
    //</editor-fold>
    //</editor-fold>
    //</editor-fold>
    //</editor-fold>
    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new Home_Data().setVisible(true);

    }
    });
    }

    // Variables declaration - do not modify
    private javax.swing.JLabel exit;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration
    }
     
    Ultima modifica: 11 Novembre 2017
Sto caricando...

Condividi questa Pagina