Persistence units in persistence.xml are created during building the application. As I want to change the database url at runtime, is there any way to modify the persistence
You can use Persistence.createEntityManagerFactory(Map) to pass properties to choose the database URL and other settings.