欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

數(shù)據(jù)庫自動備份與手動備份功能的實現(xiàn)

前端代碼:

創(chuàng)新互聯(lián)是一家專業(yè)提供銅川企業(yè)網(wǎng)站建設(shè),專注與網(wǎng)站設(shè)計、成都網(wǎng)站設(shè)計、HTML5建站、小程序制作等業(yè)務(wù)。10年已為銅川眾多企業(yè)、政府機構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站建設(shè)公司優(yōu)惠進(jìn)行中。

function createBackUp(){

var path=$("#path").val();

$.post("dataBack",{

'path' : path

}, function(data) {

if(data==1){

layer.msg("備份成功!",{time: 2000});

}else{

layer.msg("備份失敗,該路徑不存在!",{time: 2000});

}

}, "text");

}

后端實現(xiàn):

package com.cloudshield.toolbox4.accountmanage.controller;

import java.io.File;

import java.io.IOException;

import java.io.InputStream;

import java.net.UnknownHostException;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.text.SimpleDateFormat;

import java.util.Properties;

import java.util.Timer;

import java.util.TimerTask;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;

import org.springframework.context.annotation.Scope;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;

import org.springframework.web.bind.annotation.ResponseBody;

import com.cloudshield.toolbox4.utils.DateUtils;

/**

 * 

 * @XXX

 * @date 2016-10-28 17:24

 *

 */

@Controller

@RequestMapping("/")

@Scope("prototype")

public class DataBackpController {

private static final int BACKUP_SUCCESS=1;/**表示備份成功*/

private static final int BACKUP_ERROR=0;/**表示備份失敗*/

/**手動去備份*/

@ResponseBody

@RequestMapping(value="/dataBack",method = RequestMethod.POST)

public Integer dataBack(HttpServletRequest request,HttpSession session,String time){

Connection conn = null;

try{/**讀取備份路徑*/

String path = request.getParameter("path");

/**讀取配置文件*/

InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("conn.properties");   

       Properties p = new Properties();

       try {   

        p.load(inputStream);   

       } catch (IOException e1) {   

        e1.printStackTrace();  

       } 

       /**獲取用戶名密碼以及路徑*/

       String driverName = p.getProperty("c3p0.driverClass");

       String userName=p.getProperty("c3p0.user");

       String passWord=p.getProperty("c3p0.password");

       String url = p.getProperty("c3p0.jdbcUrl");

       Class.forName(driverName).newInstance();

           conn= DriverManager.getConnection(url,userName,passWord);

           backData(path,getDbName(), conn,time);

           return BACKUP_SUCCESS;

}catch(Exception e){

e.printStackTrace();

          

}finally{

try{conn.close();}catch(Exception e){}

}

return BACKUP_ERROR;

}

/**時間設(shè)置自動備份*/

@ResponseBody

@RequestMapping(value="/setAutoBackUp",method = RequestMethod.POST)

public Integer setAutoBackUp(HttpServletRequest request,HttpSession session){

try{

Timer timer = new Timer();

final String setupstime = request.getParameter("time");

final String path = request.getParameter("path");

TimerTask task =new TimerTask(){

public void run(){

Connection conn = null;

/**讀取配置文件*/

InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("conn.properties");   

Properties p = new Properties();

try {   

p.load(inputStream);  

/**獲取用戶名密碼以及路徑*/

String driverName = p.getProperty("c3p0.driverClass");

String userName=p.getProperty("c3p0.user");

String passWord=p.getProperty("c3p0.password");

String url = p.getProperty("c3p0.jdbcUrl");

Class.forName(driverName).newInstance();

conn= DriverManager.getConnection(url,userName,passWord);

backData(path,getDbName(),conn,setupstime);

} catch (Exception e1) {   

e1.printStackTrace();  

}finally{

try{conn.close();}catch(Exception e){}

}

}

             

};

if(setupstime!=null&&setupstime.equals("oneday")){

timer.scheduleAtFixedRate(task,DateUtils.getOneday(),DateUtils.getOneday());

}

if(setupstime!=null&&setupstime.equals("week")){

timer.scheduleAtFixedRate(task,DateUtils.getWeek(),DateUtils.getWeek());

}

if(setupstime!=null&&setupstime.equals("halfamonth")){

timer.scheduleAtFixedRate(task,DateUtils.getHalfamonth(),DateUtils.getHalfamonth());

}

if(setupstime!=null&&setupstime.equals("onemonth")){

timer.scheduleAtFixedRate(task,DateUtils.getMonth(),DateUtils.getMonth());

}

if(setupstime!=null&&setupstime.equals("halfayear")){

timer.scheduleAtFixedRate(task,DateUtils.getHalfayear(),DateUtils.getHalfayear());

}

if(setupstime!=null&&setupstime.equals("oneyear")){

timer.scheduleAtFixedRate(task,DateUtils.getOneYear(),DateUtils.getOneYear());

}

return BACKUP_SUCCESS; 

}catch(Exception e){

e.printStackTrace();

          

}

return BACKUP_ERROR;

}

/**備份方法*/

public String backData(String path,String db_name,Connection conn,String time) throws Exception{

/**要返回備份名稱*/

String bk_name = "";

        /**與數(shù)據(jù)庫進(jìn)行操作*/

PreparedStatement stmt = null;

        String sql = "";

        try{

        File databasePath = new File(path);

        if(!databasePath.exists()){

       databasePath.mkdir();

       databasePath.setWritable(true);

        }

        String file = new SimpleDateFormat("yyyyMMddHHmmss").format(new java.util.Date())+".bak";

            if(time!=null&&time!=""){

            file="zdbf"+file;

        }

            File newFile=new File(path+File.separator+file);

            newFile.createNewFile();

            newFile.setWritable(true);

            sql = "backup database "+db_name+" to disk=N'"+path+File.separator+file+"' with format,name=N'full backup of "+db_name+"'";

            stmt = conn.prepareStatement(sql);

            stmt.executeUpdate();

            bk_name = file; 

        }catch(Exception e){

            e.printStackTrace();

            throw e;

        }

        finally

        {

        try{stmt.close();} catch(Exception e){}

        }

        return bk_name;

    }

/**獲取要備份的數(shù)據(jù)庫名字*/

public String getDbName(){

/**讀取配置文件*/

InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("other.properties");   

    Properties p = new Properties();

    try {   

    p.load(inputStream);   

    } catch (IOException e1) {   

    e1.printStackTrace();  

    } 

    String dbname=p.getProperty("dbName");

   

    return dbname;

}

/**這里不指定post或者get方式的話,默認(rèn)2中方式都可以*/

@RequestMapping(value = "/autoBackupPage", produces="text/html;charset=UTF-8")

public String autoBackupPage(HttpServletRequest request, HttpServletResponse response) throws UnknownHostException, IOException{

return "jsp/accountManage/backupWindow";

}

/**跳轉(zhuǎn)數(shù)據(jù)備份的主頁面*/

@RequestMapping(value = "/toBackupPage", produces="text/html;charset=UTF-8")

public String toBackupPage(HttpServletRequest request, HttpServletResponse response) throws UnknownHostException, IOException{

return "jsp/accountManage/backUp";

}

}

