我的空間,寫我所寫,禪我所藏

          與我一起遨游吧

           

          JDBC通用的查詢方法。


          formId查詢的條件字段,tableName是表名,fieldName要查詢的字段  


          private static String getValue(String formId,String tableName,String fieldName)throws WfException{
                 Connection con = DbConnectionManager.getInstance().getConnection(
                                            poolName);
                            Statement st = null;
                            String value = null;
                            try {
                                    st = con.createStatement();
                                    String iSql = "select "+fieldName+" from "+tableName+" where applyid='"+formId+"'";
                                    ResultSet rs = st.executeQuery(iSql);
                                    if (rs.next()) {
                                       value = rs.getString(1);
                                    }
                            } catch (Exception e) {
                                throw new WfException(ErrorInfo.EXT_PROC_MANAGER_ERROR,"獲取值失敗!",
                                              ErrorInfo.getTrace(e, e.getStackTrace()));
                            } finally {
                                DbConnectionManager.getInstance().freeConnection(poolName, con);
                            }
                            return value;

             }

          posted on 2007-06-25 14:49 imcb 閱讀(574) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          導航

          統計

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 简阳市| 隆回县| 咸丰县| 栾川县| 青龙| 昌黎县| 平果县| 棋牌| 雅江县| 哈密市| 璧山县| 图木舒克市| 北宁市| 景德镇市| 汶川县| 平江县| 通州市| 汽车| 揭西县| 锦州市| 巨鹿县| 铜梁县| 治县。| 临汾市| 龙口市| 那坡县| 军事| 休宁县| 建水县| 隆尧县| 涡阳县| 抚州市| 邯郸县| 元氏县| 马公市| 昂仁县| 巴南区| 曲周县| 北碚区| 铜陵市| 阜新|