Results 1 to 2 of 2
  1. #1
    timoxa is offline Member
    Join Date
    Mar 2012
    Posts
    6
    Rep Power
    0

    Default How to restore MySQL database

    Hello everybody,

    I have code to backup MySQL db but I can't use and change to restore db
    This is code to backup

    File file = fileopen.getSelectedFile();
    String dbName = "fin";
    String dbUserName = "root";
    String dbPassword = "123";

    backupDB(dbName, dbUserName, dbPassword, file);
    public boolean backupDB(String dbName, String dbUserName, String dbPassword, File path) {
    String host="localhost";
    FileWriter fw=null;
    try{
    fw = new FileWriter(path + ".sql");
    Runtime rt = Runtime.getRuntime();
    Process child = rt.exec("C:\\Program Files\\MySQL\\MySQL Server 5.1\\bin\\mysqldump -h"+host+" -u"+dbUserName+" -p"+dbPassword+" finindex");
    JOptionPane.showMessageDialog(null, "Копия база данных успешно завершена !", "Внимание!", JOptionPane.INFORMATION_MESSAGE);
    InputStream in = child.getInputStream();
    InputStreamReader xx = new InputStreamReader(in,"utf8");
    char[] chars=new char[1024];
    int ibyte=0;
    while((ibyte=xx.read(chars))>0)
    {
    fw.write(chars);
    }
    fw.close();
    }catch (Exception e1) {
    e1.printStackTrace();
    }
    return false;
    }

    how to restore db ???
    Thank you !

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,856
    Rep Power
    19

    Default Re: How to restore MySQL database

    This strikes me as a MySQL question, so I'd suggest looking at the docs for your version of MySQL.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Problem with BACKUP and RESTORE MYSQL DATABASE
    By timoxa in forum New To Java
    Replies: 4
    Last Post: 03-24-2012, 05:33 AM
  2. Replies: 2
    Last Post: 02-11-2009, 04:43 AM
  3. database with mysql using the netbeans 6.0
    By kwesiaryee in forum New To Java
    Replies: 2
    Last Post: 05-02-2008, 04:27 AM
  4. MySQL Database and Java
    By shaggymac in forum Advanced Java
    Replies: 1
    Last Post: 05-01-2008, 09:01 PM
  5. connecting to mysql database
    By javagal in forum NetBeans
    Replies: 2
    Last Post: 08-04-2007, 12:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •