org.apache.derby.jdbc.ClientDriver;无法连接

org.apache.derby.jdbc.ClientDriver ; unable to connect

无法连接。无法使用 org.apache.derby.jdbc.ClientDriver 建立与 jdbc:derby://localhost:1527/sample 的连接(DERBY SQL 错误:ERRORCODE:40000,SQLSTATE:XJ040,SQLERRMC:无法使用 class 加载程序 sun.misc.Launcher$AppClassLoader@1d44bcfa 启动数据库 'sample',有关详细信息,请参阅下一个异常。::SQLSTATE:XSLAN)。

进行连接时,应将其放入 try/catch。 例如(我使用 Java 8 和 oracle SQLDeveloper):

 String dbURL="jdbc:oracle:thin:@localhost:1521:xe";
    String username = "system";
    String password = "root";


    try{

    Connection connection = DriverManager.getConnection(dbURL,username,password);
        System.out.println("Connected to Oracle database server");

        
        String sql = "INSERT INTO USERS (name,email,password)" + "VALUES('eu', 'eu@yahoo.com', 'eu')";

        Statement statement = connection.createStatement();
        int rows = statement.executeUpdate(sql);

        if(rows >0){
            System.out.println("A row has been inserted");
        }



        connection.close();
    }catch (SQLException e){
        System.out.println("ERROR");
    }

并始终检查正确的密码和用户名。希望这可以帮助。 :D