Thursday, 15 August 2013

Error while creating mysql restore cmd in java -



Error while creating mysql restore cmd in java -

i trying restore mysql sql file using java, dont have thought why it's not working. code given below.

/*note: getting path jar file beingness executed*/ codesource codesource = dbmanager.class.getprotectiondomain().getcodesource(); file jarfile = new file(codesource.getlocation().touri().getpath()); string jardir = jarfile.getparentfile().getpath(); /*note: creating database constraints*/ string dbname = "dth"; string dbuser = "root"; string dbpass = "root"; string restorepath ="\""+ jardir + "\\backup" + "\\" + s+"\""; /*note: used create dos command*/ string executecmd = ""; executecmd = "c:\\xampp\\mysql\\bin\\mysql -u" + dbuser + " -p" + dbpass + " --database " + dbname + " < " + restorepath; system.out.println(executecmd); process runtimeprocess = runtime.getruntime().exec(executecmd); int processcomplete = runtimeprocess.waitfor(); if (processcomplete == 0) { joptionpane.showmessagedialog(null, "successfully restored sql : " + s); } else { joptionpane.showmessagedialog(null, "error @ restoring"); }

the code executes java swing stuck on runtime command. line outputted system.out.println this.

c:\xampp\mysql\bin\mysql -uroot -proot --database dth < "f:\final year project\final\build\backup\0_harish_2013-02-17-20-05-12.sql"

this line works if re-create , paste in command line. dunno why java swing interface gets stuck in wait state. (the same query takes 2 seconds on cmd , on java have waited 5minutes).

edit: ran streamgobbler , still no benefit, still gives exit value: 1 problem illegalthreadstateexception how can solve this?

edit2:

the gobbling doesnt help hang still exists , heres output of gobbler

class="lang-none prettyprint-override">output>c:\xampp\mysql\bin\mysql ver 14.14 distrib 5.5.27, win32 (x86) output>copyright (c) 2000, 2011, oracle and/or affiliates. rights reserved. output> output>oracle registered trademark of oracle corporation and/or output>affiliates. other names may trademarks of respective output>owners. output> output>usage: c:\xampp\mysql\bin\mysql [options] [database] output> -?, --help display help , exit. output> -i, --help synonym -? output> --auto-rehash enable automatic rehashing. 1 doesn't need utilize output> 'rehash' table , field completion, startup output> , reconnecting may take longer time. disable output> --disable-auto-rehash. output> (defaults on; utilize --skip-auto-rehash disable.) output> -a, --no-auto-rehash output> no automatic rehashing. 1 has utilize 'rehash' output> table , field completion. gives quicker start of output> mysql , disables rehashing on reconnect. output> --auto-vertical-output output> automatically switch vertical output mode if output> result wider terminal width. output> -b, --batch don't utilize history file. disable interactive behavior. output> (enables --silent.) output> --character-sets-dir=name output> directory character set files. output> --column-type-info display column type information. output> -c, --comments preserve comments. send comments server. output> default --skip-comments (discard comments), enable output>

(rest of usage message omitted)

i able solve problem chanding string command string array command. made utilize of gobbler redundant.

java mysql swing

No comments:

Post a Comment