package 数据库;
import java.sql.*;
class Sql {
    void Sql(){
        try{
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        } catch (ClassNotFoundException ex) {
                System.out.println(ex.toString());
            //    ex.printStackTrace();
            }
            try {
                String url="jdbc:odbc:addr";
                Connection conn=DriverManager.getConnection(url);
                 Statement stmt=conn.createStatement();
                 ResultSet rs=stmt.executeQuery("slesct *form Student");
            }catch (SQLException ce){
                System.out.println(ce);
            }
        }
    }

解决方案 »

  1.   

    getConnection(); 
    createStatement();
    提示错误!
    "Sql.java": incompatible types; found   : java.sql.Connection, required: 数据库.Connection at line 29, column 47
    "Sql.java": cannot find symbol; symbol  : method createStatement(), location: class 数据库.Connection at line 30, column 38
                      
      

  2.   

    试着把Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver "); 这一句与后面的放在一个try catch块中。
      

  3.   

    url里面包括用户名、密码了吗?
      

  4.   

     ResultSet   rs=stmt.executeQuery( "slesct   *form   Student "); 
    你看看你的查询语句:slesct   *form   Student 
    应该是:select * from Student 撒!!!真是晕倒!!!!
      

  5.   

    sql语句错了
    select * from Student