網(wǎng)站題目:數(shù)據(jù)庫自動備份與手動備份功能的實現(xiàn)
本文網(wǎng)址:http://www.aaarwkj.com/article0/gjjcio.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、電子商務(wù)、靜態(tài)網(wǎng)站響應(yīng)式網(wǎng)站、軟件開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

手機網(wǎng)站建設(shè)
全黄性性激高免费放视频| 欧美一区二区日韩一区二区| 亚洲奇米精品一区二区| 成人性生活三级黄色片| 国产一区二区欧美日本| 日韩亚洲欧美成人一区| 在线视频日韩欧美国产二区| 国产精品一级片免费看| 日本韩国欧美一区在线| 国产精品一区在线免费看| 中文字幕亚洲精品熟女少妇| 欧美日韩国产精品综合| 欧美电影剧情av在线| 亚洲精品天堂av免费看| 亚洲综合成人av在线| 九九热超在线视频精品| 亚洲午夜精品毛片成人| av午夜精品一区二区| 精品一区二区三区乱码中文| 亚洲欧美成人免费视频| 美女丝袜美腿魅惑男人| 国产无套内射三级视频| 九色综合狠狠综合久久| 亚洲国产成人精品av在线| 亚洲精品国产av一区二区三区 | 在线观看视频网站一卡二卡 | 天堂社区人妻在线亚洲| 中文字幕伦理一区二区三区| 亚洲欧美一级二级三级| 果冻国产精品麻豆成人av| 毛片一区二区三区免费看| 日本福利一区二区三区| 国产午夜精品福利爽爽| 免费激情在线视频网址| 中文字幕乱码av一区二区 | 午夜福利影片免费观看| 青青草日韩欧美在线观看| 日本大片在线一区二区三区| 三级精品一区二区三区| 加勒比中文字幕日本道| 成人粉嫩av一区二区白浆|