To retrieve the database name, invoke the SYSCS_UTIL.SYSCS_GET_DATABASE_NAME() system function, as documented in the Derby Reference Manual. You can also use DatabaseMetaData to return the connection URL of any local Connection.
/* in java */ String myURL = conn.getMetaData().getURL();