0

I have an application written in JSP running in Apache Tomcat Server and back end is MySQL and m having problem in my code tried many things
like creating a .bat file but dint got a code to run .bat file from jsp page.
Also the following code i tried but not working
______________________________________________________________________

String user = "root";
String password = "root";
String database = "egateway";
String filepath = "e:\\data.sql";

String stmt1 = "mysqldump" + database + "-u" + user + "-p" + password + "- default-character-set = gb2312 - result-file =" + filepath;

try {
Runtime r = Runtime.getRuntime ();
Process p = r.exec(stmt1);
p.waitFor();
out.println ( "data has been exported to the file" + filepath + "successfully nidhish");
}
_____________________________________________________________________

i know how to do it command prompt but how in jsp page dont know please help me

___________________________________________________________
catch(IOException e)
{
e.printStackTrace ();
}

4
Contributors
5
Replies
25
Views
7 Years
Discussion Span
Last Post by itz.aayushi
-1

good, that's such terrible code it should never work.
Even if it were syntactically correct (I didn't even bother to check) it's conceptionally so utterly wrong it should just give up and die.

0

When exporting data out of a MySQL table/database, you should use the following SQL code:

SELECT * 
INTO OUTFILE 'filename/location'
FROM table_name;

My assumption would be to run a statement query execute. In terms of the whole DB at once, im sorry, but im not entirely sure.

0

f you still looking for quick and dirty solution then have look at this http://forums.sun.com/thread.jspa?me...86505#10286505, but if you want to learn something better try Java Butcher (MySQL Backup Engine)

i tried both of your option but still not successfull

and you mentioned java butcher its an jar file can u explain me how can i use it to do the same

pls help me i m still unsuccessful


and i tried the code

>>>>>>>>>>>>>>>>>>>>>>>>>>

try {
            Runtime runtime = Runtime.getRuntime();
            File backupFile = new File("backup/backupScript.sql");
            FileWriter fw = new FileWriter(backupFile);
            Process child = runtime.exec("mysqldump --user=root --password=pass --lock-all-tables --opt db_eonf");
            InputStreamReader irs = new InputStreamReader(child.getInputStream());
            BufferedReader br = new BufferedReader(irs);
            
            String line;
            while( (line=br.readLine()) != null ) {
                fw.write(line + "\n");
            }
            fw.close();
            irs.close();
            br.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }

>>>>>>>>>>>>>>>>>>>>>>>>
but dis is just creating a .sql file and no data is added to it...????
:(

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.