Commit 2c0e85e6 by hxw2303632

正确关闭sql连接

parent bccbf33e
...@@ -124,12 +124,19 @@ public class ChatCacheController { ...@@ -124,12 +124,19 @@ public class ChatCacheController {
opFlag = helper.insertArchiveInfo(archiveName, userKey, site); opFlag = helper.insertArchiveInfo(archiveName, userKey, site);
if(destroy) if(destroy) {
helper.destroy(); helper.destroy();
destroy = false;
}
} catch (Exception e) { } catch (Exception e) {
System.out.println("游戏存档时发生异常"); System.out.println("游戏存档时发生异常");
opFlag = false; opFlag = false;
}finally{
if(helper != null && destroy){
helper.destroy();
}
} }
return opFlag; return opFlag;
...@@ -239,7 +246,7 @@ public class ChatCacheController { ...@@ -239,7 +246,7 @@ public class ChatCacheController {
String fileDir = System.getProperty("user.dir") + "/ChatCache"; String fileDir = System.getProperty("user.dir") + "/ChatCache";
Boolean findFlag = false; Boolean findFlag = false;
SqlHelper helper; SqlHelper helper = null;
Map<String, String> infoPoints = new HashMap<String, String>(); Map<String, String> infoPoints = new HashMap<String, String>();
try { try {
...@@ -273,7 +280,7 @@ public class ChatCacheController { ...@@ -273,7 +280,7 @@ public class ChatCacheController {
System.out.println("sql:" + userKey); System.out.println("sql:" + userKey);
archiveInfo = helper.queryUserLastGameArchive(userKey); archiveInfo = helper.queryUserLastGameArchive(userKey);
helper.destroy();
findFlag = (archiveInfo != null); findFlag = (archiveInfo != null);
} }
...@@ -281,6 +288,8 @@ public class ChatCacheController { ...@@ -281,6 +288,8 @@ public class ChatCacheController {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
findFlag = false; findFlag = false;
} finally{
helper.destroy();
} }
System.out.println("finalFlag" + findFlag); System.out.println("finalFlag" + findFlag);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment