好的!
下面就是代码:
import java.sql.*;
public class a
{
public static void main(String args[])
{
String name,num,chinese,math,english;
Connection conn= null;
Statement stmt=null;
ResultSet rs=null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){}
try
{
conn=DriverManager.getConnection("jdbc:odbc:grade");
stmt=conn.createStatement();
rs=stmt.executeQuery("select * from grade");
while(rs.next())
{
name=rs.getString("姓名");
num=rs.getString("学号");
chinese=rs.getString("语文");
math=rs.getString("数学");
english=rs.getString("英语");
System.out.println("学号:"+"姓名:"+"数学:"+"语文:"+"英语:");
System.out.println(" "+num+" "+name+" "+math+" "+chinese+" "+english);
System.out.println();
}
conn.close();
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
}
}