Backup.java
上传用户:u_thks
上传日期:2022-07-31
资源大小:1910k
文件大小:2k
- /*
- * Created on 2005-9-24
- * Made In GamVan
- */
- package com.gamvan.sql;
- import java.sql.Connection;
- import java.sql.SQLException;
- import java.sql.Statement;
- public class Backup {
-
- private String filePath = "";
- private String fileName = "";
- private String message = "";
- /**
- * MS SQL SERVER备份
- * @param con
- * @param stmt
- * @param dbName 备份文件名自动按天备份
- * @param filePath 备份文件存放绝对路径
- */
- public boolean sqlServerBackup(Connection con, Statement stmt, String dbName){
- boolean bea = true;
- String sql = "BACKUP DATABASE ["+dbName+"] TO DISK = N'";
- sql += filePath + fileName;
- sql += "' WITH NOINIT , NOUNLOAD , NAME = N'lvdong', NOSKIP , STATS = 10, NOFORMAT";
- try {
- stmt = con.createStatement();
- stmt.executeUpdate(sql);
- }catch(SQLException e) {
- bea = false;
- e.printStackTrace();
- message = e.toString();
- }
- finally{
-
- }
- return bea;
- }
-
-
-
-
-
- public String getMessage() {
- return message;
- }
- public String getFileName() {
- return fileName;
- }
- public void setFileName(String fileName) {
- this.fileName = fileName;
- }
- public String getFilePath() {
- return filePath;
- }
- public void setFilePath(String filePath) {
- this.filePath = filePath;
- }
- /**
- public static void main (String args[]){
- Backup bu = new Backup();
- try {
- bu.backup("GVcompany", "E:\");
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- */
- }