不用ODBC,可以用SQL Server的JDBC驱动啊!
在Google上搜一下

解决方案 »

  1.   

    你和我用的一模一样在控制面板————管理工具————数据源(ODBC)里可以设置我昨天刚做好一个连接SQL数据库的程序,你有什么问题说清楚一点
    其实连接什么数据库都是一样的,改一下数据源的名称和用户名,密码就能通吃了
      

  2.   

    我编译了下面的程序:  
    import java.awt.*;  import java.net.*;
      import java.sql.*;  import java.awt.event.*;
    class Window extends Frame implements ActionListener      {TextArea text; Panel panel; TextField xm; Button button1,button2;
    Window()    {  super("成绩查询");
    setLayout ( new BorderLayout() ); setBackground(Color.cyan);
    setBounds(150,150,300,120);   setVisible(true);
    text = new TextArea(); button1 = new Button("确定"); button2 = new Button("查询所有人的成绩");
    xm = new TextField(16); panel = new Panel();
    panel.add(new Label("输入被查询的学生的姓名:") ); panel.add(xm);
    panel.add(button1);
    add(panel,"North"); add(text,"Center"); add(button2,"South");
    text.setEditable(false); text.setBackground(Color.pink);
    button1.addActionListener(this); button2.addActionListener(this);
    addWindowListener(new WindowAdapter()     {public void windowClosing(WindowEvent e)
       {  setVisible(false); System.exit(0);       }    }  );    }public void actionPerformed(ActionEvent e)      {
    if (e.getSource() == button1)      {
      text.setText("查询结果" + "\n");
     try { Liststudent1();     }
     catch (SQLException ee) {}    }
     else if (e.getSource() == button2)      {
      text.setText("查询结果" + "\n");
     try { Liststudent2();     }
     catch (SQLException ee) {}    }       } public void Liststudent1() throws SQLException  {
     String name; int math,english,physics,sum;
     try { Class.forName("sum.jdbc.odbc.jdbcOdbcDriver");    }
     catch ( ClassNotFoundException e )  {}
     Connection con = DriverManager.getConnection("jdbc:odbc:hhl02","sa"," ");
     Statement sql = con.createStatement();
     ResultSet rs = sql.executeQuery("SELECT * FROM TABLE1");
     while(rs.next() )    {
     name = rs.getString("name"); math = rs.getInt("math"); physics = rs.getInt("physics");
     english = rs.getInt("english"); sum = english + math + physics; if ((name.trim() ).equals(xm.getText().trim() ) )     {
     text.append("***" + "\n" + name + "的成绩:" + "\n" + "数学: " + math + "物理: " + physics 
     + "英语: " + english + "sum: " + sum + "\n" );       }         } 
     if ((text.getText().trim() ).equals("查询结果") )      {
     text.setText("没有该人的成绩");       }         } public void Liststudent2() throws SQLException  {
     String name; int math,english,physics,sum;
     try { Class.forName("sum.jdbc.odbc.jdbcOdbcDriver");    }
     catch ( ClassNotFoundException e )  {}
     Connection con = DriverManager.getConnection("jdbc:odbc:hhl02","sa"," ");
     Statement sql = con.createStatement();
     ResultSet rs = sql.executeQuery("SELECT * FROM TABLE1");
     while(rs.next() )    {
     name = rs.getString("2"); math = rs.getInt("math"); physics = rs.getInt("physics");
     english = rs.getInt("english"); sum = english + math + physics;
     text.append("***" + "\n" + name + "的成绩:" + "\n" + "数学: " + math + "物理: " + physics 
     + "英语: " + english + "sum: " + sum + "\n" );       }         }           }
    运行后不能连到数据库,不知何故?
      

  3.   

    不要用ODBC连接。微软有官方的4类JDBC驱动http://www.microsoft.com/downloads/details.aspx?FamilyID=4f8f2f01-1ed7-4c4d-8f7b-3d47969e66ae&DisplayLang=en#filelist