zoukankan      html  css  js  c++  java
  • Java调用DB的存储过程

    2015/12/7
     使用数据库存储过程的java代码:
       try {
                con = (Connection) DBProxy.getConnection(null);
                cStm = con.prepareCall("{call web_show_proc("+("sp".equalsIgnoreCase(showPara[0])?"true":"false")+"," + lmdm + "," + showPara[1] + ")}");
                boolean hadResults = cStm.execute();
                if (hadResults) {
                    rs = cStm.getResultSet();
                    if (rs.next()) {
    //                    nrTemplate = nrTemplate.replaceAll("#bt#", rs.getString("BT")).replaceAll("#fbsj#", rs.getString("FBSJ"))
    //                            .replaceAll("#gjly#", rs.getString("LYZ")).replaceAll("#xxnr#", rs.getString("NR").replaceAll("\^~\^", ""));
    //                    nr.append(nrTemplate);
                       
                    }
                }
                String itemContent = null;
                hadResults = cStm.getMoreResults();
                if (hadResults) {
      //上一篇文章
                    rs = cStm.getResultSet();
                    while (rs.next()) {
                        itemContent = rs.getString("item");
                        itemContent = itemContent.replaceAll("#lm#", webLmAb.get(lm)).replaceAll("#previous#", "上一篇");
                        neighbor.append(itemContent);
                    }
                }
                hadResults = cStm.getMoreResults();
                if (hadResults) {
                    //下一篇文章
                    rs = cStm.getResultSet();
                    while (rs.next()) {
                        itemContent = rs.getString("item");
                        itemContent = itemContent.replaceAll("#lm#", webLmAb.get(lm)).replaceAll("#next#", "下一篇");
                        neighbor.append(itemContent);
                    }
                }
            } catch (Exception e) {
                Logger.logger.error("查询栏目 " + lmdm + " 的信息" + "时,抛错:", e);
            } finally {
                DBProxy.closeDBObject(new Object[]{rs, cStm, con});
            }

  • 相关阅读:
    华为软件开发云评测
    个人技术博客(α)
    结对第二次作业
    结对第一次作业----部门通
    数独设计
    2017软件工程实践第一次作业
    Alpha冲刺博客集
    个人作业——软件工程实践总结作业
    用户使用调查报告
    总结随笔(Beta)
  • 原文地址:https://www.cnblogs.com/itommy/p/10610358.html
Copyright © 2011-2022 走看看