下面的代码执行的时候总是出现定义的异常,怎么解决
郁闷中~~~~~~~~满意答复必定满分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;
}
郁闷中~~~~~~~~满意答复必定满分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;
}
解决方案 »
- 一款用javascript实现的轻量级模态框解决方案TinyBox 的问题
- 成员变量和局部变量的作用域问题
- 循环分析,特别是“if(last>pre) flag=false;last=pre; ”这几句。谢过。。。
- 怎么把.txt文件内容导入jtable
- 静态代码段有什么用?
- 客户端Socket如何通过代理连Internet上的server(急)
- 写一个int型的逆排序。例如:123,输出是:321.请问高手怎么写?
- J2SDK升级到1.4.2_05后,数据库连接不上??
- 有关事件监听的简单问题??
- java中怎样读磁盘信息?
- 关于向数据库中插入数据的问题 急 高分 在线等
- 请问java.util包与java.lang包的区别?
ConnectDataBase() 后 con1 是否已经关联?
Student_Score
NowScoreNum
这三个是哪里来的呀
没看到定义呀
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;
}
..................
......................
}
QueryScoreFunction happened error!!