at com.mysql.jdbc.jdbc2.Statement.executeQuery(Unknown Source)
at com.codestudio.sql.PoolManStatement.executeQuery把 mysql何它下面所有的文件拷贝到codestudio文件加所在的com文件加中,
让mysql和codestudio同在一个com文件夹中,并且删除mysql原来所在的com
文件加机器里面的所有的东西good luck !

解决方案 »

  1.   

    这种情况,在调用类成员的时候需要指定该成员的完整路径
    如:
    java.util.Date

    java.sql.Date
      

  2.   

    可是那个bean:Publicuser.java的父类DBAction.java是这么写的呀。
    部分代码:
    package com.smartdot.standard;
    import com.codestudio.sql.*;
    import java.sql.*;
    public class DBAction
    {
    public java.sql.Statement Stmt; //SQL语句对象
    public java.sql.PreparedStatement PStmt;
    public java.sql.ResultSet Rs; //结果集对象
    public java.sql.Connection Con;
    public String strCon; //数据库连接字符串
    public String strSQL; //SQL语句
    public String TableName;//描述表名
             .....
            ......
              public void executeQuery(String strSQL) throws    
              SQLException
    {
               Rs=Stmt.executeQuery(strSQL);
              }}其子类也就是调用的bean 的代码:// Java Document
    package com.smartdot.standard;
    import com.smartdot.standard.DBAction;public class  PublicUser extends DBAction
    { //定义变量(与数据库的字段名字一一对应)
    public String TableName="PublicUser";
    public String[] aFieldName;
    public String[] aFieldValue;
    public String UserID;
    public String UserPassword;
    public String NickName;
    public String RealName;
    public int Sex;
    public String Company;
    public String Mobile;
    public String Tel;
    public String Email;
    public String Favor;
    public String Re;
    public String Profile;
    //定义用户登陆成功与否
    public boolean blnLogin;
    //构造函数
    public PublicUser() throws Exception
    {
                    blnLogin=false;
    }
       //检查登陆用户密码的合法性,如果合法就返回true,不合法返会false
          public boolean checkUser(String strUserID,String strPassword) throws Exception
    {
              executeQuery("select * from "+TableName+" where userid="+getString(strUserID)+" and UserPassword="+getString(strPassword));
              if(Rs.next())
              {
                UserID=Rs.getString(1);
                UserPassword=Rs.getString(2);
                NickName=Rs.getString(3);
                RealName=Rs.getString(4);
                Sex=Rs.getInt(5);
                Company=Rs.getString(6);
                Mobile=Rs.getString(7);
                Tel=Rs.getString(8);
                Email=Rs.getString(9);
                Favor=Rs.getString(10);
                Re=Rs.getString(11);
                Profile=Rs.getString(12);
                blnLogin=true;
                return true;
              }
              else
              {
                return false;
              }
    }
    //是否存在此用户
    public boolean existUser(String strUserID) throws Exception
            {
                executeQuery("select * from "+TableName+" where userid="+getString(strUserID));
              if (getRsCounts()==0)
              {
                return false;
              }
              else
              {
                return true;
              }
    }
    }
      

  3.   

    调用这个bean也不是老有问题,有两个页面需要用到此bean,如果一个调用成功了,另一个页面再调用的时候往往失败。神秘,太神秘了。
      

  4.   

    问题可能在DBAction里,把它全发上来看一看.
      

  5.   

    好的 可是特别长,我就怕大家一看就看不下去了,您瞧:
    package com.smartdot.standard;
    import com.codestudio.sql.*;
    import java.sql.*;
    public class DBAction
    {
    public java.sql.Statement Stmt; //SQL语句对象
    public java.sql.PreparedStatement PStmt;
    public java.sql.ResultSet Rs; //结果集对象
    public java.sql.Connection Con;
    public String strCon; //数据库连接字符串
    public String strSQL; //SQL语句
    public String TableName;//描述表名
    public String Condition;//描述条件语句
    public String[] aFieldName;//描述表的字段名
    public String[] aFieldValue;//描述表的字段值
    public int[] aFieldAttribute;//描述字段是不是字符串,是为1,不是为0
    public DBAction() throws Exception
    {
    openDB();
    }
    public DBAction(String strTableName) throws Exception
    {
    TableName=strTableName;
    openDB();
    }
    //打开连接池,建立连接和创建stmt对象。
    public void openDB() throws Exception
    {
    strCon="jdbc:poolman://Testdb";
    Class.forName("com.codestudio.sql.PoolMan").newInstance();
    Con = DriverManager.getConnection(strCon);
    Stmt = Con.createStatement(java.sql.ResultSet.TYPE_SCROLL_SENSITIVE ,java.sql.ResultSet.CONCUR_READ_ONLY); //执行SQL语句
    }
    //增加数据库一条记录
    public void executeAdd(String strTableName,String[] astrFieldName ,String[] astrFieldValue) throws Exception
    {
    String strSQL;
    if (astrFieldName.length==1)
    {
    strSQL="insert into "+strTableName+"("+astrFieldName[0]+") values("+astrFieldValue[0]+")";
    }
    else
    {
    strSQL="insert into "+strTableName+"(";
    //加字段
    for (int i=0;i<astrFieldName.length ;i++ )
    {
    if (i==astrFieldName.length-1)
    {
    strSQL=strSQL+astrFieldName[i];
    }
    else
    {
    strSQL=strSQL+astrFieldName[i]+",";
    }
    }
    strSQL=strSQL+") values(";
    //加字段值
    for (int i=0;i<astrFieldValue.length ;i++ )
    {
    if (i==astrFieldValue.length-1)
    {
    strSQL=strSQL+astrFieldValue[i];
    }
    else
    {
    strSQL=strSQL+astrFieldValue[i]+",";
    }
    }
    strSQL=strSQL+")";
    }
    strSQL=strSQL;
    executeUpdate(strSQL); }
    //修改数据库
    public void executeEdit(String strTableName,String strCondition,String[] astrFieldName ,String[] astrFieldValue) throws Exception
    {
    String strSQL;
    if (astrFieldName.length==1)
    {
    strSQL="update "+strTableName+" set "+astrFieldName[0]+"="+astrFieldValue[0]+" "+strCondition;
    }
    else
    {
    strSQL="update "+strTableName+" set ";
    //加字段
    for (int i=0;i<astrFieldName.length ;i++ )
    {
    if (i==astrFieldName.length-1)
    {
    strSQL=strSQL+astrFieldName[i]+"="+astrFieldValue[i];
    }
    else
    {
    strSQL=strSQL+astrFieldName[i]+"="+astrFieldValue[i]+",";
    }
    } strSQL=strSQL+strCondition;
    }
    strSQL=strSQL;
    executeUpdate(strSQL);
    }
    //执行sql语句
    public void executeUpdate(String strSQL) throws Exception
    { Stmt.executeUpdate(strSQL); }
    //关闭数据库连接
    public void closeDB() throws SQLException
    {
    if (Rs!=null)
            {
    Rs.close();
    }
    if (PStmt!=null)
    {
    PStmt.close();
    }
    if (Stmt!=null)
    {
    Stmt.close();
    }
    if (Con!=null)
    {
    Con.close();
    }
    }
    //用preparestament操作数据库
    public void setPStmt(String strSQL) throws SQLException
    {
    PStmt=Con.prepareStatement(strSQL);
    }
    //数据库查询,并判断返回结果集合的记录数
    //
    public void executeQuery(String strSQL) throws SQLException
    { Rs=Stmt.executeQuery(strSQL);
    }
    //返回记录集合的数
    public int getRsCounts(ResultSet Rs) throws Exception
    {
    int intCounts=1;
    if (Rs.next())
    {
    while (Rs.next())
    {
    intCounts++;
    }
    return intCounts; }
    else
    return 0; }
    //返回类属性Rs记录集合的记录数
    public int getRsCounts() throws Exception
    {
    int intCounts=1;
    if (Rs.next())
    {
    while (Rs.next())
    {
    intCounts++;
    }
    return intCounts; }
    else
    return 0; }
    //记录集指针的移动
    public boolean Move(ResultSet Rs,int intPosition) throws Exception
    {
    Rs.first();
    if (intPosition<=getRsCounts(Rs))
    { for (int i=1;i< intPosition-1; )
    {
    Rs.next();
    }
    return true;
    }
    else
    return false;
    }
    //对类属性Rs记录集指针的移动
    public boolean Move(int intPosition) throws Exception
    {
    Rs.first();
    if (intPosition<=getRsCounts(Rs))
    { for (int i=1;i< intPosition-1; )
    {
    Rs.next();
    }
    return true;
    }
    else
    return false;
    }
    //获得字符串
    public String getString(String strValue)
    {
    if (strValue!=null)
    {
    int i=-2;
    while((i=strValue.indexOf("'",i+2))!=-1)
    {
    strValue=strValue.substring(0,i)+"'"+strValue.substring(i);
    }
    return "'"+strValue+"'";
    }
    else
    {
    return "null";
    } }
    //格式话字段值数组aField,然后把此写成sql语句插入到数据库
    public String[] formatField(String[] astrFieldValue,int[] aFieldAttribute)
    {
    String[] astrTemp=new String[astrFieldValue.length];
    for (int i=0;i<astrFieldValue.length ;i++ )
    {
    if (aFieldAttribute[i]==1)
    {
    astrTemp[i]=getString(astrFieldValue[i]);
    }
    else
    {
    astrTemp[i]=astrFieldValue[i];
    } }
    return astrTemp; }
    //得到表的每个字段的名字
    public boolean getFieldName(String strTableName) throws Exception
    {
    int intCounts=0;
    int i=0;
    String strTemp;
    if (strTableName!=null || strTableName.equals(""))
    { executeQuery("desc "+strTableName);
    while (Rs.next())
    {
    intCounts++; }
    aFieldName=new String[intCounts];
    aFieldValue=new String[intCounts];
    Rs.first();
    do
    {
    aFieldName[i]=Rs.getString(1);
    strTemp=Rs.getString(2);
    if (strTemp.indexOf("text")>=0 || strTemp.indexOf("char")>=0 || strTemp.indexOf("blob")>=0)
    {
    aFieldAttribute[i]=1; }
    else
    {
    aFieldAttribute[i]=0;
    } i++; }
    while (Rs.next()); }
    closeDB();
    return true; }
    //得到表的每个字段的名字参数取类的属性TableName
    public boolean getFieldName() throws Exception
    {
    int intCounts=0;
    int i=0;
    String strTemp;
    if (TableName!=null || TableName.equals(""))
    { executeQuery("desc "+TableName);
    while (Rs.next())
    {
    intCounts++; }
    aFieldName=new String[intCounts];
    aFieldValue=new String[intCounts];
    Rs.first();
    do
    {
    aFieldName[i]=Rs.getString(1);
    strTemp=Rs.getString(2);
    if (strTemp.indexOf("text")>=0 || strTemp.indexOf("char")>=0 || strTemp.indexOf("blob")>=0)
    {
    aFieldAttribute[i]=1; }
    else
    {
    aFieldAttribute[i]=0;
    } i++; }
    while (Rs.next());
    closeDB();
    return true; }
    else
    return false; }
    }
      

  6.   

    以前有个朋友也是Unknown Source
    你可以把这句
    Stmt = Con.createStatement(java.sql.ResultSet.TYPE_SCROLL_SENSITIVE ,java.sql.ResultSet.CONCUR_READ_ONLY); 
    换成:
    Stmt=Con.createStatement();试一下看看.
      

  7.   

    和那个应该没有关系。报的是空指针异常,你看看PoolManStatement.java的第105行,是不是什么变量在用的时候还是空啊
      

  8.   

    晕!!解决了,可要发表一下,学习中。呵呵,我猜是查询string是空的等答案,呵呵
      

  9.   

    对啊,和你刚开始说的那个原因应该没关系。你用new PublicUser()创建的对象,调用的是它自己的方法。如果它没用这个方法,则调用父类的方法。应该不会存在“当前jsp文件到底要用到那一个类中的executeQuery”的事情。
      

  10.   

    我也觉得应该不是那个原因了,因为我已经把它改成了myexecuteQuery了,可是问题依然存在。我真不知怎么办了,大家在帮我看看吧。
      

  11.   

    建议你以后不要所有的方法都这样写:
       throws Exception
    很难调试。看似简单,实际要多做许多事情。
      

  12.   

    暂时看不出来,你可以这样查,看这段出错信息(不是你的出错信息,但你的也应该有):Root Cause:
    java.lang.NullPointerException
    at _0002fRegisterme_0002ejspRegisterme_jsp_1._jspService(_0002fRegisterme_0002ejspRegisterme_jsp_1.java:100)你打开_0002fRegisterme_0002ejspRegisterme_jsp_1.java这个文件,
    这个文件是tomcat将.jsp文件转换成servlet文件后产生的,
    在c:\tomcat\work目录下,然后根据出错的行数(100)看错误出在哪行了。
      

  13.   

    jtzwm(只爱一点点)
      我依照你的方法打开了该文件,可是所告诉我 的出错行只有一个大括号,且并没有大括号不匹配的情形发生。我现在怀疑问题的关键是这一句:
    java.lang.NullPointerException
    可是哪个指针是空的呢?再者,为什么错误有时有,有时没有呢?又为什么重启tomcat,之后又肯定就没问题了呢?
    非常奇怪,非常郁闷。
      

  14.   

    java.lang.NullPointerException最可能的原因还是变量没有正确初始化。我觉得你的问题还是出在数据库连接上了。我以前碰到过这样的问题,
    我也用一个类封装了对数据库的操作,
    可是在servlet中提交对数据库的操作,
    第一次java.lang.NullPointerException,
    刷新一次就可以正确提交。我也百思不得其解,
    后来一个四星高手告诉我,
    在连接字符串(我用SQL Server2000)中加一个参数:
    SelectMethod=cursor;
    就搞定了。你应该往这方面想想。
    不一定是你代码出错了。
      

  15.   

    这个问题最终解决了,不过解决的方法并不是弄清了此问题的根本,而是我干脆改了我的bean,我把父类取消不用了,把数据库连接也放在publicuser中,用Statement.executeQuery(string sql)来代替原来继承过来的executeQuery.
    这样问题是解决了但我觉得还是没有摸清问题的根本。
      不管怎样非常谢谢大家,毕竟在网上看一个问题有些不便,并且我的代码实在有些过长了。呵呵。结贴送分。