有关数据库的问题,有高手帮忙执行一下有什么错误啊。。
import java.sql.*;
import java.util.*;
public class Student {
private String name;
private String sex;
private String zhuanye;
private int age;
private String number;
public static void main(String[] args) {
//
try{
Student student, newStudent;
List list = Student.loadRecord( " ");
System.out.println( "original--------------------------- ");
for (int i=0; i <list.size();i++) {
student = (Student) list.get(i);
System.out.printf( "%s\n ",student);
}
//to test add method
newStudent = new Student();
newStudent.setName( "New ");
newStudent.add();
list = Student.loadRecord( " ");
System.out.println( "a new Student added--------------------------- ");
for (int i=0; i <list.size();i++) {
student = (Student) list.get(i);
System.out.printf( "%s\n ",student);
}
}
catch(Exception ex) {
System.out.println( "Exeption: " + ex.getMessage());
}
//
try{
String url= "jdbc:odbc:student_information ";
try{
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
}catch(
java.lang.ClassNotFoundException e){
System.err.print( "
ClassNotFoundException ");
System.err.println(e.getMessage());
}
Connection con=DriverManager.getConnection(url, " ", " ");
Statement stmt= con.createStatement();
ResultSet rs=stmt.executeQuery( "Select * from student_information ");
while(rs.next())
{
for(int i=1;i <6;i++)
System.out.println( "this number "+i+ " information: "+rs.getString(i));
}
con.close();
}
catch(
SQLException ex){
while(ex!=null){
System.out.println( "Exception be catched! ");
System.out.println(ex.getSQLState());
System.out.println(ex.getMessage());