Results 1 to 7 of 7
  1. #1
    prabhurangan is offline Member
    Join Date
    May 2008
    Posts
    69
    Rep Power
    0

    Default Restoring database through java application..?

    Hi Members,

    I have to restore the mysql database through java application. I tried using the code
    " Runtime.getRuntime().exec("mysql -u -p databasename < c:/backup.sql");"
    But this is restoring the database.
    But the same command works fine while running through command line.

    Please provide some solutions to this issue.

    Regards,
    Prabhu.

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    It has to do with either the redirection or the path or both. Read When Runtime.exec() won't - JavaWorld thoroughly and carefully.

  3. #3
    prabhurangan is offline Member
    Join Date
    May 2008
    Posts
    69
    Rep Power
    0

    Default

    Hi Masijade,

    Im new to java, however i gone through it, but what i understood is, the process executed should be handled.

    However do you have any idea of my problem, what goes wrong in my part.

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    There is no way that you thoroughly read the posted document and evaluated it's advice and suggestions against your code in the time between our posts.

    Read that link, and use its advice. And bookmark it.

    That link has everything you need (and could even want, except for a block copy and paste solution).

  5. #5
    prabhurangan is offline Member
    Join Date
    May 2008
    Posts
    69
    Rep Power
    0

    Default

    I ran the sample code given in the link provided by you, but my command is not getting executed. Instead it provides the 'usage option' for mysql command.

    My head is spinning masijade... Help me to figure out my mistake.

  6. #6
    prabhurangan is offline Member
    Join Date
    May 2008
    Posts
    69
    Rep Power
    0

    Default

    run-main:
    USAGE: java GoodWindowsExec <cmd>
    osName : Windows XP
    Execing cmd.exe /C C:\Program Files\MySQL\MySQL Server 5.0\bin\mysql -u user-p pass database < C:/backup.sql
    ERROR>'C:\Program' is not recognized as an internal or external command,
    ERROR>operable program or batch file.
    ExitValue: 1


    When i tried to execute, im facing this issue..............

  7. #7
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Like I said, it has to do with your path, and that is covered in the link I gave you.

Similar Threads

  1. Replies: 3
    Last Post: 10-28-2010, 02:42 PM
  2. Java Database Connectivity
    By Java Tutorial in forum Java Tutorial
    Replies: 2
    Last Post: 02-08-2009, 02:15 AM
  3. Replies: 3
    Last Post: 09-18-2008, 03:07 PM
  4. Excel to database using java
    By Priyadharshini.s in forum Advanced Java
    Replies: 1
    Last Post: 03-08-2008, 06:12 PM
  5. PDA, Database, and Java
    By percivalwcy in forum CLDC and MIDP
    Replies: 0
    Last Post: 08-08-2007, 03:12 AM

Posting Permissions

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