发新话题
打印

求助!!谁来帮我看一下这个小程序。。

求助!!谁来帮我看一下这个小程序。。

连接数据库所的一段:

public void connectDB()
{
  //this is the database driver
  String DBdriver = "oracle.jdbc.driver.OracleDriver";
  
  //this is the url of the database
  String url = "jdbcracle:xxxxxxxxxx";
  
  //initial connection and statement of database
  Statement stmt = null;
  Connection conn = null;
  
  
  //load the database driver
  try
  {
   Class.forName(DBdriver);
  }catch(Exception e)
  {
   System.out.println("Can not load the database driver");
   System.out.println(e);
   }
   
        //set up connection
  try
  {
   conn = DriverManager.getConnection(url,"xxx","xxx");
   stmt = conn.createStatement();
  }catch(SQLException sqle)
  {
   System.out.println("Can not connect to the database");
   System.out.println(sqle);
   }
  
  }

然后它说错误是:

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

为什么呢????

      

TOP

呵呵,我知道了,忘了加入oracle的library.........挖哈哈,真笨      

TOP

啦啦啦~~~~      

TOP

发新话题