СУБД H2

Средний рейтинг
Еще нет оценок
Мой рейтинг:

DBMS H2.

Вот основной ресурс этой СУБД. Здесь все подробности.

Столкнулся с этой БД при обновлении OSS Nexus. Там они в последней версии перешли с OrientDB на H2 (для тех, кто бедный) или на PostgreSQL (для тех, кто побогаче, т.к. надо покупать премиум аккаунт по подписке).

Но т.к. в современных реалиях, на момент написания данной заметки, нет возможности оплатить хотя бы месяц этого премиального аккаунта, то пришлось выбирать H2.

И так…

Скачать архив:

распаковать:

Запустить скрипт:

Targets:
benchmarkRun the benchmarks.
cleanClean all jar files, classes, and generated documentation.
compileCompile all classes.
coverageRun the JaCoco code coverage.
docsCreate the documentation from sources (incl. API Javadocs).
downloadDownload all required jar files.
installerCreate the h2.zip file and the Windows installer.
jarCreate the regular h2.jar file.
jarMVStoreCreate h2mvstore.jar containing only the MVStore.
javadocCreate the API Javadocs (incl. JDBC API and tools).
javadocImplCreate the Javadocs of the implementation.
mavenDeployCentralBuild H2 release jars and upload to file:///data/h2database/m2-repo.
mavenInstallLocalBuild a snapshot H2 jar and upload to local Maven 2
offlineBuild H2 jar avoiding downloads (list missing files).
spellcheckRun the spellchecker.
testCompile and run all tests (excluding the compile step).
testCICompile and run all tests for CI (excl. the compile step).
testNetworkTest the local network of this machine.
testSysPropertiesPrint the system properties.
uploadBuildUpload all build results to the public website.
warConsoleBuild the h2console.war file.

Запустим так:

Мне написало такое:

Error: JAVA_HOME is not defined.

Тогда сделаю так сначала:

и повторю выполнил предыдущую команду. Вот что мне написало:

Target: test
/usr/lib/jvm/java-17-openjdk-amd64/bin/java -ea -Xmx128m -cp src/java10/precompiled:src/java9/precompiled:temp:bin:ext/postgresql-42.7.2.jar:ext/javax.servlet-api-4.0.1.jar:ext/jakarta.servlet-api-5.0.0.jar:ext/lucene-core-9.7.0.jar:ext/lucene-analysis-common-9.7.0.jar:ext/lucene-queryparser-9.7.0.jar:ext/org.osgi.core-5.0.0.jar:ext/org.osgi.service.jdbc-1.1.0.jar:ext/jts-core-1.19.0.jar:ext/slf4j-api-2.0.7.jar:ext/slf4j-nop-2.0.7.jar:ext/asm-9.5.jar:/usr/lib/jvm/java-17-openjdk-amd64/../lib/tools.jar:ext/nashorn-core-15.4.jar:ext/asm-commons-9.5.jar:ext/asm-tree-9.5.jar:ext/asm-util-9.5.jar org.h2.test.TestAll
Error: Could not find or load main class org.h2.test.TestAll
Caused by: java.lang.ClassNotFoundException: org.h2.test.TestAll

Попробую так:

Вывод большой, не буду сюда его выкладывать. Только то, что в конце было написано:

Building index for all classes…
Generating docs/javadoc/allclasses-index.html…
Generating docs/javadoc/allpackages-index.html…
Generating docs/javadoc/index-all.html…
Generating docs/javadoc/overview-summary.html…
Generating docs/javadoc/help-doc.html…
Zip temp/org/h2/util/data.zip (669 KB)
Done in 22407 ms

Потом можно опять попробовать тест запустить, но это долгий процесс.

Options are case sensitive.
Supported options[-help] or [-?]Print the list of options
[-web] Start the web server with the H2 Console
[-webAllowOthers] Allow other computers to connect — see below
[-webExternalNames] The comma-separated list of external names and IP addresses of this server, used together with -webAllowOthers
[-webDaemon] Use a daemon thread
[-webPort ] The port (default: 8082)
[-webSSL] Use encrypted (HTTPS) connections
[-webAdminPassword] Password of DB Console administrator
[-browser] Start a browser connecting to the web server
[-tcp] Start the TCP server
[-tcpAllowOthers] Allow other computers to connect — see below
[-tcpDaemon] Use a daemon thread
[-tcpPort ] The port (default: 9092)
[-tcpSSL] Use encrypted (SSL) connections
[-tcpPassword ] The password for shutting down a TCP server
[-tcpShutdown «»] Stop the TCP server; example: tcp://localhost
[-tcpShutdownForce] Do not wait until all connections are closed
[-pg] Start the PG server
[-pgAllowOthers] Allow other computers to connect — see below
[-pgDaemon] Use a daemon thread
[-pgPort ] The port (default: 5435)
[-properties «»] Server properties (default: ~, disable: null)
[-baseDir] The base directory for H2 databases (all servers)
[-ifExists] Only existing databases may be opened (all servers)
[-ifNotExists] Databases are created when accessed
[-trace] Print additional trace information (all servers)
[-key ] Allows to map a database name to another (all servers)
The options -xAllowOthers are potentially risky.

 

Попробовал запустить вот так:

Я запускал в режиме PG, чтобы это ни значило.

Потом запустил консоль:

Далее указывал следующие параметры:

/mnt/nexus_blob/dbms_h2/databases/ — путь, где будет храниться БД, nexus3 — название БД

Далее, будет Driver — тут просто нажал Enter.

Потом задал имя пользователя:

Задал пароль и повторил потом:

В итоге получилось что-то типа такого:

Попробую посмотреть какие есть таблицы:

Можем запустить web-доступ:

 

Здесь:

  • JDBC URL: вводим — jdbc:h2:/mnt/nexus_blob/dbms_h2/databases/nexus3
  • User Name: nexusdbusr
  • Password: [пароль который задавали в консоли]

Жмём Connect и попадаем вот сюда:

If you found an error, highlight it and press Shift + Enter or to inform us.

Фото аватара

Дмитрий

родился, учился, работаю-учусь

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest
0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии