Auf Thema antworten

so. habe gerade nochmals das DB connect angepasst. bin jetzt glaube ich wieder am anfang angelangt... sprich DB connect und GUI an sich funktionieren. leider ohne inhalt der daten aus der DB...


[code=Java]import java.sql.*;


/*

 * artikelverwaltung1.java

 *

 * Created on __DATE__, __TIME__

 */


/**

 *

 * @author  __USER__

 */

public class artikelverwaltung1 extends javax.swing.JDialog {


   

    private Connection mydbconn = null; 

   

    /** Creates new form artikelverwaltung1 */

    public artikelverwaltung1(java.awt.Frame parent, boolean modal) {

        super(parent, modal);


        initComponents();


        //DB Connection erstellen

        try {

             String userName = "root";

             String password = "root";

             String url = "jdbc:mysql://localhost/mydb";

             Class.forName("com.mysql.jdbc.Driver").newInstance();

             this.mydbconn = DriverManager.getConnection(url, userName, password);

             System.out.println("Database connection established");

             } catch (Exception e) {

               System.err.println("Cannot connect to database server ");

               e.printStackTrace();

             }

    }

    

   

    /** 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.

     */

    //GEN-BEGIN:initComponents

    // <editor-fold defaultstate="collapsed" desc="Generated Code">

    private void initComponents() {


        jScrollPane1 = new javax.swing.JScrollPane();

        jTable1 = new javax.swing.JTable();


        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);


        jTable1.setModel(new javax.swing.table.DefaultTableModel(

                new Object[][] { { null, null, null, null, null },

                        { null, null, null, null, null },

                        { null, null, null, null, null },

                        { null, null, null, null, null } }, new String[] {

                        "ID", "Bezeichnung", "Preis", "bearbeiten", "löschen" }) {

            Class[] types = new Class[] { java.lang.Object.class,

                    java.lang.Object.class, java.lang.Object.class,

                    java.lang.Boolean.class, java.lang.Boolean.class };


            public Class getColumnClass(int columnIndex) {

                return types[columnIndex];

            }

        });

        jScrollPane1.setViewportView(jTable1);


        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(

                getContentPane());

        getContentPane().setLayout(layout);

        layout.setHorizontalGroup(layout.createParallelGroup(

                javax.swing.GroupLayout.Alignment.LEADING).addGroup(

                javax.swing.GroupLayout.Alignment.TRAILING,

                layout.createSequentialGroup()

                        .addContainerGap(29, Short.MAX_VALUE)

                        .addComponent(jScrollPane1,

                                javax.swing.GroupLayout.PREFERRED_SIZE, 452,

                                javax.swing.GroupLayout.PREFERRED_SIZE)

                        .addGap(22, 22, 22)));

        layout.setVerticalGroup(layout.createParallelGroup(

                javax.swing.GroupLayout.Alignment.LEADING).addGroup(

                layout.createSequentialGroup()

                        .addGap(107, 107, 107)

                        .addComponent(jScrollPane1,

                                javax.swing.GroupLayout.PREFERRED_SIZE, 93,

                                javax.swing.GroupLayout.PREFERRED_SIZE)

                        .addContainerGap(135, Short.MAX_VALUE)));


        pack();

    }// </editor-fold>

    //GEN-END:initComponents


    /**

     * @param args the command line arguments

     */

    public static void main(String args[]) {

        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {

                artikelverwaltung1 dialog = new artikelverwaltung1(

                        new javax.swing.JFrame(), true);

                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    public void windowClosing(java.awt.event.WindowEvent e) {

                        System.exit(0);

                    }

                });

                dialog.setVisible(true);

            }

        });

    }


    //GEN-BEGIN:variables

    // Variables declaration - do not modify

    private javax.swing.JScrollPane jScrollPane1;

    private javax.swing.JTable jTable1;

    // End of variables declaration//GEN-END:variables


}[/code]



Oben