你先换成:
String SQL = "select * from user where name ='oneman'";
ResultSet rs = null;
Statement stmt;
stmt = conn.createStatement();
试验一下,如果还是不行,那就是数据库没有连接成功。
这种情况多数是数据库没连接成功。

解决方案 »

  1.   

    conn你是在那得到的,可能就没有得到conn,才会这样
      

  2.   

    1。有可能是未连接
    2。Statement创建的时候参数不对
    stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
      

  3.   

    Statement创建的时候参数不对
    正确的:stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
      

  4.   

    rs = stmt.executeQuery(sql); ?
    应该是
    rs = stmt.executeQuery(SQL); 吧检查你是否真的连接到数据库
      

  5.   

    同意楼上的
    另外
    "select * from user where name ='oneman'";oneman 是变量还是常量啊如果是变量改成下面这样试一下
    "select * from user where name ='"+oneman+"'";
      

  6.   

    本来这是一个过程调用,我把它整合在一起好请教大家,String SQL可改为String sql.
    原来是"select * from user where name ='"+oneman+"'";我把它改为"select * from user where name ='oneman'",道理一样的
    关键是为什么抛出NullPointerException异常.在这前面曾执行这样的查询没问题,后来查询另一个用户的情况时便这样了.
    conn这个连接是保存在public static Connection conn中.我试过改为用stmt = conn.createStatement();没有问题
      

  7.   

    //因为
    String SQL = "select * from user where name ='oneman'";
    …………
    //所以
    rs = stmt.executeQuery(SQL);