]> git.basschouten.com Git - openhab-addons.git/commitdiff
[jdbc] Upgrade H2 to 2.2.224 (#15726)
authorWouter Born <github@maindrain.net>
Tue, 10 Oct 2023 11:14:48 +0000 (13:14 +0200)
committerGitHub <noreply@github.com>
Tue, 10 Oct 2023 11:14:48 +0000 (13:14 +0200)
Upgrades H2 database from 1.4.191 to 2.2.224.

Add ';NON_KEYWORDS=VALUE' to the JDBC URL because the add-on uses 'value' (which is also a keyword) as column name.

Also fixes some queries used by the command extension because H2 always uses upper case table names.

For the change log, see:

https://h2database.com/html/changelog.html

For migration notes, see:

https://h2database.com/html/migration-to-v2.html

Fixes #13115

Signed-off-by: Wouter Born <github@maindrain.net>
bundles/org.openhab.persistence.jdbc/README.md
bundles/org.openhab.persistence.jdbc/pom.xml
bundles/org.openhab.persistence.jdbc/src/main/feature/feature.xml
bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/JdbcConfiguration.java
bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/db/JdbcH2DAO.java
bundles/org.openhab.persistence.jdbc/src/main/resources/OH-INF/config/config.xml
bundles/org.openhab.persistence.jdbc/src/main/resources/OH-INF/i18n/jdbc.properties
features/openhab-addons-external/src/main/resources/conf/jdbc.cfg

index 56345665018d661def60d19094f19910ac0d2487..2f6f4daebe56c14d5738d5c47080bc6c75239fb8 100644 (file)
@@ -7,16 +7,16 @@ It is designed for a maximum of scalability, to store very large amounts of data
 The generic design makes it relatively easy for developers to integrate other databases that have JDBC drivers.
 The following databases are currently supported and tested:
 
-| Database                                     | Tested Driver / Version                                      |
-| -------------------------------------------- | ------------------------------------------------------------ |
-| [Apache Derby](https://db.apache.org/derby/) | [derby-10.14.2.0.jar](https://mvnrepository.com/artifact/org.apache.derby/derby) |
-| [H2](https://www.h2database.com/)            | [h2-1.4.191.jar](https://mvnrepository.com/artifact/com.h2database/h2) |
-| [HSQLDB](http://hsqldb.org/)                 | [hsqldb-2.3.3.jar](https://mvnrepository.com/artifact/org.hsqldb/hsqldb) |
+| Database                                     | Tested Driver / Version                                                                                  |
+| -------------------------------------------- |----------------------------------------------------------------------------------------------------------|
+| [Apache Derby](https://db.apache.org/derby/) | [derby-10.14.2.0.jar](https://mvnrepository.com/artifact/org.apache.derby/derby)                         |
+| [H2](https://www.h2database.com/)            | [h2-2.2.224.jar](https://mvnrepository.com/artifact/com.h2database/h2)                                   |
+| [HSQLDB](http://hsqldb.org/)                 | [hsqldb-2.3.3.jar](https://mvnrepository.com/artifact/org.hsqldb/hsqldb)                                 |
 | [MariaDB](https://mariadb.org/)              | [mariadb-java-client-3.0.8.jar](https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client) |
-| [MySQL](https://www.mysql.com/)              | [mysql-connector-j-8.0.33.jar](https://mvnrepository.com/artifact/com.mysql/mysql-connector-j) |
-| [PostgreSQL](https://www.postgresql.org/)    | [postgresql-42.4.3.jar](https://mvnrepository.com/artifact/org.postgresql/postgresql) |
-| [SQLite](https://www.sqlite.org/)            | [sqlite-jdbc-3.42.0.0.jar](https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc) |
-| [TimescaleDB](https://www.timescale.com/)    | [postgresql-42.4.3.jar](https://mvnrepository.com/artifact/org.postgresql/postgresql) |
+| [MySQL](https://www.mysql.com/)              | [mysql-connector-j-8.0.33.jar](https://mvnrepository.com/artifact/com.mysql/mysql-connector-j)           |
+| [PostgreSQL](https://www.postgresql.org/)    | [postgresql-42.4.3.jar](https://mvnrepository.com/artifact/org.postgresql/postgresql)                    |
+| [SQLite](https://www.sqlite.org/)            | [sqlite-jdbc-3.42.0.0.jar](https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc)                    |
+| [TimescaleDB](https://www.timescale.com/)    | [postgresql-42.4.3.jar](https://mvnrepository.com/artifact/org.postgresql/postgresql)                    |
 
 ## Table of Contents
 
index d3a6a3bae917bdf3d23df805614df269e9a53bd1..3e29ab7cbf08e608c331dc3bd12162927c1783a1 100644 (file)
@@ -26,7 +26,7 @@
 
     <!-- JDBC database driver versions -->
     <derby.version>10.14.2.0</derby.version>
-    <h2.version>1.4.191</h2.version>
+    <h2.version>2.2.224</h2.version>
     <hsqldb.version>2.3.3</hsqldb.version>
     <mariadb.version>3.0.8</mariadb.version>
     <mysql.version>8.0.33</mysql.version>
index df454e50357853fffe30d5f282d0fc6fd4cca7ec..14c7724c54340933b56e48bdfd45a0737728fe62 100644 (file)
@@ -13,7 +13,7 @@
        <feature name="openhab-persistence-jdbc-h2" description="JDBC Persistence H2" version="${project.version}">
                <configfile finalname="${openhab.conf}/services/jdbc.cfg" override="false">mvn:org.openhab.addons.features.karaf/org.openhab.addons.features.karaf.openhab-addons-external/${project.version}/cfg/jdbc</configfile>
                <feature prerequisite="false" dependency="false">openhab-runtime-base</feature>
-               <bundle start-level="80">mvn:com.h2database/h2/1.4.191</bundle>
+               <bundle start-level="80">mvn:com.h2database/h2/2.2.224</bundle>
                <bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.persistence.jdbc/${project.version}</bundle>
        </feature>
 
index e39dca680cfe01c42130ee138ab1a6df28d8f7b7..cfea39bd6394d62b17982c34e4835dd8a5195b82 100644 (file)
@@ -321,7 +321,7 @@ public class JdbcConfiguration {
                         warn += "\tDerby:     version >= 10.14.2.0 from          https://mvnrepository.com/artifact/org.apache.derby/derby\n";
                         break;
                     case "h2":
-                        warn += "\tH2:        version >= 1.4.189 from            https://mvnrepository.com/artifact/com.h2database/h2\n";
+                        warn += "\tH2:        version >= 2.2.224 from            https://mvnrepository.com/artifact/com.h2database/h2\n";
                         break;
                     case "hsqldb":
                         warn += "\tHSQLDB:    version >= 2.3.3 from              https://mvnrepository.com/artifact/org.hsqldb/hsqldb\n";
index 78f41cb20559644a2315242abfc024c444ced2c1..cd8b955f4f688e3cf9ffeca8871638de6e26217a 100644 (file)
@@ -52,6 +52,8 @@ public class JdbcH2DAO extends JdbcBaseDAO {
     private void initSqlQueries() {
         logger.debug("JDBC::initSqlQueries: '{}'", this.getClass().getSimpleName());
         sqlIfTableExists = "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='#searchTable#'";
+        sqlGetItemTables = "SELECT LOWER(table_name) AS table_name FROM information_schema.tables WHERE table_type='BASE TABLE' AND table_schema='PUBLIC' AND NOT table_name=UPPER('#itemsManageTable#')";
+        sqlGetTableColumnTypes = "SELECT column_name, data_type, is_nullable FROM information_schema.columns WHERE table_schema='#jdbcUriDatabaseName#' AND table_name='#tableName#'";
         // SQL_INSERT_ITEM_VALUE = "INSERT INTO #tableName# (TIME, VALUE) VALUES( NOW(), CAST( ? as #dbType#) )";
         // http://stackoverflow.com/questions/19768051/h2-sql-database-insert-if-the-record-does-not-exist
         sqlInsertItemValue = "MERGE INTO #tableName# (TIME, VALUE) VALUES( #tablePrimaryValue#, CAST( ? as #dbType#) )";
@@ -69,8 +71,6 @@ public class JdbcH2DAO extends JdbcBaseDAO {
     private void initDbProps() {
         // Properties for HikariCP
         databaseProps.setProperty("driverClassName", DRIVER_CLASS_NAME);
-        // driverClassName OR BETTER USE dataSourceClassName
-        // databaseProps.setProperty("dataSourceClassName", DATA_SOURCE_CLASS_NAME);
     }
 
     /**************
index a91244bdd98778fb2cadcfc3a6416f42c4b42c50..9f83d635240b95b4099b77cf188bbe2b00a2fe13 100644 (file)
@@ -26,7 +26,7 @@
                        # Some URL-Examples, 'service' identifies and activates internally the correct jdbc driver.
                        # required database url like 'jdbc:<service>:<host>[:<port>;<attributes>]'
                        # jdbc:url=jdbc:derby:./testDerby;create=true
-                       # jdbc:url=jdbc:h2:./testH2
+                       # jdbc:url=jdbc:h2:./testH2;NON_KEYWORDS=VALUE
                        # jdbc:url=jdbc:hsqldb:./testHsqlDb
                        # jdbc:url=jdbc:mariadb://192.168.0.1:3306/testMariadb
                        # jdbc:url=jdbc:mysql://192.168.0.1:3306/testMysql
@@ -40,7 +40,7 @@
                        Parameter 'service' is used as identifier for the selected jdbc driver.
                        URL-Examples:<br>
                        jdbc:derby:./testDerby;create=true<br>
-                       jdbc:h2:./testH2<br>
+                       jdbc:h2:./testH2;NON_KEYWORDS=VALUE<br>
                        jdbc:hsqldb:./testHsqlDb<br>
                        jdbc:mariadb://192.168.0.1:3306/testMariadb<br>
                        jdbc:mysql://192.168.0.1:3306/testMysql<br>
index 670c072cca8408e6f0aed24dec6d93c7cf7eef9d..b30f16ea61334cef7e98f4212ce46d00e379496c 100644 (file)
@@ -49,7 +49,7 @@ persistence.config.jdbc.tableUseRealItemNames.description = Enables Tablename pr
 persistence.config.jdbc.tableUseRealItemNames.option.true = Enable
 persistence.config.jdbc.tableUseRealItemNames.option.false = Disable
 persistence.config.jdbc.url.label = Database URL
-persistence.config.jdbc.url.description = Defines required database URL and optional path and parameters.<br> Required database url like 'jdbc:<service>:<host>[:<port>;<attributes>]'<br> Parameter 'service' is used as identifier for the selected jdbc driver. URL-Examples:<br> jdbc:derby:./testDerby;create=true<br> jdbc:h2:./testH2<br> jdbc:hsqldb:./testHsqlDb<br> jdbc:mariadb://192.168.0.1:3306/testMariadb<br> jdbc:mysql://192.168.0.1:3306/testMysql<br> jdbc:postgresql://192.168.0.1:5432/testPostgresql<br> jdbc:sqlite:./testSqlite.db
+persistence.config.jdbc.url.description = Defines required database URL and optional path and parameters.<br> Required database url like 'jdbc:<service>:<host>[:<port>;<attributes>]'<br> Parameter 'service' is used as identifier for the selected jdbc driver. URL-Examples:<br> jdbc:derby:./testDerby;create=true<br> jdbc:h2:./testH2;NON_KEYWORDS=VALUE<br> jdbc:hsqldb:./testHsqlDb<br> jdbc:mariadb://192.168.0.1:3306/testMariadb<br> jdbc:mysql://192.168.0.1:3306/testMysql<br> jdbc:postgresql://192.168.0.1:5432/testPostgresql<br> jdbc:sqlite:./testSqlite.db
 persistence.config.jdbc.user.label = Database User
 persistence.config.jdbc.user.description = Defines the database user.
 
index 730a0bd5139e7b26358ce562c216df418312bada..bb74d2c6c9831886b6e68370663e7ce251caba79 100644 (file)
@@ -15,7 +15,7 @@
 # Some URL-Examples, 'service' identifies and activates internally the correct jdbc driver.
 # required database url like 'jdbc:<service>:<host>[:<port>;<attributes>]'
 # url=jdbc:derby:./testDerby;create=true
-# url=jdbc:h2:./testH2
+# url=jdbc:h2:./testH2;NON_KEYWORDS=VALUE
 # url=jdbc:hsqldb:./testHsqlDb
 # url=jdbc:mariadb://192.168.0.1:3306/testMariadb
 # url=jdbc:mysql://192.168.0.1:3306/testMysql