Page History
...
- By default JOC Cockpit starts the H2® database in embedded mode which does not allow shared access.
- For shared access the H2® database can be configured for mixed mode which includes to add the
AUTO_SERVER=TRUE
parameter to the JDBC URL.- By default JOC Cockpit makes use of the
hibernate.cfg.xml
Hibernate file in the/var/sos-berlin.com/js7/joc/resources/joc
directory, for details see JS7 - Database. Users can add the
AUTO_SERVER=TRUE
parameter to the JDBC URL like this:Code Block language xml <property name="jakarta.persistence.jdbc.url">jdbc:h2:./resources/joc/h2/joc;MODE=LEGACY;AUTO_SERVER=TRUE</property>
- For shared access the
AUTO_SERVER=TRUE
parameter similarly has to be used for URLs specified by the Operation Script.
- By default JOC Cockpit makes use of the
- It is recommended to activate shared access as this allows to take online backups while JOC Cockpit is up and running.
...
Code Block | ||
---|---|---|
| ||
Usage: operate-h2.sh [Command] [Options] [Switches] Commands: console --classpath [--web-port] shell --classpath --url [--file|--sql] [--driver-class] [--user] [--password] backup --classpath --url --file [--user] [--password] [--file-versions] export --classpath --url --file [--user] [--password] [--file-versions] [--zip] import --classpath --url --file [--user] [--password] [--zip] Options: --classpath=<path> | required: JDBC Driver classpath, default: ./h2-2.3.232.jar --url=<url> | optional: URL or path to database, default: jdbc:h2:./h2/joc --driver-class=<name> | optional: JDBC Driver class, default: org.h2.Driver --user=<account> | optional: database User, default: joc --password=<password> | optional: database password --file=<path> | optional: file for backup/export/import and SQL statements --file-versions=<number> | optional: create versions of files for backup/export, default: 1 --sql=<sql> | optional: SQL statement --web-port=<port> | optional: console web server port, default: 8082 Switches: -h | --help | displays usage -v | --verbose | displays verbose output -p | --password | asks for password -z | --zip | assumes zip compressed file on export/import |
Commands
console
- Invokes the H2® Console for use with a browser.
- Users can specify the
--web-port
option and otherwise use default port8082
.
shell
- Invokes the H2® Shell for execution of SQL statements:
- SQL statements can be specified using the
--sql
option. - Using the
--file
option a file can be specified holding SQL statements. - Without the
--sql
and--file
options the interactive H2® Shell will be used.
- SQL statements can be specified using the
- Invokes the H2® Shell for execution of SQL statements:
- backup
- Backup
- When creating backups then a .zip archive is created that holds related database files.
- Backups are transactionally consistent and represent a full backup of the JOC Cockpit database.
- To perform online backups consider mixed mode for connections to the database using the
AUTO_SERVER=TRUE
parameter with the database URL.
- Restore
- To restore a database it is replaced from the database files previously backed up.
- To this purpose JOC Cockpit must be stopped and must be restarted after completion of the restore operation.
- Restoring a database includes to extract the database files from a previoulsy created backup archive and to replace existing database files.
- When using the
--file-versions
option, backup files will be stored in versions:- Each newly created backup file is appended the suffix
-001
. - An existing backup file with the suffix
-001
is renamed to-002
. A backup file with the suffix-002
is renamed to the suffix-003
etc. - When the number of versions specified with the option is exeeded then the earliest backup file is removed.
- Each newly created backup file is appended the suffix
- Backups are created to restore an H2® database for the same version of H2®. For migration of H2® databases to newer versions of the database engine use the
export
andimport
commands.
- Backup
- export
- Export to text file holding SQL statements:
- By default the H2® database is exported to a text file that holds SQL statements which can be used to recreate the database.
- Export to .zip archive file:
- If the
--zip
switch is used, exports the H2® database to a .zip compressed
- archive file.
- The
- archive file includes the
script.sql
file holding SQL statements that can be used to recreate the database.
- If the
- When using the
--file-versions
option, export files will be stored in versions:- Each newly created export file is appended the suffix
-001
. - An existing export file with the suffix
-001
is renamed to-002
. An export file with the suffix-002
is renamed to the suffix-003
etc. - When the number of versions specified with the option is exeeded then the earliest export file is removed.
- Each newly created export file is appended the suffix
- Migration of H2® databases includes to export using the H2® Java binary file of the current version of the database engine. Import is performed using the newer version of the H2® Java binary file.
- Export to text file holding SQL statements:
import
- Import of text files holding SQL statements:
- By default a text file holding SQL statements is imported. Such files can be created using the
export
command.
- By default a text file holding SQL statements is imported. Such files can be created using the
- Import of .zip archive file:
- If the
--zip
switch is used, imports data from a compressed .zip archive file. The archive file includes text files holding SQL statements. The archive file can be created from theexport
command using the--zip
switch.
- If the
- If the import file was created using the
export
command, then it Imports data from an export file that holds the full export of the database. To restore a database it is recommended to (re)move the existing H2® database. The database will be recreated on import. - The export file created using the
export
command must be extracted to the resultingscript.sql
file.The path to thescript.sql
import file is specified with the--file
option.
- Import of text files holding SQL statements:
Options
--classpath
- H2® ships from a single Java binary file, for example
h2-2.3.232.jar
. - The option specifies the path to the H2® Java binary file, by default the current directory is used:
./h2-2.3.232.jar
.
- H2® ships from a single Java binary file, for example
--url
- Specifies the location of the H2® database. The JS7 - Database using H2® is located with JOC Cockpit from the
<jetty-base>/resources/joc/h2
directory. The name of the database isjoc
. - The URL is prefixed with
jdbc:h2:
followed by the relative or absolute path to the database. If the prefix is omitted, it will be added by the script. - Examples:
jdbc:h2:/var/sos-berlin.com/js7/joc/resources/joc/h2/joc
/var/sos-berlin.com/js7/joc/resources/joc/h2/joc
- Specifies the location of the H2® database. The JS7 - Database using H2® is located with JOC Cockpit from the
--driver
- Specifies the class name of the H2® JDBC Driver, default:
org.h2.Driver
.
- Specifies the class name of the H2® JDBC Driver, default:
--user
- Specifies the account for the H2® database, default:
joc
.
- Specifies the account for the H2® database, default:
--password
- Specifies the password used for the account specified with the
--user
option for the H2® database, default: no password. - Password input from the command line is considered insecure. Consider use of the
-p
switch offering a secure option for interactive keyboard input.
- Specifies the password used for the account specified with the
--file
- When used with the
export
command, specifies the path to the .zip archive file that holds the full database export. - When used with the
import
command, specifies the path to the .sql script file used for import. This offers to restore the database from a previous full export. - When used with the
shell
command, specifies the path to the .sql script file that holds SQL statements that should be executed.
- When used with the
--file-versions
- When used with the
export
command, specifies the number of versions for which backup files will be stored
- When used with the
--sql
- When used with the
shell
command specifies the SQL statement that should be executed. - Consider to apply quotes as with
--sql="SELECT COUNT(*) FROMM JOC_VARIABLES;"
. SQL statements should be terminated by semicolon.
- When used with the
--web-port
- When used with the
console
command specifies the port used by the H2® Console, default:8082
.
- When used with the
...
Overview
Content Tools