java5 新增线程池的使用

  • u7_193722
    了解作者
  • 23.4KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-14 05:37
    上传日期
NULL 博文链接:https://baobeituping.iteye.com/blog/1399150
androidtcpserver.rar
内容介绍
package com.subsystem.androidtcpserver.subapp.inspection; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.HashMap; import java.util.List; import com.subsystem.androidtcpserver.base.AppBase; import com.subsystem.androidtcpserver.util.Config; import com.subsystem.androidtcpserver.util.DataUtil; import com.subsystem.androidtcpserver.util.PrintUtil; import common.util.database.DataBase; public class Inspection extends AppBase { Connection DBConn = null; PreparedStatement pstm = null; ResultSet RS = null; DataBase db =null; DataBase dataBase = null; @Override public String doAction(List<HashMap<String, String>> list) { String result ="200"; try { if (list.size() != 0) { if(initDB()) { HashMap<String, String> hashMap = list.get(0); String submitButtonFlag = hashMap.get("submit"); String opt = submitButtonFlag.split(";")[1]; String table = submitButtonFlag.split(";")[2]; PrintUtil.printFile("参数:"+opt+" 表名:"+table, Config.INSPECTION_LOG_PATH + DataUtil.getDateYYMMDD() + ".log"); if("search".equals(opt)) { HashMap<String, String> hashMap1 = list.get(1); if("Inspection".equals(table)) { String ECCabinetID = hashMap1.get("ECCabinetID"); result = searchInspection(ECCabinetID); PrintUtil.printFile("查询Inspection返回结果:"+result, Config.INSPECTION_LOG_PATH + DataUtil.getDateYYMMDD() + ".log"); } if("InspectionDetail".equals(table)) { String ECCabinetID = hashMap1.get("ECCabinetID"); result = searchInspection(ECCabinetID); PrintUtil.printFile("查询InspectionDetail返回结果:"+result, Config.INSPECTION_LOG_PATH + DataUtil.getDateYYMMDD() + ".log"); } } if("insert".equals(opt)) { } if("delete".equals(opt)) { } if("deleteinsert".equals(opt)) { if("Inspection".equals(table)) { result = deleteAndInsertInspection(list); PrintUtil.printFile("插入Inspection的返回结果:"+result, Config.INSPECTION_LOG_PATH + DataUtil.getDateYYMMDD() + ".log"); } if("InspectionDetail".equals(table)) { result = deleteAndInsertInspectionDetail(list); PrintUtil.printFile("插入InspectionDetail返回结果:"+result, Config.INSPECTION_LOG_PATH + DataUtil.getDateYYMMDD() + ".log"); } } } else { result = "数据库连接失败!"; } } else { result = "提交数据为空!"; } } catch (Exception e) { e.printStackTrace(); result=e.getMessage(); } return result; } private String deleteAndInsertInspectionDetail( List<HashMap<String, String>> list) { String result = "200"; HashMap<String, String> hashMap1 = list.get(1); String eCCabinetID = hashMap1.get("Fitemid"); String checkerType = hashMap1.get("CheckerType"); String deleteSql = "delete from InspectionDetail where Fitemid=? and CheckerType=?"; String insertSql = "insert into InspectionDetail (fitemid, checkerType, operName, zlwtfl, ABCfl, csgx, zrbm, zlwtms, fsrq, fgsj, clfs, zjr, hjr, mac) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; String insertSql1 = "insert into InspectionDetailLog (fitemid, checkerType, operName, zlwtfl, ABCfl, csgx, zrbm, zlwtms, fsrq, fgsj, clfs, zjr, hjr, mac) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; String deleteLog ="删除INSPECTIONDETAIL:"+"delete from InspectionDetail where Fitemid="+eCCabinetID+" and CheckerType="+checkerType+""; PrintUtil.printFile(deleteLog, Config.INSPECTION_LOG_PATH + DataUtil.getDateYYMMDD() + ".log"); try { DBConn.setAutoCommit(false); this.pstm = DBConn.prepareStatement(deleteSql); this.pstm.setString(1,eCCabinetID); this.pstm.setString(2,checkerType); this.pstm.execute(); this.pstm.close(); this.pstm = DBConn.prepareStatement(insertSql); insertInspectionDetail(list); pstm.close(); this.pstm = DBConn.prepareStatement(insertSql1); insertInspectionDetail(list); this.DBConn.commit(); //this.connection.setAutoCommit(true); } catch (Exception e) { try { this.DBConn.rollback(); } catch (Exception e2) { e2.printStackTrace(); } e.printStackTrace(); PrintUtil.printFile(e.getMessage(), Config.INSPECTION_LOG_PATH + DataUtil.getDateYYMMDD() + ".log"); result = e.getMessage(); } finally{ try { this.dataBase.close(DBConn, pstm, null); } catch (Exception e2) { e2.printStackTrace(); } } return result; } private void insertInspectionDetail(List<HashMap<String, String>> list) throws SQLException { for(int i=1;i<list.size();i++) { HashMap<String, String> map = (HashMap<String, String>)list.get(i); String Fitemid = map.get("Fitemid"); String CheckerType = map.get("CheckerType"); String OperName = map.get("OperName"); String Zlwtfl = map.get("Zlwtfl"); String ABCfl = map.get("ABCfl"); String Csgx = map.get("Csgx"); String Zrbm = map.get("Zrbm"); String Zlwtms = map.get("Zlwtms"); String Fsrq = map.get("Fsrq"); String Fgsj = map.get("Fgsj"); String Clfs = map.get("Clfs"); String Zjr = map.get("Zjr"); String Hjr = map.get("Hjr"); String Mac = map.get("Mac"); pstm.setString(1, Fitemid); pstm.setString(2, CheckerType); pstm.setString(3, OperName); pstm.setString(4, Zlwtfl); pstm.setString(5, ABCfl); pstm.setString(6, Csgx); pstm.setString(7, Zrbm); pstm.setString(8, Zlwtms); pstm.setString(9, Fsrq); pstm.setString(10, Fgsj); pstm.setString(11, Clfs); pstm.setString(12, Zjr); pstm.setString(13, Hjr); pstm.setString(14, Mac); pstm.addBatch(); } pstm.executeBatch(); } private boolean initDB() { boolean flag = true; dataBase = new DataBase(); DBConn = dataBase.getPoolConnection("RSUCustomerService"); if(DBConn == null) { flag = false; } return flag; } private String deleteAndInsertInspection(List<HashMap<String, String>> list) { String result = "200"; HashMap<String, String> hashMap1 = list.get(1); String eCCabinetID = hashMap1.get("ECCabinetID"); String checkerType = hashMap1.get("CheckerType"); String deleteSql = "delete from Inspection where ECCabinetID=? and CheckerType=?"; String insertSql = "insert into Inspection (ECCabinetID,OrderID,Name,Value,Info,Mac,CheckerType,Category,OperName) values (?,?,?,?,?,?,?,?,?)"; String insertSql1 = "insert into InspectionLog (ECCabinetID,OrderID,Name,Value,Info,Mac,CheckerType,Category,OperName) values (?,?,?,?,?,?,?,?,?)"; String deleteLog ="删除INSPECTION:"+"delete from Inspection where ECCabinetID="+eCCabinetID+" and CheckerType="+checkerType+""; PrintUtil.printFile(deleteLog, Config.INSPECTION_LOG_PATH + DataUtil.getDateYYMMDD() + ".log"); try { DBConn.setAutoCommit(false); this.pstm = DBConn.prepareStatement(deleteSql); this.pstm.setString(1,eCCabinetID); this.pstm.setString(2,checkerType); this.pstm.execute(); this.pstm.close(); this.pstm = DBConn.prepareStatement(insertSql); insertInspection(list); pstm.close(); this.pstm = DBConn.prepareStatement(insertSql1); insertInspection(list); this.DBConn.commit(); //this.connection.setAutoCommit(true); } catch (Exception e) { try { result = e.getMessage(); e.printStackTrace(); PrintUtil.printFile(e.getMessage(), Config.INSPECTION_LOG_PATH + DataUtil.getDateYYMMDD() + ".log"); this.DBConn.rollback(); } catch (Exception e2) { e2.printStackTrace(); result = e2.getMessage(); } } finally{ try { this.dataBase.close(DBConn, pstm, null);
评论
    相关推荐
    • CasseBrique:https
      CasseBrique:https
    • 使用socket post 数据到httphttps
      使用socket post 数据到httphttps
    • nodejs http-server开启https的证书
      https证书文件,nodejs http-server开启https的证书,可以直接在本地启动https的协议,方便部署和使用。
    • http https 切换
      http https切换代码,能够实现网站在传输信息的过程中不易遭人盗取
    • Http2Https-crx插件
      将书签中的http转换为https 害怕用https书签替换旧的http书签? 随着许多网站迁移到https,旧的http书签使星标图像为空。 搜索并转换为https! ****************************************************** ***********...
    • LocomotiveCMS https to http-crx插件
      语言:English 将登录网址从https替换为http以进行开发 此扩展程序供使用机车cms开发应用程序时供个人使用。 为了易于在开发模式下使用,此扩展程序将https登录网址替换为http
    • http:https的镜像
      框架HTTP
    • https镜像
      scp镜 SCP基金会部分界面https //
    • CookieIsolator:分离 HTTPHTTPS cookie
      松散隔离:HTTP cookie 只能在 HTTP 通道中发送,而 HTTPS cookie 可以在 HTTP(不带安全标志)和 HTTPS 通道中发送。 严格隔离:HTTP cookie 和 HTTPS cookie 只能分别在 HTTPHTTPS 通道中发送。 Ext Secure...
    • https协议
      NULL 博文链接:https://willwen.iteye.com/blog/1988199