简体   繁体   中英

java sql + check true/false

I have problem ; / I set in global variable :

public static boolean wystawianie;

On other button i set to this variable true. But this if dont see this true/false... This code do always :

JOptionPane.showMessageDialog(null, "Faktura została wystawiona poprawnie");
dispose();  

Kod:

public void actionPerformed(ActionEvent e)
                {

                if(zmienne.wystawianie = true)
            {

                JOptionPane.showMessageDialog(null, "Faktura została wystawiona poprawnie");
                dispose();  

            }
            else
            {
                try
                {
                    String url = "jdbc:mysql://localhost:3306/faktury";
                    String userid = "root";
                    String password = "w4t3q99j";

                    Connection conn= DriverManager.getConnection( url, userid, password );
                    Statement stmt = conn.createStatement();
                    String sql = "DROP DATABASE "+zmienne.a+"";
                    stmt.executeUpdate(sql);
                    System.out.println("usuniete");


                }
                catch(Exception e3)
                {
                    System.out.println(e3);
                }

                JOptionPane.showMessageDialog(null, "Faktura została nie zapisana");
                dispose();  
            }

            }
        });

Anyone know why ? ^^

This statement: if(zmienne.wystawianie = true)

sets the value of zmienne.wystawianie to true.

You should use:

if(zmienne.wystawianie)

instead.

You are doing assignment(single=) instead of comparison(==) here:

            if(zmienne.wystawianie = true)

Change it to:

            if(zmienne.wystawianie == true)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM