修复SQLITE创建表失败问题
This commit is contained in:
parent
2bdda9250c
commit
18cb4236eb
4
pom.xml
4
pom.xml
@ -10,7 +10,7 @@
|
||||
</parent>
|
||||
<groupId>com.yutou</groupId>
|
||||
<artifactId>tools</artifactId>
|
||||
<version>1.0.10.1</version>
|
||||
<version>1.0.10.3</version>
|
||||
<name>tools</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
@ -109,7 +109,7 @@
|
||||
<dependency>
|
||||
<groupId>net.mamoe</groupId>
|
||||
<artifactId>mirai-core-qqandroid</artifactId>
|
||||
<version>1.3.2</version> <!-- 替换版本为最新版本 -->
|
||||
<version>1.3.1</version> <!-- 替换版本为最新版本 -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
|
@ -1,10 +1,7 @@
|
||||
package com.yutou.tools;
|
||||
|
||||
import com.yutou.tools.home.nas.MusicController;
|
||||
import com.yutou.tools.utils.APIFilter;
|
||||
import com.yutou.tools.utils.MusicTools;
|
||||
import com.yutou.tools.utils.QQBotManager;
|
||||
import com.yutou.tools.utils.RedisTools;
|
||||
import com.yutou.tools.utils.*;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
@ -15,10 +12,10 @@ import java.io.IOException;
|
||||
public class ToolsApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("当前版本号:1.0.10.1");
|
||||
System.out.println("当前版本号:1.0.10.3");
|
||||
SpringApplication.run(ToolsApplication.class, args);
|
||||
RedisTools.initRedisPoolSub();
|
||||
if (APIFilter.isDebug) {
|
||||
if (ConfigTools.load(ConfigTools.CONFIG, "model").equals("dev")) {
|
||||
MusicController.defaultMusicPath = "C:\\Users\\admin\\Music\\";
|
||||
MusicTools.getInstance().setMusicPath("C:\\Users\\admin\\Music\\");
|
||||
} else {
|
||||
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.yutou.tools.home.nas.Data.MusicData;
|
||||
import com.yutou.tools.nas.UpdateIp;
|
||||
import com.yutou.tools.utils.APIFilter;
|
||||
import com.yutou.tools.utils.ConfigTools;
|
||||
import com.yutou.tools.utils.MusicTools;
|
||||
import com.yutou.tools.utils.Tools;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
@ -88,7 +89,7 @@ public class MusicController {
|
||||
@ResponseBody
|
||||
public String getLocalHost(){
|
||||
JSONObject json=new JSONObject();
|
||||
if(APIFilter.isDebug){
|
||||
if(ConfigTools.load(ConfigTools.CONFIG, "model").equals("dev")){
|
||||
json.put("data","");
|
||||
}else{
|
||||
json.put("data", "http://"+UpdateIp.nas_ip);
|
||||
|
@ -34,7 +34,7 @@ public class ADSQLiteManager extends SQLiteManager {
|
||||
String sql = "insert into `app_ad` (`appId`,`adSrc`,`adAppId`,`adAppKey`,`adOpenKey`,`adInterKey`,`adBannerKey`,`adVideoKey`,`adNativeKey`,`show`) values " +
|
||||
"('" + appId + "','" + adSrc + "','" + adAppId + "','" + adAppKey + "','" + adOpenKey + "','" + adInterKey + "','" + adBannerKey + "','" + adVideoKey + "','" + adNativeKey + "',1);";
|
||||
boolean flag = statement.execute(sql);
|
||||
statement.close();
|
||||
statement.closeOnCompletion();
|
||||
return flag;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -48,7 +48,7 @@ public class ADSQLiteManager extends SQLiteManager {
|
||||
String sql = "insert into `ad_log` (`appId`,`adSrc`,`adType`,`model`,`subtime`) values ('" + appId + "','" + src + "','" + type
|
||||
+ "','" + model + "','" + System.currentTimeMillis() + "'); ";
|
||||
boolean flag = statement.execute(sql);
|
||||
statement.close();
|
||||
statement.closeOnCompletion();
|
||||
return flag;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -65,7 +65,7 @@ public class ADSQLiteManager extends SQLiteManager {
|
||||
String appId = UUID.randomUUID().toString();
|
||||
String sql = "insert into `app`(`appName`,`packageName`,`appId`) values ('" + appName + "','" + packageName + "','" + appId + "')";
|
||||
statement.execute(sql);
|
||||
statement.close();
|
||||
statement.closeOnCompletion();
|
||||
return appId;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -123,7 +123,7 @@ public class ADSQLiteManager extends SQLiteManager {
|
||||
}
|
||||
}
|
||||
set.close();
|
||||
statement.close();
|
||||
statement.closeOnCompletion();
|
||||
return json;
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ public class ADSQLiteManager extends SQLiteManager {
|
||||
array.add(item);
|
||||
}
|
||||
set.close();
|
||||
statement.close();
|
||||
statement.closeOnCompletion();
|
||||
return array;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -157,7 +157,7 @@ public class ADSQLiteManager extends SQLiteManager {
|
||||
Statement statement=conn.createStatement();
|
||||
String sql="select * from `app` where `appName`='"+appName+"';";
|
||||
json=getApp(statement, sql);
|
||||
statement.close();
|
||||
statement.closeOnCompletion();
|
||||
return json;
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
@ -170,7 +170,7 @@ public class ADSQLiteManager extends SQLiteManager {
|
||||
Statement statement=conn.createStatement();
|
||||
String sql="select * from `app` where `packageName`='"+packageName+"';";
|
||||
json=getApp(statement, sql);
|
||||
statement.close();
|
||||
statement.closeOnCompletion();
|
||||
return json;
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
@ -208,7 +208,7 @@ public class ADSQLiteManager extends SQLiteManager {
|
||||
json.put("packageName",set.getString("packageName"));
|
||||
}
|
||||
set.close();
|
||||
statement.close();
|
||||
statement.closeOnCompletion();
|
||||
return json;
|
||||
}
|
||||
|
||||
|
@ -44,18 +44,25 @@ public class SQLiteManager {
|
||||
|
||||
}
|
||||
private void createSql(JSONObject json){
|
||||
try {
|
||||
sql.mkdirs();
|
||||
sql.delete();
|
||||
conn = DriverManager.getConnection(url + sql.getAbsolutePath());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
startBatch();
|
||||
JSONArray array=json.getJSONArray("table");
|
||||
for (Object o : array) {
|
||||
System.out.println("创建表:"+((JSONObject)o).getString("name"));
|
||||
createSqlOfTable((JSONObject) o);
|
||||
}
|
||||
closeBatch();
|
||||
ConfigTools.save(ConfigTools.SQLITE, json.getString("file"), json);
|
||||
}
|
||||
private void createSqlOfTable(JSONObject table) {
|
||||
String tableName = table.getString("name");
|
||||
try {
|
||||
sql.mkdirs();
|
||||
sql.delete();
|
||||
conn = DriverManager.getConnection(url + sql.getAbsolutePath());
|
||||
Statement statement = conn.createStatement();
|
||||
JSONArray items = table.getJSONArray("item");
|
||||
StringBuilder sql = new StringBuilder();
|
||||
@ -88,7 +95,7 @@ public class SQLiteManager {
|
||||
}
|
||||
sql.append(");");
|
||||
statement.execute(sql.toString().replace(",);", ");"));
|
||||
|
||||
statement.closeOnCompletion();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class APIFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
if(isDebug){
|
||||
if(ConfigTools.load(ConfigTools.CONFIG, "model").equals("dev")){
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user