智慧保安后台管理-外网项目备份
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package org.springblade.modules.FTP;
 
 
import org.springblade.common.config.DataSyncConfig;
import org.springblade.common.config.FtpConfig;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
 
import static org.springblade.common.config.FtpConfig.localPath;
 
 
public class MysqlCenlint {
 
    /**
     * 连接mysql数据库 新增
     * @param sql
     */
    public static void inster(String sql) {
        try {
            int ColumnCount;
            //int RowCount;
            String driver = DataSyncConfig.driver;
            //换成要连接的数据库信息
            String url = DataSyncConfig.url;
            String user = DataSyncConfig.username;
            String password = DataSyncConfig.password;
            Class.forName ( driver );
            Connection conn = (Connection) DriverManager.getConnection ( url, user, password );
            if (!conn.isClosed ()) {
                System.out.println ( "数据库连接成功:" );
                //sql
                String sqls = sql;
                PreparedStatement ps = conn.prepareStatement ( sqls );
                boolean execute = ps.execute();
                ps.close ();
                conn.close ();
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace ();
        } catch (SQLException e) {
            e.printStackTrace ();
        }
    }
 
    /**
     * 连接mysql数据库 修改
     * @param sql
     */
    public static void update(String sql) {
        try {
            int ColumnCount;
            //int RowCount;
            String driver = DataSyncConfig.driver;
            //换成要连接的数据库信息
            String url = DataSyncConfig.url;
            String user = DataSyncConfig.username;
            String password = DataSyncConfig.password;
            Class.forName ( driver );
            Connection conn = (Connection) DriverManager.getConnection ( url, user, password );
            if (!conn.isClosed ()) {
                System.out.println ( "数据库连接成功:" );
                String sqls = sql; //sql
                PreparedStatement ps = conn.prepareStatement ( sqls );
                ps.executeUpdate();
                ps.close ();
                conn.close ();
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace ();
        } catch (SQLException e) {
            e.printStackTrace ();
        }
    }
 
    /**
     * 连接mysql数据库 删除
     * @param sql
     */
    public static void delete(String sql) {
        try {
            int ColumnCount;
            //int RowCount;
            String driver = DataSyncConfig.driver;
            //换成要连接的数据库信息
            String url = DataSyncConfig.url;
            String user = DataSyncConfig.username;
            String password = DataSyncConfig.password;
            Class.forName ( driver );
            Connection conn = (Connection) DriverManager.getConnection ( url, user, password );
            if (!conn.isClosed ()) {
                System.out.println ( "数据库连接成功:" );
                String sqls = sql; //sql
                PreparedStatement ps = conn.prepareStatement ( sqls );
                ps.executeUpdate();
                ps.close ();
                conn.close ();
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace ();
        } catch (SQLException e) {
            e.printStackTrace ();
        }
    }
 
//    /**
//     * 删除本地文件
//     */
//    public  static  void deletes(String fileName){
//        File file = new File("D:\\"+fileName);
//        if (file.isFile() && file.exists()) {
//            file.delete();
//        }
//    }
    public  static  void deletess(String fileName){
        File file = new File(localPath+fileName);
        if (file.isFile() && file.exists()) {
            file.delete();
        }
    }
}