1

I have a text Field where the user enter a world to search a JTable when the user click a button called btnSearch.

every time I try to perform a search nothing happen and an Exception is thrown (see error below) when debug it show that the error occur at the if statement condition. could you please explain what I should do to fix the problem

the Error:

     Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError:com.mysql.jdbc.StringUtils.isEmptyOrWhitespaceOnly(Ljava/lang/String;)Z

The Code behind the search button:

    btnSearch.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            String entry =txtSearchData.getText();
            if (StringUtils.isEmptyOrWhitespaceOnly(entry)){

            }else{
            }
            txtSearchData.setText(" ");
        }
    });
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Sarah
  • 133
  • 1
  • 9

1 Answers1

2

The only explanation I can find is you are using 2 mysql jdbc jars:

  • one that has StringUtils.isEmptyOrWhitespaceOnly defined, and which is used when you compile your code;

  • another one that does not have StringUtils.isEmptyOrWhitespaceOnly defined, and which is used when you run your code.

You should use only one version, both for compiling and running. Check you project dependencies and make sure there is only one mysql jdbc driver.

Matei Florescu
  • 1,155
  • 11
  • 23