Dlaczego wysypuje mi tyle błędów? Podłączenie gui

0

Gdy odpalam klasę gui i naciskam "Dodaj" wysypuje mi tyle błędów
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: zakladpogrzebowy.ZakladPogrzebowy
at zakladpogrzebowy.GUI.jDodajActionPerformed(GUI.java:157)
at zakladpogrzebowy.GUI.access$100(GUI.java:15)
at zakladpogrzebowy.GUI$2.actionPerformed(GUI.java:86)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6535)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6300)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4891)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4713)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4713)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)


Chodzi o prostą tabelę która będzie dodawała oraz wyświetlała dane z bazy, zależy mi na tym by wszystko co się tylko da było w klasie ZakładPogrzebowy, a w gui tylko wypełnianie tabeli i wyświetlanie jej.

kod GUI:
```java
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package zakladpogrzebowy;


import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Rafał
 */
public class GUI extends javax.swing.JFrame {
    

    public String id_klienta;
    public String imie;
    public String nazwisko;
    public String adres;
    public String miasto;
    public String telefon;
    
    
    /**
     * Creates new form GUI
     */
    public GUI() {
        
        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() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTabela = new javax.swing.JTable();
        jId_klienta = new javax.swing.JTextField();
        jImie = new javax.swing.JTextField();
        jNazwisko = new javax.swing.JTextField();
        jAdres = new javax.swing.JTextField();
        jMiasto = new javax.swing.JTextField();
        jTelefon = new javax.swing.JTextField();
        jDodaj = new javax.swing.JButton();
        jWyswietl = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTabela.setModel(new javax.swing.table.DefaultTableModel(
            new String [][] {
                {"id","Imie","nazwisko","adres","miasto","telefon"}
            },
            new String [] {
                "Id klienta", "Imie", "Nazwisko", "Adres", "Miasto", "Telefon"
            }
        ));
        jScrollPane1.setViewportView(jTabela);

        jId_klienta.setText("aa");

        jImie.setText("bb");
        jImie.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jImieActionPerformed(evt);
            }
        });

        jNazwisko.setText("cc");

        jAdres.setText("dd");

        jMiasto.setText("ee");

        jTelefon.setText("888");

        jDodaj.setText("Dodaj");
        jDodaj.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jDodajActionPerformed(evt);
            }
        });

        jWyswietl.setText("Wyświetl");
        jWyswietl.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jWyswietlActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jId_klienta, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jImie, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jNazwisko, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jAdres, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jMiasto, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTelefon, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jDodaj)
                        .addGap(18, 18, 18)
                        .addComponent(jWyswietl)))
                .addContainerGap(15, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(81, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jDodaj)
                    .addComponent(jWyswietl))
                .addGap(38, 38, 38)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jId_klienta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jImie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jNazwisko, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jAdres, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jMiasto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTelefon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

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

    private void jDodajActionPerformed(java.awt.event.ActionEvent evt) {                                       
    
        DefaultTableModel model =(DefaultTableModel)jTabela.getModel();
        model.addRow(new String[]{jId_klienta.getText(),jImie.getText(),jNazwisko.getText(),jAdres.getText(),jMiasto.getText(),jTelefon.getText()});
        // TODO add your handling code here:
        this.id_klienta = jId_klienta.getText();
        this.imie = jImie.getText();
        this.nazwisko = jNazwisko.getText();
        this.adres= jAdres.getText();
        this.miasto=jMiasto.getText();
        this.telefon = jTelefon.getText();
        ZakladPogrzebowy zp = new ZakladPogrzebowy();
        zp.dodajDaneDoBazy();
    }                                      

    private void jWyswietlActionPerformed(java.awt.event.ActionEvent evt) {                                          
        ZakladPogrzebowy zp = new ZakladPogrzebowy();
        zp.wyswietlDaneZBazy();
        // TODO add your handling code here:
    }                                         

    private void jImieActionPerformed(java.awt.event.ActionEvent evt) {                                      
        // TODO add your handling code here:
    }                                     

    /**
     * @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(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

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

    // Variables declaration - do not modify                     
    private javax.swing.JTextField jAdres;
    private javax.swing.JButton jDodaj;
    public javax.swing.JTextField jId_klienta;
    public javax.swing.JTextField jImie;
    private javax.swing.JTextField jMiasto;
    private javax.swing.JTextField jNazwisko;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTabela;
    private javax.swing.JTextField jTelefon;
    private javax.swing.JButton jWyswietl;
    // End of variables declaration                   
}

kod ZakladPogrzebowy:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Scanner;
import javax.swing.JTextField;
import zakladpogrzebowy.GUI;


/**
 *
 * @author Rafał
 */
public class ZakladPogrzebowy 
{


GUI gui = new GUI();
 
        static String daneZBazy;
        /**
         * @param args
         */
//       public static void main(String[] args) {
//             
//
//               dodajDaneDoBazy();
//  //wyswietlDaneZBazy();
//              
// 
//        }
        public void dodajDaneDoBazy(){
             
//            Scanner odczyt = new Scanner(System.in);
//            System.out.println("\n Podaj id klienta: ");
//            int id_klienta =odczyt.nextInt();
//             String id_klienta = gui.id_klienta;
//            
////             Scanner odczyt1 = new Scanner(System.in);
////            System.out.println("Podaj imię klienta: ");
////            String imie =odczyt.next();
//            String imie = gui.imie;
//            
////            Scanner odczyt2 = new Scanner(System.in);
////            System.out.println("Podaj nazwisko klienta: ");
////            String nazwisko =odczyt.next();
//            String nazwisko = gui.nazwisko;
////            Scanner odczyt3 = new Scanner(System.in);
////            System.out.println("Podaj adres klienta: ");
////            String adres =odczyt.next();
//            String adres = gui.adres;
////            Scanner odczyt4 = new Scanner(System.in);
////            System.out.println("Podaj miasto klienta: ");
////            String miasto =odczyt.next();
//            String miasto = gui.miasto;
//            
////            Scanner odczyt5 = new Scanner(System.in);
////            System.out.println("Podaj numer telefonu klienta: ");
////            String telefon =odczyt.next();
//            String telefon = gui.telefon;
//            
             
               String dodaj = "INSERT INTO  public.\"Klient\" "+ "VALUES ("+ gui.id_klienta + ",'"+gui.imie+"','"+gui.nazwisko+"','"+gui.adres+"','"+gui.miasto+"',"+gui.telefon+")";
               
             String polaczenieURL = "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=123456";
                //Tworzymy proste zapytanie do bazy danych
                
               
               
               
                Connection conn = null;
               
                try {
 
                        //Ustawiamy dane dotyczące podłączenia
                        conn = DriverManager.getConnection(polaczenieURL);
                       
                        //Ustawiamy sterownik MySQL
                        Class.forName("com.mysql.jdbc.Driver");
                       
                        //Uruchamiamy zapytanie do bazy danych
                        Statement stmt = conn.createStatement();
                        ResultSet rs = stmt.executeQuery(dodaj);
                    
                        conn.close();
                }
                //Wyrzuć wyjątki jężeli nastąpią błędy z podłączeniem do bazy danych lub blędy zapytania o dane
                catch(ClassNotFoundException wyjatek) {
                        System.out.println("Problem ze sterownikiem");
                }
 
                catch(SQLException wyjatek) {
                    //    e.printStackTrace();
                     //   System.out.println("Problem z logowaniem\nProsze sprawdzic:\n nazwę użytkownika, hasło, nazwę bazy danych lub adres IP serwera");
                        System.out.println("SQLException: " + wyjatek.getMessage());
                    System.out.println("SQLState: " + wyjatek.getSQLState());
                    System.out.println("VendorError: " + wyjatek.getErrorCode());
                }
 
           
         
       //      String dodaj2 = "\"INSERT INTO  public.\"Klient\"\"+\"VALUES (\"+ dodajDaneDoBazy(id_klienta)+\"'Adam','Kowalski','Lwoska','Kraków',888999666)\"";
       //      stmt.executeUpdate("INSERT INTO  public.\"Klient\""+"VALUES ("+ id_klienta+",'Adam','Kowalski','Lwoska','Kraków',888999666)");
            
        }
        
        public  void wyswietlDaneZBazy(){
              String polaczenieURL = "jdbc:postgresql://localhost:5432/postgres?user=postgres&password=123456";
                //Tworzymy proste zapytanie do bazy danych
                String wyswietl = "Select * FROM public.\"Klient\"";
               
                Connection conn = null;
               
                try {
 
                        //Ustawiamy dane dotyczące podłączenia
                        conn = DriverManager.getConnection(polaczenieURL);
                       
                        //Ustawiamy sterownik MySQL
                        Class.forName("com.mysql.jdbc.Driver");
                       
                        //Uruchamiamy zapytanie do bazy danych
                        Statement stmt = conn.createStatement();
                        ResultSet rs = stmt.executeQuery(wyswietl);
                        
                        while (rs.next()) {
                                wyswietl(rs);
                        }
    
       
                        conn.close();
                }
                //Wyrzuć wyjątki jężeli nastąpią błędy z podłączeniem do bazy danych lub blędy zapytania o dane
                catch(ClassNotFoundException wyjatek) {
                        System.out.println("Problem ze sterownikiem");
                }
 
                catch(SQLException wyjatek) {
                    //    e.printStackTrace();
                     //   System.out.println("Problem z logowaniem\nProsze sprawdzic:\n nazwę użytkownika, hasło, nazwę bazy danych lub adres IP serwera");
                        System.out.println("SQLException: " + wyjatek.getMessage());
                    System.out.println("SQLState: " + wyjatek.getSQLState());
                    System.out.println("VendorError: " + wyjatek.getErrorCode());
                }
        }
            static void wyswietl(ResultSet rs){
                
            
                try{
                daneZBazy = rs.getString(1);
                System.out.print("\n" + daneZBazy + " ");
                daneZBazy = rs.getString(2);
                System.out.print(daneZBazy + " ");
                daneZBazy = rs.getString(3);
                System.out.print(daneZBazy+ " ");
                daneZBazy = rs.getString(4);
                System.out.print(daneZBazy+ " ");
                daneZBazy = rs.getString(5);
                System.out.print(daneZBazy+ " ");
                daneZBazy = rs.getString(6);
                System.out.print(daneZBazy+ " ");
                
                }catch(SQLException e) {
                        e.printStackTrace();
                }
        }

   
               
}

0

Google mówi że to jakis WTF netbeansowy i sugeruje przebudowanie projektu i kasowanie cache netbeansa. Ja proponuje zmienic środowisko na takie które działa (jak IntelliJ).

1 użytkowników online, w tym zalogowanych: 0, gości: 1