主要看数据库支持不支持,和jsp本身无关.

解决方案 »

  1.   

    也有可能是你的语法写错了.最好把sql语句和错误提示都贴出来,否则没法帮你.
      

  2.   

    语法应该没错,SQL Server 2000数据库,win2000 server平台。在查询分析器中执行没有错误,一点错误都没有,很简单的一条语句。
     String sql="select MAX(id) AS [ID] from KPIsort";
     ResultSet rs=stmt.executeQuery(sql); 其他语句都没有错,就是用到聚合函数,如SUM\MAX\MIN就会报javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]? 'T_kpisort.KSort_ID' ??????????????????????????? GROUP BY ???错误
      

  3.   

    将sql语句在查询分析器运行看有没有错先
      

  4.   

    明显就不是这句的错误 !!
    javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]? 'T_kpisort.KSort_ID' ??????????????????????????? GROUP BY ???你的SQL中哪里有KSort_ID??!!!
    定位好你的错误行号!
      

  5.   

    不好意思,表结构改了一下。还是错。改为ID和KPIsort了,在查询分析器运行一点错误没有
      

  6.   

    终于找到原因了,原来是游标的原因Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
    就不能使用sum,min,max,distinct等聚合函数Statement stmt=conn.createStatement();
    就可以使用聚合函数
      

  7.   

    呵呵.. createStatement()后面括号那串东西本来就没必要写.
      

  8.   

    createStatementpublic Statement createStatement(int resultSetType,
                                     int resultSetConcurrency)
                              throws SQLExceptionCreates a Statement object that will generate ResultSet objects with the given type and concurrency. This method is the same as the createStatement method above, but it allows the default result set type and concurrency to be verridden. Parameters:
      resultSetType - a result set type; one of ResultSet.TYPE_FORWARD_ONLY,
    ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
    resultSetConcurrency - a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE Returns:a new Statement object that will generate ResultSet objects with the given type and concurrency Throws: SQLException - if a database access error occurs or the given parameters are not ResultSet constants indicating type and concurrencySince: 
    1.2