H2 is a Java-based Database which replaced Derby as the default database in Payara 5. Derby as a database service that can be started and managed by Payara Server Community, has been removed starting from version 5.201
Why replace Derby?
In terms of performance, Derby is one of the slowest embedded databases as compared to other H2, PostgresSQL, HSQLDB, etc. H2 also has a smaller disk footprint; the size of a JAR file is around 1.5 MB.
To Start the Database
To start the database run the command below:
The above command will start H2 on the default port, which is 9092.
To Stop the Database
To stop the database run the command below:
The above command will stop H2.
To connect to H2 DB databases
To connect to an H2 DB database and execute SQL scripts, you should:
Stop Payara Server if running
/path/to/payara/payara5/h2db/binto find the h2db binaries
java -jar h2.jar(this will start the H2 Admin UI server and open browser with the Admin UI URL)
In the browser, set JDBC URL to
jdbc:h2:/path/to/payara/payara5/glassfish/domains/domain1/lib/databases/ejbtimerto connect to the EJB timer database (or change the path to connect to another DB)
Leave the other options as they are and log into the SQL console
Make sure to stop the
java -jar h2.jarprocess before launching Payara Server