AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

backup database

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> JVM, native methods and hardware
View previous topic :: View next topic  
Author Message
Eveline Franken
Guest





PostPosted: Sat Aug 30, 2003 10:34 am    Post subject: backup database Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> JVM, native methods and hardware All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.