在这句的前面加一句
rs.next();

解决方案 »

  1.   

    安全点的话先判断
    rs.next()!=null
      

  2.   

    可以这样啊:String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
     String sConnStr = "jdbc:odbc:bmanager";
     String sLogin = "sa";
     String sPassword = "282708";
         String sql;
        Connection conn = null;
        ResultSet rs = null;
        Statement stmt;
     try{
       Class.forName(sDBDriver);
      }catch(ClassNotFoundException e){System.out.println(e);}
     try{
        sql="select * from systypes";
      Class.forName(sDBDriver);
      conn = DriverManager.getConnection(sConnStr, sLogin, sPassword);
          stmt = conn.createStatement();
      rs = stmt.executeQuery(sql);
               rs.next();
      String name=rs.getString("name");
      rs.close();
                  stmt.close();
              conn.close(); }catch(SQLException e){System.out.println(e);}