You will first need to load the derby driver class. To do that, add this code before the DriverManager.getConnection()
call.
try{
Class.forName("org.apache.derby.jdbc.ClientDriver");// or may be it is "org.apache.derby.jdbc.EmbeddedDriver"? Not sure. Check the correct name and put it here.
} catch(ClassNotFoundException e){
//handle exception
}
This will load and register the Derby driver class in the JDBC's driver registry, after which you'll be able to connect to the database.
Refer to this for more details:
https://db.apache.org/derby/docs/10.4/devguide/cdevdvlp40653.html
Update
There should be a derbyclient.jar
in the lib folder of derby installation. You will need to add that also to the class path and make it available at run time. This seems to solve the problem for me.
Hope this helps!