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

          與我一起遨游吧

           

          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)  編輯  收藏


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


          網(wǎng)站導(dǎo)航:
           

          導(dǎo)航

          統(tǒng)計

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 宣恩县| 新建县| 衢州市| 周宁县| 红原县| 墨竹工卡县| 社旗县| 鄱阳县| 交城县| 武义县| 大宁县| 大足县| 广东省| 蒙城县| 金塔县| 内江市| 公主岭市| 临漳县| 西华县| 定州市| 博兴县| 屏东市| 闽清县| 安岳县| 房产| 静安区| 泌阳县| 虞城县| 普定县| 甘德县| 满城县| 原平市| 保德县| 太谷县| 拜城县| 九龙坡区| 巫山县| 永丰县| 西乌珠穆沁旗| 满洲里市| 司法|