0

can someone please correct to me this program, i try to connect to MySQL but the process cant stop, if i run this command in command prompt there is cursor waiting and i authenticate without it just pressing enter here is the code:

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         


     try {
        // TODO code application logic here
        Process x=Runtime.getRuntime().exec("cmd /C C:\\xampp\\mysql\\bin\\mysql -u root -p -e \"show slave status\\G\"| findstr \"Last_SQL\"");
        BufferedReader br = new BufferedReader(new InputStreamReader(x.getInputStream()));
        BufferedReader stdError = new BufferedReader(new InputStreamReader(x.getErrorStream()));
        // read the output from the command

        String s = null;
        String t=null;
        while ((s = br.readLine()) != null) {

            jTextArea1.append("\n"+s);
        }

   }catch(IOException ex){
         ex.printStackTrace();
   }

}                                        
14
  • your problem is not quite clear Commented Apr 16, 2014 at 23:34
  • ok i want to execute the command that i specified to getRuntime().exec() on java and put the result in JTexArea but there is problem in command i dont know how can i solve it Commented Apr 16, 2014 at 23:37
  • try to elaborate the exact problem you are facing. is it hanging up the command line or you are getting some error? Commented Apr 16, 2014 at 23:39
  • first thank you for the help, concerning this example there is no error its correct but the process is waiting, normally in command prompt if we execute this command when we press enter there is another cursor that waits for entering the password, in my example i don't have password authentication with root.beg pardon Commented Apr 16, 2014 at 23:46
  • it seems you dont have a password set for root user. If it is so, try sending a null string or "" as the password. Commented Apr 16, 2014 at 23:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.