main
黄海 6 months ago
parent 098745d8bc
commit 6aa0763456

@ -23,6 +23,20 @@ public class CommonUtil {
throw new RuntimeException("获取mysqldump路径失败", e);
}
}
/**
* mysql
*/
public static String getMySQLPath() {
try {
String resourcePath = PropKit.get("mysql_path");
if (resourcePath.startsWith("/")) {
resourcePath = resourcePath.substring(1);
}
return java.net.URLDecoder.decode(resourcePath, "UTF-8");
} catch (Exception e) {
throw new RuntimeException("获取mysql路径失败", e);
}
}
/**
* JDBC URL

@ -2,6 +2,7 @@ package com.dsideal.YunXiaoTools.Utils;
import com.jfinal.kit.PropKit;
import com.obs.services.ObsClient;
import java.io.*;
import java.util.zip.*;
@ -26,7 +27,7 @@ public class MysqlRestoreUtil {
this.obsBucket = PropKit.get("obs_bucket_name");
// 目标数据库配置
String jdbcUrl=PropKit.get("write.jdbcUrl");
String jdbcUrl = PropKit.get("write.jdbcUrl");
this.dbHost = CommonUtil.getHostFromJdbcUrl(jdbcUrl);
this.dbPort = CommonUtil.getPortFromJdbcUrl(jdbcUrl);
this.dbUser = PropKit.get("write.user");
@ -36,6 +37,7 @@ public class MysqlRestoreUtil {
/**
*
*
* @param obsKey OBS
*/
public void restore(String obsKey) {
@ -113,7 +115,7 @@ public class MysqlRestoreUtil {
private void restoreDatabase(String sqlFile) {
try {
// 获取mysql命令路径
String mysqlPath = getMySQLPath();
String mysqlPath = CommonUtil.getMySQLPath();
// 构建还原命令
ProcessBuilder pb = new ProcessBuilder(
@ -164,20 +166,4 @@ public class MysqlRestoreUtil {
throw new RuntimeException("还原数据库失败: " + e.getMessage(), e);
}
}
/**
* mysql
*/
private String getMySQLPath() {
try {
String resourcePath = getClass().getClassLoader()
.getResource("mysql.exe").getPath();
if (resourcePath.startsWith("/")) {
resourcePath = resourcePath.substring(1);
}
return java.net.URLDecoder.decode(resourcePath, "UTF-8");
} catch (Exception e) {
throw new RuntimeException("获取mysql路径失败", e);
}
}
}

@ -13,6 +13,8 @@ write.jdbcUrl=jdbc:mysql://10.10.14.203:3306/HuangHai_Test?rewriteBatchedStateme
# mysqldump执行文件位置
mysqldump_path=D:/ffmpeg/mysqldump.exe
# mysql执行文件位置
mysql_path=D:/ffmpeg/mysql.exe
# 当前是读取方还是写入方 1:读取 2写入
DEPLOY_ID=1

Loading…
Cancel
Save