日期:2014-05-18  浏览次数:20679 次

哪位热心人,可以建立一个上面的数据库,这个数据库很简单的,可能只需要五分钟就能搞定,将代码COPY一份,在计算机上运行一下,给我找找原因.
import   java.sql.*;
import   java.awt.event.*;
import   javax.swing.*;
class   sqlTest
{


public   static   void   main(String[]   args)
{
JFrame   jf=new   JFrame( "The   system   of   Student   informaton ");
jf.setSize(600,400);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel   jp=new   JPanel();
JLabel   jl=new   JLabel( "Please   input   student 's   IDnumber ");
final   JTextField   jtf=new   JTextField(15);
final   JTextArea   jta=new   JTextArea();
JButton   jb=new   JButton( "Select ");
jf.getContentPane().add(jp, "North ");
    jf.getContentPane().add(jta, "Center ");
    jf.getContentPane().add(jb, "South ");
    jp.add(jl);
    jp.add(jtf);
    jf.setVisible(true);
    jb.addActionListener(new   ActionListener()
    {
    public   void   actionPerformed(ActionEvent   e)
    {
    Connection   conn=null;
Statement   stmt=null;
ResultSet   rs=null;
try
{
      Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
}
catch(ClassNotFoundException   ce)
{
      ce.printStackTrace();  
      //System.out.println( "my   a   ClassNotFoundException   wrong ");
}
try
{
    conn=DriverManager.getConnection( "jdbc:odbc:test: ");
    stmt=conn.createStatement();
    String   strNumber=jtf.getText();
    String   strSql= "select   *   from   grade   where   StuNumber=strNumber ";
    rs=stmt.executeQuery(strSql);
    String   strline=System.getProperty( "line.separator ");
    while(rs.next())
    {
          jta.append(rs.getString( "学号 "));
          jta.append(strline);
          jta.append(rs.getString( "姓名 "));
          jta.append(strline);
          jta.append(rs.getString( "语文 "));
          jta.append(strline);
          jta.append(rs.getString( "数学 "));
          jta.append(strline);
          jta.append(rs.getString( "英语 "));
    }
}
catch(SQLException   se)
{
      se.printStackTrace();
      //System.out.println( "my   a   executeQueryException   wrong ");
}
finally
{
try
{