下面的代码执行的时候总是出现定义的异常,怎么解决
郁闷中~~~~~~~~满意答复必定满分public boolean QueryScoreFunction(String SnoN)
  {//根据学号查询学生的成绩信息
  String str1;
  String score;
  boolean find=false;
  if(ConnectDataBase())//连接数据库(函数已经定义)
  {
  try
  {
  st1=con1.createStatement();
  str1="SELECT* FROM StudentScore WHERE 学号='"+SnoN+"'";
  ResultSet s2=st1.executeQuery(str1);
  while(s2.next())
  {
   find=true;
   score=s2.getString(1)+"\t"+s2.getLong(2)+"\t"+s2.getLong(3)+"\t"
   +s2.getLong(4)+"\t"+s2.getLong(5)+"\t"+s2.getLong(6);
   Student_Score[NowScoreNum]=score;
   }
   Close_database();
   }catch(SQLException e)
        {
    System.out.println("QueryScoreFunction happened error!!!");
        }
   }
   if(find)
   return true;
   else
   return false;
  }

解决方案 »

  1.   

    where's the definition of array Student_Score[] and NowScoreNum ???
      

  2.   

    变量 con1 ,st1,Student_Score,NowScoreNum, 是否都存在?
    ConnectDataBase() 后 con1 是否已经关联?
      

  3.   

    st1
    Student_Score
    NowScoreNum
    这三个是哪里来的呀
    没看到定义呀
      

  4.   

    贴出相关代码:
    class   DataBaseControl
    {       
         private Connection con1;
    private Statement st1;
    ...............
    //类中公有变量类型变量
        public final int MaxNum=10;
        public String Student_Information[]=new String[MaxNum];
        public String Student_Score[]=new String[MaxNum];
        public String[] Database_Score={"学号","英语","高数","C","VC","JAVA"};
    public String[] Database_Information={"学号","姓名","性别","年龄","班级","系别"};
    public int NowScoreNum;
    public int NowInformationNum;
    ..........................
    .....................
    public boolean ConnectDataBase()//连接数据源
    {
    try
    {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    }catch(ClassNotFoundException e)
    {
    System.out.println("Driver not found!");
    return false;
    }   try
      {
    con1=DriverManager.getConnection("jdbc:odbc:学生管理数据库");
      }catch(SQLException e)
      {
    System.out.println("Data Source not found!");
    return false;
     }
      return true;
        }
    .................
     public void Close_database()
       {
       try
       {
       st1.close();
       con1.close();
       }catch(SQLException e)
       {
       System.out.println("Error!!!!");
       }
       }
    ................................
     public boolean QueryScoreFunction(String SnoN)
      {//根据学号查询学生的成绩信息
      String str1;
      String score;
      boolean find=false;
      if(ConnectDataBase())
      {
      try
      {
      st1=con1.createStatement();
      str1="SELECT* FROM StudentScore WHERE 学号='"+SnoN+"'";
      ResultSet s2=st1.executeQuery(str1);
      while(s2.next())
      {
       find=true;
       score=s2.getString(1)+"\t"+s2.getLong(2)+"\t"+s2.getLong(3)+"\t"
       +s2.getLong(4)+"\t"+s2.getLong(5)+"\t"+s2.getLong(6);
       Student_Score[NowScoreNum]=score;
       }
       Close_database();
       }catch(SQLException e)
            {
        System.out.println("QueryScoreFunction happened error!!!");
            }
       }
       if(find)
       return true;
       else
       return false;
      }
    ..................
    ......................
    }
      

  5.   

    异常是:
    QueryScoreFunction happened error!!
      

  6.   

    你把 System.out.println("QueryScoreFunction happened error!!!"); 改为e.printStackTrace(); 将打印出来的信息贴出来