# H2 Database Server Setup
# Summary
To improve the performance of the calendar dashboard page, incident information is cached in an H2 database. Whenever the yCrash server is installed across multiple nodes, you need to set up the H2 database in server mode on a centralized storage.
By following the steps outlined below, you can manually start the H2 database server and configure your application to connect to it using the h2-connector.xml file.
# Step 1: Launch the H2 Database Server
- Download the H2 Database distribution from this location (opens new window).
- Open a terminal or command prompt.
- Navigate to the directory where the
h2-yc.jarwas downloaded in step #1 - Run the following command to start the H2 server:
java -cp h2-yc.jar org.h2.tools.Server -tcp -tcpPort <TCP-PORT> -tcpAllowOthers -baseDir <DIRECTORY>
Here replace
<TCP-PORT> - Port number in which H2 DB should listen for server connections.
<DIRECTORY> - Directory in which H2 DB files will be stored.
Example:
java -cp h2-yc.jar org.h2.tools.Server -tcp -tcpPort 9092 -tcpAllowOthers -baseDir /tmp/h2
# Step 2: Configure H2 Database
Open Command Prompt or Terminal: Navigate to the directory where the H2 jar file is located.
Run H2 Shell Command: Use the following command to start the H2 Shell.
java -cp h2-yc.jar org.h2.tools.Shell
H2 Shell Welcome Message: You will see the following welcome message:
Welcome to H2 Shell
Exit with Ctrl+C
Database URL: You will be prompted to enter the URL for the H2 database. You can specify a path to a file-based database. For example:
URL jdbc:h2:./path/to/database
Driver: Enter the driver class name for H2.
Driver org.h2.Driver
User: Enter the username for the database. The default user for H2 is sa.
User sa
Password: Enter the password for the database user. You will need to confirm the password by typing it again. The password input will be hidden for security.
Connection Confirmation: Upon successful connection, you will see a message indicating that you are connected.
Example:
> java -cp h2-yc.jar org.h2.tools.Shell
Welcome to H2 Shell
Exit with Ctrl+C
[Enter] jdbc:h2:mem:2
URL jdbc:h2:./path/to/database
[Enter] org.h2.Driver
Driver
[Enter] sa
User your_username
Password (hidden)
Type the same password again to confirm database creation.
Password (hidden)
Connected
sql> quit
Connection closed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Step 3: Connect to the H2 Database Server
To connect application (e.g., yCrash) to the H2 database server that you started manually, follow these steps:
- Download (opens new window) the
h2-connector.xmlconfiguration file. - Set the database credentials in the
h2-connector.xmlfile. - Place the
h2-connector.xmlfile in the uploads directory of yCrash server.
h2-connector.xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="H2_URL">JDBC URL</entry>
<entry key="H2_USER">username</entry>
<entry key="H2_PASSWORD">password</entry>
</properties>
2
3
4
5
6
7
Replace the following placeholders with your actual database credentials:
- JDBC URL: JDBC URL where the H2 database is listening that you have configured in step 2.
- username: The username for accessing the H2 database that you have configured in step 2.
- password: The password for accessing the H2 database that you have configured in step 2.