mirror of
https://github.com/Hello-hao/Tbed.git
synced 2026-09-20 03:18:28 +00:00
:fire:修复部分问题
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package cn.hellohao.utils;
|
||||
|
||||
import cn.hellohao.config.GlobalConstant;
|
||||
import cn.hutool.core.io.FileUtil;import org.slf4j.Logger;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -106,10 +108,13 @@ public class FirstRun implements InitializingBean {
|
||||
Print.Normal("Add table.appclient");
|
||||
}
|
||||
Integer isconfdata = RunSqlScript.RunSelectCount(isTableName+"'confdata'");
|
||||
String isdata = RunSqlScript.RunSelectCountForString("select * from confdata where `key`='config'",2);
|
||||
if(isconfdata==0){
|
||||
RunSqlScript.RunInsert(createConfdata);
|
||||
RunSqlScript.RunInsert(instartConfdata);
|
||||
Print.Normal("Add table.confdata");
|
||||
}else if(StringUtils.isBlank(isdata)){
|
||||
RunSqlScript.RunInsert(instartConfdata);
|
||||
}
|
||||
Integer ret7 =
|
||||
RunSqlScript.RunSelectCount(judgeTable + " 'keys' and column_name = 'SysTransmit'");
|
||||
|
||||
@@ -63,6 +63,55 @@ final class RunSqlScript {
|
||||
return count;
|
||||
}
|
||||
|
||||
public static String RunSelectCountForString(String sql,int columnIndex) {
|
||||
String count = null;
|
||||
//数据库连接对象
|
||||
Connection conn = null;
|
||||
//数据库操作对象
|
||||
Statement stmt = null;
|
||||
//1、加载驱动程序
|
||||
try {
|
||||
Class.forName(DBDRIVER);
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//2、连接数据库
|
||||
//通过连接管理器连接数据库
|
||||
try {
|
||||
//在连接的时候直接输入用户名和密码才可以连接
|
||||
conn = DriverManager.getConnection(DBURL,USERNAME,PASSWORD);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//3、向数据库中插入一条数据
|
||||
//String sql = "select count(*) from information_schema.columns where table_name = 'config' and column_name = 'id'";
|
||||
try {
|
||||
stmt = conn.createStatement();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//4、执行语句
|
||||
try {
|
||||
//stmt.executeUpdate(sql);
|
||||
ResultSet resultSet = stmt.executeQuery(sql);
|
||||
if(resultSet.next()){
|
||||
//columnIndex是获取第几列的值 1开始
|
||||
count = resultSet.getString(columnIndex);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
//5、关闭操作
|
||||
try {
|
||||
stmt.close();
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
//insert操作
|
||||
public static Integer RunInsert(String sql) {
|
||||
|
||||
Reference in New Issue
Block a user