那明显是sDBDriver有问题,为什么还用odbc

解决方案 »

  1.   

    你是否配置了数据源,也就是odbc。
      

  2.   

    引用
    ---------------------------------
     catch(java.lang.ClassNotFoundException e)
        
        System.err.println(e.getMessage() );    //<------提示我这里有错误.
        }
    --------------------------------------
    好像少了个括号呢还catch(java.lang.ClassNotFoundException e)后面
      

  3.   

    恩你的是有问题的, 
    你运用JDBC-ODBC 桥连接的话,
    首先 装驱动  
         在打开连接这个千古道理你要清楚,
        在就是看 看你的 字符串和 创建的连接 Statement  等等这些细节对否?
      这个都是死东西,很好找的 你要静下心来找,一定清楚,这个很重要,也很基本的!
       祝你好运!
      

  4.   

    Public class DataBaseConnection 
    {
     public static Connection GetConnection()
    {
      Connection  con = null;
      String  classforname ="oracle.jdbc.driver.OracleDriver";
      String  url="jdbc:odbc:odbcsource";
      String  user = "user";
      String  pwd = " ";
    try{
       //转载驱动,每个数据库驱动程序都必须实现Driver接口;
        class.forName(classforname);
        //调用DriverManager的getConnection()连接到指定的数据库;
        con = DriverManager.getConnection(url,user,pwd);
       }
    catch(excepton e)
    {
      e.printStactTrance();
    }
    return con;
    }
    }  class ExeSql
    {  
       public ExeSql()
      {
          try
            {
            Connection con= null; 
            con = DataBaseConnection.GetConnection()
            }
           catch(exception e)
            {
             e.printStackTrace();        }
       }   public  ResultSet ExecuteQuery()
     {
       try{  Connection  con = DataBaseConnection.GetConnection()
      Statement stmt = null;
      ResultSet  rst = null;
      String  sql="select * from tablename  where a =b "
      rst  =  stmt.executeQuery("sql");
      reture rst;
      Close();
           }
       catch(exception e)
         {
          e.printStackTrace();
          }
     }
      
     public  int  ExecuteUpdate()
     {
      try
      {
       Connection  con = DataBaseConnection.GetConnection()
      Statement stmt = null;
      int rst =0;
      String  sql="update tablename  set a = b where a = c "
      rst  =  stmt.executeQuery("sql");
      return rst;
      Close();
     catch(exception e )
      {
        e.printStackTrace();
       }
     }  public  boolean  Execute()
     {
      try{   Connection  con = DataBaseConnection.GetConnection()
      Statement stmt = null;
      boolean rst=false;
      String  sql="select * from tablename  where a =b "
      rst  =  stmt.execute("sql");
      return rst;
      Close();
        }
     catch(exception e)
       {
         e.printStackTrace();
       }
     }  public void Close()
       {
        if(con != null || stmt !=null)
        con.close;
        stmt.close;
       }
    }
      

  5.   

    Public class DataBaseConnection 
    {
     public static Connection GetConnection()
    {
      Connection  con = null;
      String  classforname ="oracle.jdbc.driver.OracleDriver";
      String  url="jdbc:odbc:odbcsource";
      String  user = "user";
      String  pwd = " ";
    try{
       //转载驱动,每个数据库驱动程序都必须实现Driver接口;
        class.forName(classforname);
        //调用DriverManager的getConnection()连接到指定的数据库;
        con = DriverManager.getConnection(url,user,pwd);
       }
    catch(excepton e)
    {
      e.printStactTrance();
    }
    return con;
    }
    }  class ExeSql
    {  
       public ExeSql()
      {
          try
            {
            Connection con= null; 
            con = DataBaseConnection.GetConnection()
            Statement stmt = null;
            }
           catch(exception e)
            {
             e.printStackTrace();        }
       }   public  ResultSet ExecuteQuery()
     {
       try{
      ResultSet  rst = null;
      String  sql="select * from tablename  where a =b "
      rst  =  stmt.executeQuery("sql");
      reture rst;
      Close();
           }
       catch(exception e)
         {
          e.printStackTrace();
          }
     }
      
     public  int  ExecuteUpdate()
     {
      try
      {
      int rst =0;
      String  sql="update tablename  set a = b where a = c "
      rst  =  stmt.executeQuery("sql");
      return rst;
      Close();
     catch(exception e )
      {
        e.printStackTrace();
       }
     }  public  boolean  Execute()
     {
      try{
      boolean rst=false;
      String  sql="select * from tablename  where a =b "
      rst  =  stmt.execute("sql");
      return rst;
      Close();
        }
     catch(exception e)
       {
         e.printStackTrace();
       }
     }  public void Close()
       {
        if(con != null || stmt !=null)
        con.close;
        stmt.close;
       }
    }
    上面个有问题 呵呵,随手写的,三个月之前学的java 只后就做.net写这里参考下,有很多都想不起来,也没调试!