/**Process the HTTP Get request*/
  public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String type=request.getParameter("RType");
String perd=request.getParameter("RPerd"); DataOutputStream out=new DataOutputStream(response.getOutputStream());
//ObjectOutputStream out1=new ObjectOutputStream(response.getOutputStream()); try{
  SqlAccess conn=new SqlAccess();
  //取当前时间
  java.util.Date now=new java.util.Date();
  SimpleDateFormat sd=new SimpleDateFormat("yyyy/MM/dd");
  String nowStr=sd.format(now);
  //只查询已启用的利率
  String sqlStr="SELECT S_Serial,C_Rate,I_Deadline,F_Rate FROM P_RATE";
  sqlStr+=" WHERE d_begindate<date('"+nowStr+"') AND (d_enddate IS NULL OR d_enddate>date('"+nowStr+"'))";
  if(type!=null&&perd!=null)
sqlStr+=" AND C_RateType="+type+" AND I_Deadlint<"+perd;
  sqlStr+=" ORDER BY I_Deadline";
  //-----
  //System.out.println(sqlStr);
  //-----
  ResultSet rst=conn.queryselect(sqlStr);
  if(rst!=null){
//写查询成功标志
out.writeBoolean(true);
while(rst.next()){
  out.writeUTF(rst.getString("S_Serial"));
  //-----
  //System.out.println("S_Serial:"+rst.getString("S_Serial"));
  //-----
  out.writeUTF(rst.getString("C_Rate"));
  //-----
  //System.out.println("C_RateType:"+rst.getString("C_Rate"));
  //-----
  out.writeInt(rst.getInt("I_Deadline"));
  //-----
  //System.out.println("I_ Deadline:"+rst.getString("I_Deadline"));
  //-----
  out.writeFloat(rst.getFloat("F_Rate"));
  //-----
  //System.out.println("F_Rate:"+rst.getString("F_Rate"));
  //-----
}
  }
  else
out.writeBoolean(false);
  out.close();
  }catch(SQLException exp){
  exp.printStackTrace();
  out.writeBoolean(false);
  out.close();
  }
  }    请看原玛,多多指教!

解决方案 »

  1.   

    你这段代码根本就没有释放connection呀???什么意思???
      

  2.   

    对不起哟,
    finally{
      conn.close;
      conn=null;
    }是我后来加进去的,但是还是有这样的问题啊??不明白!
      

  3.   

    finally{
    System.out.println("正在释放连接");
    try{
    conn.close();
    }catch(SQLException e){
      System.out.println("连接释放时出现问题:" + e);
    }
    conn=null;
    }
      

  4.   

    嘿嘿,我又按你的方法做了一次,发现有打印东西出来,好象是说sql的date有问题,正在找?多谢!
      

  5.   

    郁闷,怎么没人响应了,看来我大年都不能睡好觉了,因为必须给银行生产环境重起SERVER???!!
      

  6.   

    "好象是说sql的date有问题"你就不能说明白点吗?
    把异常贴出来得了。。我这句你查查看我说了多少次了
      

  7.   

    建议使用显式的关闭conn.不要用finally.这个和垃圾回收有关,不一定会立即执行.同时建议先关闭resultset