try{
  Connection conn=mytools.getConn();
      //Statement st=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
      Statement st=conn.createStatement();
  String sql="select * from Strainlib_Chip where Strain_ID like 'hs001a%' order by Strain_ID ASC";
  ResultSet rs=st.executeQuery(sql);
      ResultSetMetaData rsmd = rs.getMetaData();
  if (rs.isLast())
          System.out.println("OK");
        else
        System.out.println("false");
}catch (SQLException ex){
      System.out.println("error");
    }
---------------------------------------
系统始终抛出SQLException异常,我该怎么做?

解决方案 »

  1.   

    你应该输出SQLException的异常栈才能跟踪错在那里
    因为里面的很多调用都要SQLException产生的
      

  2.   

    应该这么写:
    Statement st=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
      

  3.   

    SQLException的异常栈信息:
    This JDBC 2.0 method is not implemented
      

  4.   

    java.sql.SQLException: This JDBC 2.0 method is not implemented
            at weblogic.jdbc.mssqlserver4.TdsConnection.createStatement(TdsConnectio
    n.java:539)
            at example.main(example.java:19)
      

  5.   

    看了你的程序,觉得api的使用没有问题,估计不是ResultSet自动关闭造成的SQLException! 先改改程序:
        ....
        } catch (SQLException ex){
          System.out.println("error");
          System.out.println(ex.getMessage());//看看是什么东东
          ex.printStackTrace();//看看到底是那一句出了异常
        }ResultSet总是跟产生它的Statement有关联,只有当Statement关闭close或重新执行或检索后面的ResultSet时,当前ResultSet才自动关闭。你的程序里没有上面列举的行为!其实,现在很多数据库JBDC Driver都很健壮,当语句Statement执行insert或update等非查询行为时,当前ResulstSet也常常不自动关闭。所以,我的经验是,一个Statement在同一时刻只能维持一个ResultSet!
      

  6.   

    呵呵,慢了一拍儿
    看来你的Driver比较落伍,只支持用一般的语句
    Statement st=conn.createStatement();
    它肯定支持了,要不然.....faint
      

  7.   

    Statement st=conn.createStatement();
    我用了,系统除了能执行rs.next()外,First(), Last()等等都报异常!
    是不是我的开发环境有问题?
    weblogic7.0, SQLServer2000, JDK1.3
      

  8.   

    1.多次使用ResultSet:
    可以实现Clonable2.SQLException:
    该驱动没有实现这些方法,所以不能用,试试看其他的
      

  9.   

    whiteshen(White Shen) 可否说得清楚些,
    给个example.
      

  10.   

    系统始终抛出SQLException异常,是因为你用了(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE)(敏感滚动)
    若你的JDBC驱动程序不支持“敏感滚动”;
      

  11.   

    Statement st=conn.createStatement();
    我用了,系统除了能执行rs.next()外,First(), Last()等等都报异常!
    是不是我的开发环境有问题?
    weblogic7.0, SQLServer2000, JDK1.3
    绝对是JDBC驱动程序不支持,取消"敏感滚动",只用next()即可,不然重新下载
    JDBC 2.0以上的驱动程序
      

  12.   

    呵呵,你的driver不支持JDBC2.0以上 api,所以first()或last()什么的都没的用了!有三个选择:
    1,更换高级的driver,使用JDBC2.0以上api
    2,降低需求,避免使用JDBC2.0以上api
    3,到java.sun.com去当rowset.jar,这样可以把结果集缓存到CachedRowSet里,部分的解决问题
      

  13.   

    //there are a few steps you have to do before you can run and test 
    //the following code, hope it will give a basic idea
    //the code below will use JDBC to connect to your data source 
    //read ALL the data inside and print out in you console window
    //IF YOU CAN GET THIS JOB DONE I THINK YOU WILL ABTAIN A LOT!!
    //step1
    //use microsoft Access to create a table named BOOKS.//step2
    //establish a data source naemed "BooksInfoODBC"(quote not include)
    //if you don't how to create a data source in you computer, 
    //check with your frieds//step 3
    //create a java class and run the following codeimport java.io.*;
    import java.sql.*;public class Test1 {
      public static void main(String[] args) {
        try {
          // loads the jdbc odbc bridge driver
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        }
        catch (ClassNotFoundException e) {
          System.err.println("Error" + e) ;
        }
        try {
          // establish db connection through a Connection object
          Connection con =  DriverManager.getConnection("jdbc:odbc:BooksInfoODBC") ;      // instance of a sql statement
          Statement stmt = con.createStatement();      // prepare sql statement
          String sqlStr = "SELECT * FROM BOOKS";      // execute the SELECT query through executeQuery()
          // save the result in ResultSet
          ResultSet rs = stmt.executeQuery(sqlStr);      // process the result of the ResultSet
          System.out.println(" the records selected are");
          ResultSetMetaData info = rs.getMetaData();      while (rs.next()) {
            for (int i=1; i<=info.getColumnCount(); i++) {
              System.out.print("\t" + rs.getString(i));
            }
            System.out.println();
          }      // close the ResultSet, Statement and Connection objects
          rs.close();//************************************************
          stmt.close();//**********************************************
          con.close();//***********************************************
        }
        catch (SQLException e) {
          System.err.println("Error " + e);
        }
      }
    }//disable the codes with star. i mean, do not 
    //close your resultset,your statement,you connetion
    //before you really want to quit, then you can use the
    //resultset as many times as possible before you run 
    //the code with star sign
      

  14.   

    another way is you can use Microsoft J++6.0 to make you class as a COM object and output you class as .DLL file, this .dll file will be registerd on your computer. and of course you can use it as many times as possible.