You connect to a database using a form of the Derby connection URL as an argument to the DriverManager.getConnection call.
For details on the syntax of the connection URL, see "Syntax of database connection URLs for applications with embedded databases" in the Derby Reference Manual.
You specify a path to the database within this connection URL.