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 ();
}

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.

jwenting


i will be glad if u try to solve it n help me to solve this

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.

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...????
:(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.