日期:2014-05-18  浏览次数:20596 次

连接占线导致另一个 hstmt
Java code

<%@ page contentType = "text/html;char=GB2312" %>
<%@ page import = "java.sql.*" %>
<html>
  <body>
    <%
    Connection con;
    Statement sqlq;
    Statement sqlu;
    ResultSet rs;
    try{
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    }
    catch(ClassNotFoundException e){
      out.print("not found1");    
    }

    try{
      con = DriverManager.getConnection("jdbc:odbc:sun", "sa", "12345");
      sqlq = con.createStatement();
      sqlu = con.createStatement();
      rs = sqlq.executeQuery("SELECT * FROM Fscore");
      while(rs.next())
        {
        Date fixture = rs.getDate(4);        
        String hostTeam = rs.getString(5);
        String fullScore = rs.getString(6);
        out.println(fullScore);
        String visitingTeam = rs.getString(8);
        
        String big = "gib";
        String small = "Mall";
        //String big = "大";
        //byte a[] = big.getBytes("ISO-8859-1");
        //big = new String(a);
        //String small = "小";
        //byte b[] = small.getBytes("ISO-8859-1");
        //small = new String(b);

        String fullBulk = rs.getString(11);
        float fullBulkf = Float.valueOf(fullBulk);
        char hostfullScore = fullScore.charAt(0);
        char visitingfullScore = fullScore.charAt(2);
         float hostfullScoref = Float.valueOf(hostfullScore);
        float visitingfullScoref = Float.valueOf(visitingfullScore);
        if((fullBulkf - (hostfullScoref+visitingfullScoref)) > 0.25 )
          {
            String bigOrsmall = "UPDATE Fscore SET finalfullbulk =" + "'" + small + "'" + 
                      "WHERE fixture =" + fixture + " and hostteam = " + "'" +hostTeam + "'" + " and visitingteam = 

" + "'" + visitingTeam + "'";
            out.println(bigOrsmall);
            sqlu.executeUpdate(bigOrsmall);
          }
        else{          
            String bigOrsmall = "UPDATE Fscore SET finalfullbulk =" + "'" + big + "'" + 
                      "WHERE fixture =" + fixture + " and hostteam = " + "'" +hostTeam + "'" + " and visitingteam = 

" + "'" + visitingTeam + "'";
            out.println(bigOrsmall);    
            sqlu.executeUpdate(bigOrsmall);      
             }
        }

      con.close();  
    }
    catch(SQLException e1){
      e1.printStackTrace();
      out.print("not found2");
    }
    %>
  </body>
</html>



error: 连接占线导致另一个 hstmt


------解决方案--------------------
这个问题我也遇到过,开始也是一个statement下两个sql语句,也是报同样的错误,楼主用的odbc桥接吗?最后我没有办法打开两个连接!发送两条语句!