我的空间,写我所写,禅我所藏

与我一起遨游吧

 

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 阅读(572) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿(2)

随笔分类

随笔档案

文章档案

搜索

最新评论

阅读排行榜

评论排行榜