From 568025796c345fe0fdb7daf90b0d0f01f73ab9fc Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Sat, 21 Aug 2021 09:19:30 +0800
Subject: [PATCH] 1.ftp
---
src/main/java/org/springblade/modules/FTP/MysqlCenlint.java | 108 ++++++++++++++++++++++++++++++++++++
src/main/java/org/springblade/modules/information/controller/InformationController.java | 43 +++++++-------
2 files changed, 130 insertions(+), 21 deletions(-)
diff --git a/src/main/java/org/springblade/modules/FTP/MysqlCenlint.java b/src/main/java/org/springblade/modules/FTP/MysqlCenlint.java
new file mode 100644
index 0000000..86f4a22
--- /dev/null
+++ b/src/main/java/org/springblade/modules/FTP/MysqlCenlint.java
@@ -0,0 +1,108 @@
+package org.springblade.modules.FTP;
+
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+public class MysqlCenlint {
+
+ /**
+ * 连接mysql数据库 新增
+ * @param sql
+ */
+ public static void inster(String sql) {
+ try {
+ int ColumnCount;
+ //int RowCount;
+ String driver = "com.mysql.jdbc.Driver";
+ String url = "jdbc:mysql://223.82.109.183:2083/zhba"; //换成要连接的数据库信息
+ String user = "root";
+ String password = "zhba0728";
+ 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 );
+ 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 = "com.mysql.jdbc.Driver";
+ String url = "jdbc:mysql://223.82.109.183:2083/zhba"; //换成要连接的数据库信息
+ String user = "root";
+ String password = "zhba0728";
+ 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 = "com.mysql.jdbc.Driver";
+ String url = "jdbc:mysql://223.82.109.183:2083/zhba"; //换成要连接的数据库信息
+ String user = "root";
+ String password = "zhba0728";
+ 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 delete(){
+ File file = new File("D:\\anbao\\sql.json");
+ if (file.isFile() && file.exists()) {
+ file.delete();
+ }
+ }
+}
diff --git a/src/main/java/org/springblade/modules/information/controller/InformationController.java b/src/main/java/org/springblade/modules/information/controller/InformationController.java
index 6c6a05e..2d14353 100644
--- a/src/main/java/org/springblade/modules/information/controller/InformationController.java
+++ b/src/main/java/org/springblade/modules/information/controller/InformationController.java
@@ -335,27 +335,28 @@
}
-// public static void main(String[] args) throws Exception {
-// //ftp服务器IP地址
-// String ftpHost = "192.168.0.105";
-// //ftp服务器端口
-// int ftpPort = 21;
-// //ftp服务器用户名
-// String ftpUserName = "yly";
-// //ftp服务器密码
-// String ftpPassword = "Yly@123";
-// //ftp服务器路径
-// String ftpPath = "anbao/sql.json";
-// //本地路径
-// String localPath = "D:\\anbao";
-// //文件名
-// String fileName = "sql.json";
-//// FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName);
-// String s = OutJson.TestJson();
-// System.out.println(s);
-// //boolean ftpFileExist = FtpUtil.isFTPFileExist(ftpPath, ftpUserName, ftpPassword, ftpHost, ftpPort);
-// //System.out.println(ftpFileExist);
-// }
+ public static void main(String[] args) throws Exception {
+ //ftp服务器IP地址
+ String ftpHost = "192.168.0.105";
+ //ftp服务器端口
+ int ftpPort = 21;
+ //ftp服务器用户名
+ String ftpUserName = "yly";
+ //ftp服务器密码
+ String ftpPassword = "Yly@123";
+ //ftp服务器路径
+ String ftpPath = "anbao/sql.json";
+ //本地路径
+ String localPath = "D:\\anbao";
+ //文件名
+ String fileName = "sql.json";
+// FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName);
+ String s = OutJson.TestJson();
+ String sql = OutJson.stringReplace(s);
+ System.out.println(sql);
+ //boolean ftpFileExist = FtpUtil.isFTPFileExist(ftpPath, ftpUserName, ftpPassword, ftpHost, ftpPort);
+ //System.out.println(ftpFileExist);
+ }
--
Gitblit v1.9.3