Derby db connectivity problems

I receive the following error msg when attempting to connect to a derby network server:

java.sql.SQLException: No suitable driver found for jdbc:derby://localhost/studentdb;create=true

Derby is properly installed and all environment variables set. I am able to start the derby NetworkServerControl from a Windows command prompt with the following command:

java org.apache.derby.drda.NetworkServerControl start -h localhost

,and I can do this from any location within my system's directory tree.

I can start the derby ij client from within a Windows command prompt with the command:

java org.apache.derby.tools.ij

,again, from any location within my system's directory tree.

But the code snippet below is unable to make this connection:

    public static void main(String[] args) {
    Connection conn = null;

        String url = "jdbc:derby://localhost/studentdb;create=true";

    //the error happens here, the program executes no further
        conn = DriverManager.getConnection(url,null);

        Statement stmt = conn.createStatement();

}

Placing the port value in the url string makes no difference. Any suggestions would be much appreciated.


您必须将derby jdbc驱动程序添加到您的类路径中(来自derbyclient.jar ,因为这是ClientDriver ),然后使用此指令加载驱动程序:

Class.forName("org.apache.derby.jdbc.ClientDriver");
链接地址: http://www.djcxy.com/p/41246.html

上一篇: 由于无法找到数据库,因此无法将战争部署到GlassFish 4.1.2服务器

下一篇: 德比分贝连接问题