Class.forName("sun.jdbc.odbc.jdbcobcDriver");
请加入引号

解决方案 »

  1.   

    Class.forName("sun.jdbc.odbc.jdbcobcDriver");
    加了引号也没有成呀,到这里就出错
    Connection c=DriverManager.getConnection(con.dburl,con.username,con.password);
    不加引号,还到不出这些烂东西!
      

  2.   

    sun.jdbc.odbc.JdbcOdbcDriver
    大小写,拼写!
      

  3.   

    /*
     * Created on 2003-4-15
     *
     * To change the template for this generated file go to
     * Window>Preferences>Java>Code Generation>Code and Comments
     *//**
     * @author Administrator
     *
     * To change the template for this generated type comment go to
     * Window>Preferences>Java>Code Generation>Code and Comments
     */
    import java.sql.*;
    class constr{
    String dburl="jdbc:odbc:dzyls";
    String username="sa";
    String password="syncmaster";
    }
    public class democlass {
    public static void main(String[] args){
    constr con=new constr();
    try{
    Class.forName("sun.jdbc.odbc.JdbcObcDriver");
    }
    catch(ClassNotFoundException e)
    {
     System.out.println("ClassNotFoundException:" +e.getMessage());
    }
    Connection c=DriverManager.getConnection(con.dburl,con.username,con.password);
    Statement s=c.createStatement();
    ResultSet r=s.executeQuery("select * from gpzk");
    while (r.next())
    {
    System.out.println(r.getString("pm"));
    }
    s.close();
    } }
    还是有问题,我纳闷,本人比较笨! 麻烦各位了!
      

  4.   

    class constr{
    String dburl="jdbc:odbc:dzyls";
    String username="sa";
    String password="syncmaster";
    }
    一个文件只能有一个类!!
    你得把这个class放在文件外面或者放到类里面!
      

  5.   

    /*
     * Created on 2003-4-15
     *
     * To change the template for this generated file go to
     * Window>Preferences>Java>Code Generation>Code and Comments
     *//**
     * @author Administrator
     *
     * To change the template for this generated type comment go to
     * Window>Preferences>Java>Code Generation>Code and Comments
     */
    import java.sql.*;
    class constr{
    String dburl="jdbc:odbc:dzyls";
    String username="sa";
    String password="syncmaster";
    }
    public class democlass {
    public static void main(String[] args){
    constr con=new constr();
    Connection  c = null;
    Statement s = null;
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    c = DriverManager.getConnection(con.dburl,con.username,con.password);
    s = c.createStatement();
    ResultSet r=s.executeQuery("select * from gpzk");
    while (r.next())
    {
    System.out.println(r.getString("pm"));
    }
    }
    catch(Exception e){
     System.out.println("ClassNotFoundException:" +e.getMessage());
    }
    finally{
    try{
    s.close();
    c.close();
    }catch(Exception e){}
    }
    } }