Sqlserver2000 backup database

Source: Internet
Author: User

Public Boolean bankupdatabase (string filepath) throws exception {
Dbmanager DB = dbmanager. getinstance ();
String qrysql = "use master select count (phyname) CNT from Master .. sysdevices where name = \ 'backupbank \'";
Resultset rs = db.exe cutequery (qrysql );
While (Rs. Next ()){
If (Rs. getint ("CNT")> 0 ){
String SQL = "use master exec sp_dropdevice \ 'backupbank \'";
Preparedstatement pstmt = dB. getcon (). preparestatement (SQL );
Pstmt.exe cuteupdate ();
}
}

String SQL = "use master" +
"Exec sp_addumpdevice \ 'disk \ ', \ 'backupbank \', \ '" + filepath + "\'" +
"Backup database bank to backupbank ";
Try {
File file = new file (filepath );
If (file. exists ()){
File. Delete ();
}
Preparedstatement pstmt = dB. getcon (). preparestatement (SQL );
Pstmt.exe cuteupdate ();
} Catch (exception e ){
E. printstacktrace ();
Return false;
}
Return true;
}

Use master

Exec sp_addumpdevice 'disk', 'backupban', 'd: \ backup \ bank. dat'

Backup database bank to backupbank

Use master
Select count (phyname) from Master .. sysdevices where name = 'backupbank'

Use master
Exec sp_dropdevice 'backupbank'

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.