2013-04-20 100 views
1

我研究了这个问题,但我没有找到解决方案。java.sql.SQLException:没有找到合适的驱动程序为jdbc:derby:// localhost:1527/Employees1

以下是我的代码:

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没有合适的驱动程序:德比:// localhost:1527/Employees1

Screenshot of Services tab

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

等待回复。

感谢

+0

你不应该使用加载'的Class.forName()'司机? – NINCOMPOOP 2013-04-20 04:57:22

+0

[Duplicated](http://stackoverflow.com/questions/3816015/sqlexception-no-suitable-driver-found-for-jdbcderby-localhost1527) – gks 2013-04-20 05:19:25

回答

4

检查:

  1. derbyclient.jar中是在类路径上。

  2. 通过加载驱动程序类

    Class.forName("org.apache.derby.jdbc.ClientDriver"); 
    
相关问题