Java.io.ioexception Cannot Run Program Mysql Createprocess Error=2
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might how to take backup of mysql database using java have Meta Discuss the workings and policies of this site
How To Take Backup Of Mysql Database Using Java Swing
About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting mysqldump command ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up java.io.IOException:Cannot run program “mysql”:CreateProcess error=2, The system cannot find the file specified up vote 0 down vote favorite Something is going wrong with my program for database recovery, this error hides my happiness: java.io.IOException: Cannot run program "mysql":CreateProcess error=2, The system cannot find the file specified file to be recovered is located in D:/Backup/backup.sql when I browse and open the file from this path then error appears when I click recovery button. Please help me solve this problem. below is my code with JFileChooser for browsing file location. browseButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent event){ String recPath = ""; JFileChooser fc = null; if (fc == null) { fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fc.setAcceptAllFileFilterUsed(false); } int returnVal = fc.showDialog(null, "Open"); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); recPath = file.getAbsolutePath(); sourceField.setText(recPath); } } } ); recoveryButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent event){ try{ String databaseName ="jdbc:mysql://localhost:3306/myDB"; String userName ="abc"; String password ="123"; String source = sourceField.getText(); int processComplete; String[] executeCmd = new String[]{"mysql",databaseName, "--user=" + userName, "--password=" + password, "-e", "source"+source}; //sava the command in a array Process runtimeProcess = Runtime.getRuntime().exec(executeCmd);// execute the command processComplete = runtimeProcess.waitFor();// get the result to variable if(processComplete==1){ JOptionPane.showMessageDialog(null, "Restore Failed"); } else if(processComplete==0){ JOptionPane.showMes
Certification Databases Caching Books Engineering Languages Frameworks Products This Site Careers Other all forums Forum: JDBC and Relational Databases java.io.IOException: Cannot run program "mysql":CreateProcess error=2, The system cannot find the fi Nasoro Salum Greenhorn Posts: 4 posted 7 months ago How are you my friends? Something is going wrong with my program for database recovery, this error hides http://stackoverflow.com/questions/35699614/java-io-ioexceptioncannot-run-program-mysqlcreateprocess-error-2-the-system my happiness: java.io.IOException: Cannot run program "mysql":CreateProcess error=2, The system cannot find the file specified file to be recovered is located in D:/Backup/backup.sql when I browse and open the file from this path then error appears when I I click recovery button. Please help me to solve this https://coderanch.com/t/662714/JDBC/databases/java-io-IOException-run-program problem. below is my code with JFileChooser for browsing file location. browseButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent event){ String recPath = ""; JFileChooser fc = null; if (fc == null) { fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fc.setAcceptAllFileFilterUsed(false); } int returnVal = fc.showDialog(null, "Open"); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); recPath = file.getAbsolutePath(); sourceField.setText(recPath); } } } ); recoveryButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent event){ try{ String databaseName ="jdbc:mysql://localhost:3306/myDB"; String userName ="abc"; String password ="123"; String source = sourceField.getText(); int processComplete; String[] executeCmd = new String[]{"mysql",databaseName, "--user=" + userName, "--password=" + password, "-e", "source"+source}; //sava the command in a array Process runtimeProcess = Runtime.getRuntime().exec(executeCmd);// execute the command processComplete = runtimeProcess.waitFor();// get the result to variable if(processComplete==1){ JOptionPane.showMessageDialog(null, "Restore Failed"); } else if(processComplete==0){ JOptionPane.showMessageDialog(null, "Restore Completed"); } } catch(Exception ex){ JOptionPane.showMessageDialog(null,ex); } } } ); Dave Tolls Ranch Hand Posts: 1955 14
CommunityOracle User Group CommunityTopliners CommunityOTN Speaker BureauJava CommunityError: You don't have JavaScript enabled. This tool uses JavaScript and much of it will not work correctly https://community.oracle.com/thread/1326368 without it enabled. Please turn JavaScript back on and reload this page. Please enter a title. You can not post a blank message. Please type your message and try again. More discussions in Java - JDBC Archive All PlacesOracle CommunityArchived ForumsJava - JDBC Archive This discussion is how to archived 12 Replies Latest reply on Apr 17, 2008 3:11 PM by dcminter backup not taking 843859 Jan 16, 2015 5:03 PM hi to all,I've a backup code but that will not be taking the backup..String ip="localhost"; String port="3306"; String database="rich"; String user="username"; String pass="password"; String path; how to take JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new File(".")); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.showSaveDialog(null); path = chooser.getSelectedFile().getAbsolutePath(); System.out.println(path); String dumpCommand = "mysqldump " + database + " -h " + ip + " -u " + user +" -p" + pass; Runtime rt = Runtime.getRuntime(); File test=new File(path); PrintStream ps; try{ Process child = rt.exec(dumpCommand); ps=new PrintStream(test); InputStream in = child.getInputStream(); int ch; while ((ch = in.read()) != -1) { ps.write(ch); System.out.write(ch); //to view it by console } JOptionPane.showMessageDialog (null,"BackUP Successfully Completed"); InputStream err = child.getErrorStream(); while ((ch = err.read()) != -1) { System.out.write(ch); } }catch(Exception exc) { exc.printStackTrace(); } This code is throwing this error path=/home/VEL AREA/backupfile.sql java.io.IOException: Cannot run program "mysqldump": java.io.IOException: error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:459) at java.lang.Runtime.exec(Runtime.java:593) at java.lang.Runtime.exec(Runtime.java:431) at java.lang.Runtime.exec(Runtime.java:328) at richwoods.MasterScreen.actionPerformed(MasterScreen.java:682) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) at javax.swing.AbstractButton.doClick(AbstractButton.java:357) at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1216) at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouse