日期:2014-05-18 浏览次数:20896 次
<%@ 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>