 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Eveline Franken Guest
|
Posted: Sat Aug 30, 2003 10:34 am Post subject: backup database |
|
|
Hi,
I have an application that connects with a mysq-database.
I wrote a file in wich I can backup a table from de database. I can't
however backup the entire database at ones. this is te code I have so far.
package backup;
import java.sql.*;
/**
* @author Eveline Franken
*
* To change this generated comment edit the template variable
"typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class Lock {
Lock()
{
try
{ //connection db
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost/camping");//, "eveline",
"franken");
//Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost/camping","javauser","jav
apass");
Statement stmt = conn.createStatement();
//lock tables
String flush = "FLUSH TABLES WITH READ LOCK ";
System.out.println(flush);
int rs = stmt.executeUpdate(flush);
System.out.println(rs);
Statement stmt2 = conn.createStatement();
String back = "BACKUP TABLES back TO 'H://back'"; //this
works
//back = "mysqlhotcopy camping 'H://backup'";
// this is what I want to work
int rs9 = stmt2.executeUpdate(back);
System.out.println(rs9);
// unlock tables
Statement stmt3 = conn.createStatement();
String weglokje = "UNLOCK TABLES";
int rs2 = stmt3.executeUpdate(weglokje);
System.out.println(rs2);
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
new Lock();
}
}
I hope anyone can help. Thanks in advance, Eveline
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|