【问题标题】:java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/Employees1java.sql.SQLException:找不到适合 jdbc:derby://localhost:1527/Employees1 的驱动程序
【发布时间】:2013-04-13 13:27:04
【问题描述】:

我研究了这个问题,但没有找到解决方案。

以下是我的代码:

package database_console;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
 *
 * @author SuperPc
 */
public class DBConnect {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    // TODO code application logic here
    try{
    Connection con=DriverManager.getConnection("jdbc:derby://localhost:1527/Employees1","admin1","admin");
    }
    catch(SQLException err){
        System.out.println(err);

    }

}

}

当我运行此代码时,我会关注

错误:java.sql.SQLException:找不到适合 jdbc:derby://localhost:1527/Employees1 的驱动程序

请指导我为什么会出现此错误以及如何解决此问题。

等待回复。

谢谢

【问题讨论】:

  • 您不应该使用Class.forName() 加载驱动程序吗?

标签: java javadb


【解决方案1】:

检查:

  1. derbyclient.jar 位于类路径中。

  2. 加载驱动类

    Class.forName("org.apache.derby.jdbc.ClientDriver");
    

【讨论】:

    猜你喜欢
    • 2011-04-18
    • 1970-01-01
    • 2018-05-04
    • 1970-01-01
    • 2016-10-29
    • 1970-01-01
    • 2010-11-25
    • 1970-01-01
    相关资源
    最近更新 更多