Makefile.fetch                                                             |   
 1 
 Repository.mk                                                              |   
 2 
 RepositoryExternal.mk                                                      |   
47 +
 RepositoryFixes.mk                                                         |   
 2 
 config_host.mk.in                                                          |   
 3 
 configure.ac                                                               |   
78 ++
 connectivity/Configuration_hsqldb.mk                                       |   
20 
 connectivity/Jar_sdbc_hsqldb.mk                                            |   
37 +
 connectivity/JunitTest_complex.mk                                          |   
 4 
 connectivity/Library_hsqldb.mk                                             |   
62 +
 connectivity/Module_connectivity.mk                                        |   
 3 
 connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java   |   
62 +
 connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java           |   
71 +
 connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java  |   
60 +
 connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java       |   
62 +
 connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java             |  
126 +++
 connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java         |   
90 ++
 connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java  |   
34 
 connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java |  
145 +++
 connectivity/registry/hsqldb/org/openoffice/Office/DataAccess/Drivers.xcu  |   
74 ++
 connectivity/source/commontools/DriversConfig.cxx                          |   
 5 
 connectivity/source/drivers/hsqldb/HCatalog.cxx                            |  
150 ++++
 connectivity/source/drivers/hsqldb/HColumns.cxx                            |   
78 ++
 connectivity/source/drivers/hsqldb/HStorageMap.cxx                         |  
367 ++++++++++
 connectivity/source/drivers/hsqldb/HTables.cxx                             |  
186 +++++
 connectivity/source/drivers/hsqldb/HTerminateListener.cxx                  |   
52 +
 connectivity/source/drivers/hsqldb/HTerminateListener.hxx                  |   
54 +
 connectivity/source/drivers/hsqldb/HTools.cxx                              |   
53 +
 connectivity/source/drivers/hsqldb/HUser.cxx                               |  
327 ++++++++
 connectivity/source/drivers/hsqldb/HUsers.cxx                              |  
103 ++
 connectivity/source/drivers/hsqldb/HViews.cxx                              |  
158 ++++
 connectivity/source/drivers/hsqldb/Hservices.cxx                           |  
105 ++
 connectivity/source/drivers/hsqldb/StorageFileAccess.cxx                   |  
170 ++++
 connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx            |  
297 ++++++++
 connectivity/source/drivers/hsqldb/accesslog.cxx                           |   
78 ++
 connectivity/source/drivers/hsqldb/accesslog.hxx                           |  
138 +++
 connectivity/source/drivers/hsqldb/hsqldb.component                        |   
26 
 connectivity/source/inc/hsqldb/HCatalog.hxx                                |   
64 +
 connectivity/source/inc/hsqldb/HColumns.hxx                                |   
60 +
 connectivity/source/inc/hsqldb/HConnection.hxx                             |  
150 ++++
 connectivity/source/inc/hsqldb/HDriver.hxx                                 |  
140 +++
 connectivity/source/inc/hsqldb/HStorageAccess.hxx                          |   
39 +
 connectivity/source/inc/hsqldb/HStorageMap.hxx                             |   
97 ++
 connectivity/source/inc/hsqldb/HTable.hxx                                  |  
116 +++
 connectivity/source/inc/hsqldb/HTables.hxx                                 |   
56 +
 connectivity/source/inc/hsqldb/HTools.hxx                                  |   
52 +
 connectivity/source/inc/hsqldb/HUser.hxx                                   |   
77 ++
 connectivity/source/inc/hsqldb/HUsers.hxx                                  |   
55 +
 connectivity/source/inc/hsqldb/HView.hxx                                   |   
90 ++
 connectivity/source/inc/hsqldb/HViews.hxx                                  |   
55 +
 dbaccess/CppunitTest_dbaccess_RowSetClones.mk                              |   
 6 
 dbaccess/CppunitTest_dbaccess_embeddeddb_performancetest.mk                |   
 2 
 dbaccess/CppunitTest_dbaccess_hsqldb_test.mk                               |   
 6 
 dbaccess/source/core/dataaccess/ModelImpl.cxx                              |   
 2 
 dbaccess/source/core/misc/dsntypes.cxx                                     |   
 2 
 dbaccess/source/ui/dlg/generalpage.cxx                                     |   
 2 
 distro-configs/LibreOfficeCoverity.conf                                    |   
 2 
 download.lst                                                               |   
 2 
 external/Module_external.mk                                                |   
 1 
 external/hsqldb/ExternalPackage_hsqldb.mk                                  |   
16 
 external/hsqldb/ExternalProject_hsqldb.mk                                  |   
28 
 external/hsqldb/Makefile                                                   |   
 7 
 external/hsqldb/Module_hsqldb.mk                                           |   
18 
 external/hsqldb/README                                                     |   
11 
 external/hsqldb/UnpackedTarball_hsqldb.mk                                  |   
33 
 external/hsqldb/patches/fdo36824.patch                                     |   
11 
 external/hsqldb/patches/i103528.patch                                      |   
11 
 external/hsqldb/patches/i104901.patch                                      |   
27 
 external/hsqldb/patches/i96823.patch                                       |   
94 ++
 external/hsqldb/patches/i97032.patch                                       |   
10 
 external/hsqldb/patches/jdbc-4.1.patch                                     |  
320 ++++++++
 external/hsqldb/patches/limit_as_table_alias.patch                         |   
11 
 external/hsqldb/patches/multipleResultSets.patch                           |   
11 
 include/sal/log-areas.dox                                                  |   
 1 
 officecfg/registry/schema/org/openoffice/Office/DataAccess.xcs             |   
15 
 postprocess/CustomTarget_registry.mk                                       |   
 3 
 postprocess/Rdb_services.mk                                                |   
 1 
 77 files changed, 5028 insertions(+), 6 deletions(-)

New commits:
commit f4fc28aedf9c673f368ddc00f3279f6d54c1a654
Author: Sophia Schröder <sophia.schroe...@libreoffice.org>
Date:   Wed Apr 11 15:39:57 2018 +0100

    Revert "Remove dead HSQLDB driver"
    
    We cannot silently convert user data or their used file formats
    and then await them to accept it or reinstall an older version.
    
    Let us make a soft change instead of an hard (heart) break
    and avoid us to been attacked with fire and forks from our users.
    
    This reverts commit 8d381ae8d6c742a7e15bf7ad9e07b65f81728ef6.
    
    Change-Id: Ia153640935e355771acb85cf652f8fe4c21fafbb
    Reviewed-on: https://gerrit.libreoffice.org/52731
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Tamás Bunth <btom...@gmail.com>

diff --git a/Makefile.fetch b/Makefile.fetch
index 20402ba1dad8..94f697ea9270 100644
--- a/Makefile.fetch
+++ b/Makefile.fetch
@@ -131,6 +131,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_$(gb_Side).mk 
$(SRCDIR)/download.lst $(S
                $(call fetch_Optional,GPGMEPP,GPGME_TARBALL) \
                $(call fetch_Optional,GRAPHITE,GRAPHITE_TARBALL) \
                $(call fetch_Optional,HARFBUZZ,HARFBUZZ_TARBALL) \
+               $(call fetch_Optional,HSQLDB,HSQLDB_TARBALL) \
                $(call fetch_Optional,HUNSPELL,HUNSPELL_TARBALL) \
                $(call fetch_Optional,HYPHEN,HYPHEN_TARBALL) \
                $(call fetch_Optional,ICU,ICU_TARBALL) \
diff --git a/Repository.mk b/Repository.mk
index c57906d74c20..69bcdae4d396 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -604,6 +604,7 @@ $(eval $(call 
gb_Helper_register_libraries_for_install,PLAINLIBS_OOO,ooo, \
        dict_ja \
        dict_zh \
        embobj \
+       $(if $(ENABLE_JAVA),hsqldb) \
        i18nutil \
        index_data \
        $(if $(and $(ENABLE_GTK3), $(filter LINUX %BSD SOLARIS,$(OS))), 
libreofficekitgtk) \
@@ -738,6 +739,7 @@ $(eval $(call gb_Helper_register_jars_for_install,OOO,ooo, \
        $(if $(filter-out MACOSX,$(OS)),officebean) \
        query \
        report \
+       sdbc_hsqldb \
        smoketest \
        table \
        unoil \
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index f6144e4fa613..aecbd71b8b43 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -2856,6 +2856,26 @@ $(call gb_LinkTarget_set_include,$(1),\
 )
 endef
 
+ifneq ($(SYSTEM_HSQLDB),)
+
+define gb_LinkTarget__use_hsqldb
+
+$(call gb_LinkTarget_add_defs,$(1),\
+       -DSYSTEM_HSQLDB \
+       -DHSQLDB_JAR=\""file://$(HSQLDB_JAR)"\" \
+)
+
+endef
+
+else # !SYSTEM_HSQLDB
+
+define gb_LinkTarget__use_hsqldb
+
+endef
+
+endif # SYSTEM_HSQLDB
+
+
 ifneq ($(SYSTEM_OPENLDAP),)
 
 define gb_LinkTarget__use_openldap
@@ -3612,6 +3632,33 @@ endef
 
 ### Jars ############################################################
 
+ifneq ($(SYSTEM_HSQLDB),)
+
+define gb_Jar__use_hsqldb
+$(call gb_Jar_use_system_jar,$(1),$(HSQLDB_JAR))
+endef
+define gb_JunitTest__use_hsqldb
+$(call gb_JunitTest_use_system_jar,$(1),$(HSQLDB_JAR))
+endef
+
+else # !SYSTEM_HSQLDB
+
+ifeq ($(ENABLE_JAVA),TRUE)
+$(eval $(call gb_Helper_register_jars_for_install,OOO,ooo, \
+       hsqldb \
+))
+endif
+
+define gb_Jar__use_hsqldb
+$(call gb_Jar_use_jar,$(1),hsqldb)
+endef
+define gb_JunitTest__use_hsqldb
+$(call gb_JunitTest_use_jar,$(1),hsqldb)
+endef
+
+endif # SYSTEM_HSQLDB
+
+
 ifeq ($(ENABLE_SCRIPTING_BEANSHELL),TRUE)
 
 ifneq ($(SYSTEM_BSH),)
diff --git a/RepositoryFixes.mk b/RepositoryFixes.mk
index a8536f389e0d..82c0701e59dd 100644
--- a/RepositoryFixes.mk
+++ b/RepositoryFixes.mk
@@ -45,6 +45,8 @@ gb_Library_FILENAMES := \
     $(subst jpipe:libjpipe.dylib,jpipe:libjpipe.jnilib,$(gb_Library_FILENAMES))
 gb_Library_FILENAMES := \
     $(subst juh:libjuh.dylib,juh:libjuh.jnilib,$(gb_Library_FILENAMES))
+gb_Library_FILENAMES := \
+    $(subst 
hsqldb:libhsqldb.dylib,hsqldb:libhsqldb.jnilib,$(gb_Library_FILENAMES))
 endif
 
 # fixes for all the libraries that are named with too much creativity and do
diff --git a/config_host.mk.in b/config_host.mk.in
index 8a0722336fd7..965cdaf6887a 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -254,6 +254,8 @@ export HAVE_POSIX_FALLOCATE=@HAVE_POSIX_FALLOCATE@
 export HELP_COMMON_ONLY=@HELP_COMMON_ONLY@
 export HELP_ONLINE=@HELP_ONLINE@
 export HOST_PLATFORM=@host@
+export HSQLDB_JAR=@HSQLDB_JAR@
+export HSQLDB_USE_JDBC_4_1=@HSQLDB_USE_JDBC_4_1@
 export HUNSPELL_CFLAGS=$(gb_SPACE)@HUNSPELL_CFLAGS@
 export HUNSPELL_LIBS=$(gb_SPACE)@HUNSPELL_LIBS@
 export HYPHEN_LIB=$(gb_SPACE)@HYPHEN_LIB@
@@ -526,6 +528,7 @@ export SYSTEM_GLM=@SYSTEM_GLM@
 export SYSTEM_GPGMEPP=@SYSTEM_GPGMEPP@
 export SYSTEM_GRAPHITE=@SYSTEM_GRAPHITE@
 export SYSTEM_HARFBUZZ=@SYSTEM_HARFBUZZ@
+export SYSTEM_HSQLDB=@SYSTEM_HSQLDB@
 export SYSTEM_HUNSPELL=@SYSTEM_HUNSPELL@
 export SYSTEM_HYPH=@SYSTEM_HYPH@
 export SYSTEM_ICU=@SYSTEM_ICU@
diff --git a/configure.ac b/configure.ac
index ce3dcd67f1d1..e4f2bb53770d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1739,6 +1739,15 @@ AC_ARG_WITH(system-libtommath,
                            [Use libtommath already on system]),,
             [with_system_libtommath="$with_system_libs"])
 
+AC_ARG_WITH(system-hsqldb,
+    AS_HELP_STRING([--with-system-hsqldb],
+        [Use hsqldb already on system.]))
+
+AC_ARG_WITH(hsqldb-jar,
+    AS_HELP_STRING([--with-hsqldb-jar=JARFILE],
+        [Specify path to jarfile manually.]),
+    HSQLDB_JAR=$withval)
+
 libo_FUZZ_ARG_ENABLE(scripting-beanshell,
     AS_HELP_STRING([--disable-scripting-beanshell],
         [Disable support for scripts in BeanShell.]),
@@ -8419,6 +8428,75 @@ fi
 AC_SUBST(SYSTEM_MYSQL_CONNECTOR_CPP)
 
 dnl ===================================================================
+dnl Check for system hsqldb
+dnl ===================================================================
+if test "$with_java" != "no"; then
+    HSQLDB_USE_JDBC_4_1=
+    AC_MSG_CHECKING([which hsqldb to use])
+    if test "$with_system_hsqldb" = "yes"; then
+        AC_MSG_RESULT([external])
+        SYSTEM_HSQLDB=TRUE
+        if test -z $HSQLDB_JAR; then
+            HSQLDB_JAR=/usr/share/java/hsqldb.jar
+        fi
+        if ! test -f $HSQLDB_JAR; then
+               AC_MSG_ERROR(hsqldb.jar not found.)
+        fi
+        AC_MSG_CHECKING([whether hsqldb is 1.8.0.x])
+        export HSQLDB_JAR
+        if $PERL -e \
+           'use Archive::Zip;
+            my $file = "$ENV{'HSQLDB_JAR'}";
+            my $zip = Archive::Zip->new( $file );
+            my $mf = $zip->contents ( "META-INF/MANIFEST.MF" );
+            if ( $mf =~ m/Specification-Version: 1.8.*/ )
+            {
+                push @l, split(/\n/, $mf);
+                foreach my $line (@l)
+                {
+                    if ($line =~ m/Specification-Version:/)
+                    {
+                        ($t, $version) = split (/:/,$line);
+                        $version =~ s/^\s//;
+                        ($a, $b, $c, $d) = split (/\./,$version);
+                        if ($c == "0" && $d > "8")
+                        {
+                            exit 0;
+                        }
+                        else
+                        {
+                            exit 1;
+                        }
+                    }
+                }
+            }
+            else
+            {
+                exit 1;
+            }'; then
+            AC_MSG_RESULT([yes])
+        else
+            AC_MSG_ERROR([no, you need hsqldb >= 1.8.0.9 but < 1.8.1])
+        fi
+    else
+        AC_MSG_RESULT([internal])
+        SYSTEM_HSQLDB=
+        BUILD_TYPE="$BUILD_TYPE HSQLDB"
+        AC_MSG_CHECKING([whether hsqldb should be built with JDBC 4.1])
+        javanumver=`$JAVAINTERPRETER -version 2>&1 | $AWK -v num=true -f 
$SRC_ROOT/solenv/bin/getcompver.awk`
+        if expr "$javanumver" '>=' 000100060000 > /dev/null; then
+            AC_MSG_RESULT([yes])
+            HSQLDB_USE_JDBC_4_1=TRUE
+        else
+            AC_MSG_RESULT([no])
+        fi
+    fi
+    AC_SUBST(SYSTEM_HSQLDB)
+    AC_SUBST(HSQLDB_JAR)
+    AC_SUBST([HSQLDB_USE_JDBC_4_1])
+fi
+
+dnl ===================================================================
 dnl Check for PostgreSQL stuff
 dnl ===================================================================
 if test "x$enable_postgresql_sdbc" != "xno"; then
diff --git a/connectivity/Configuration_hsqldb.mk 
b/connectivity/Configuration_hsqldb.mk
new file mode 100644
index 000000000000..a9528cf4973c
--- /dev/null
+++ b/connectivity/Configuration_hsqldb.mk
@@ -0,0 +1,20 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Configuration_Configuration,driver_hsqldb))
+
+$(eval $(call 
gb_Configuration_add_spool_modules,driver_hsqldb,connectivity/registry/hsqldb,\
+       org/openoffice/Office/DataAccess/Drivers-hsqldb.xcu \
+))
+
+$(eval $(call 
gb_Configuration_add_localized_datas,driver_hsqldb,connectivity/registry/hsqldb,\
+       org/openoffice/Office/DataAccess/Drivers.xcu \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/connectivity/Jar_sdbc_hsqldb.mk b/connectivity/Jar_sdbc_hsqldb.mk
new file mode 100644
index 000000000000..20cd1f8ae044
--- /dev/null
+++ b/connectivity/Jar_sdbc_hsqldb.mk
@@ -0,0 +1,37 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Jar_Jar,sdbc_hsqldb))
+
+$(eval $(call gb_Jar_use_externals,sdbc_hsqldb,\
+       hsqldb \
+))
+
+$(eval $(call gb_Jar_add_manifest_classpath,sdbc_hsqldb,\
+       $(if $(filter MACOSX,$(OS)),../../Frameworks/,..) \
+))
+
+$(eval $(call gb_Jar_set_packageroot,sdbc_hsqldb,com))
+
+$(eval $(call gb_Jar_add_packagedir,sdbc_hsqldb,org))
+
+$(eval $(call gb_Jar_add_sourcefiles,sdbc_hsqldb,\
+       connectivity/org/hsqldb/lib/FileSystemRuntimeException \
+       connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper \
+       connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries \
+       connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper \
+       connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess \
+       connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess \
+       connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess \
+       connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream \
+       connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/connectivity/JunitTest_complex.mk 
b/connectivity/JunitTest_complex.mk
index 8893562589a3..78947bfc2076 100644
--- a/connectivity/JunitTest_complex.mk
+++ b/connectivity/JunitTest_complex.mk
@@ -22,6 +22,10 @@ $(eval $(call gb_JunitTest_use_jars,connectivity_complex,\
        unoil \
 ))
 
+$(eval $(call gb_JunitTest_use_externals,connectivity_complex,\
+       hsqldb \
+))
+
 $(eval $(call gb_JunitTest_add_classes,connectivity_complex,\
        org.openoffice.test.UnoApiTest \
 ))
diff --git a/connectivity/Library_hsqldb.mk b/connectivity/Library_hsqldb.mk
new file mode 100644
index 000000000000..0685402145bb
--- /dev/null
+++ b/connectivity/Library_hsqldb.mk
@@ -0,0 +1,62 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Library_Library,hsqldb))
+
+$(eval $(call gb_Library_set_include,hsqldb,\
+       -I$(SRCDIR)/connectivity/inc \
+       -I$(SRCDIR)/connectivity/source/inc \
+       $$(INCLUDE) \
+))
+
+$(eval $(call gb_Library_use_externals,hsqldb,\
+       boost_headers \
+       hsqldb \
+))
+
+$(eval $(call gb_Library_use_sdk_api,hsqldb))
+
+$(eval $(call gb_Library_use_libraries,hsqldb,\
+       comphelper \
+       cppu \
+       cppuhelper \
+       dbtools \
+       jvmfwk \
+       sal \
+       salhelper \
+       tl \
+       utl \
+       i18nlangtag \
+))
+
+$(eval $(call 
gb_Library_set_componentfile,hsqldb,connectivity/source/drivers/hsqldb/hsqldb))
+
+$(eval $(call gb_Library_add_exception_objects,hsqldb,\
+       connectivity/source/drivers/hsqldb/HCatalog \
+       connectivity/source/drivers/hsqldb/HColumns \
+       connectivity/source/drivers/hsqldb/HConnection \
+       connectivity/source/drivers/hsqldb/HDriver \
+       connectivity/source/drivers/hsqldb/HStorageAccess \
+       connectivity/source/drivers/hsqldb/HStorageMap \
+       connectivity/source/drivers/hsqldb/HTable \
+       connectivity/source/drivers/hsqldb/HTables \
+       connectivity/source/drivers/hsqldb/HTerminateListener \
+       connectivity/source/drivers/hsqldb/HTools \
+       connectivity/source/drivers/hsqldb/HUser \
+       connectivity/source/drivers/hsqldb/HUsers \
+       connectivity/source/drivers/hsqldb/HView \
+       connectivity/source/drivers/hsqldb/HViews \
+       connectivity/source/drivers/hsqldb/Hservices \
+       connectivity/source/drivers/hsqldb/StorageFileAccess \
+       connectivity/source/drivers/hsqldb/StorageNativeInputStream \
+       connectivity/source/drivers/hsqldb/StorageNativeOutputStream \
+       connectivity/source/drivers/hsqldb/accesslog \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/connectivity/Module_connectivity.mk 
b/connectivity/Module_connectivity.mk
index 4a500eb3ea3d..3ba7ecf01d41 100644
--- a/connectivity/Module_connectivity.mk
+++ b/connectivity/Module_connectivity.mk
@@ -40,7 +40,10 @@ $(eval $(call gb_Module_add_l10n_targets,connectivity,\
 
 ifneq ($(ENABLE_JAVA),)
 $(eval $(call gb_Module_add_targets,connectivity,\
+       Configuration_hsqldb \
        Configuration_jdbc \
+       Jar_sdbc_hsqldb \
+       Library_hsqldb \
        Library_jdbc \
 ))
 endif
diff --git 
a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java 
b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java
new file mode 100644
index 000000000000..66b6f5489862
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java
@@ -0,0 +1,62 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+public class NativeInputStreamHelper extends java.io.InputStream{
+    private final String key;
+    private final String file;
+    private final StorageNativeInputStream in;
+    /** Creates a new instance of NativeInputStreamHelper */
+    public NativeInputStreamHelper(String key,String _file) {
+        file = _file;
+        this.key = key;
+        in = new StorageNativeInputStream(key,file);
+    }
+
+    @Override
+    public int read() throws java.io.IOException {
+        return in.read(key,file);
+    }
+
+    @Override
+    public int read(byte[] b, int off, int len) throws java.io.IOException {
+        return in.read(key,file,b,off,len);
+    }
+
+    @Override
+    public void close() throws java.io.IOException {
+        in.close(key,file);
+    }
+
+    @Override
+    public long skip(long n) throws java.io.IOException {
+        return in.skip(key,file,n);
+    }
+
+    @Override
+    public int available() throws java.io.IOException {
+        return in.available(key,file);
+    }
+
+    @Override
+    public int read(byte[] b) throws java.io.IOException {
+        return in.read(key,file,b);
+    }
+
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java 
b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java
new file mode 100644
index 000000000000..59541556b185
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java
@@ -0,0 +1,71 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+final class NativeLibraries {
+    public static void load() {
+        if (System.getProperty( "os.name" ).startsWith("Windows")) {
+            loadLibrary("msvcr71");
+            loadLibrary("sal3");
+            loadLibrary("dbtoolsmi");
+        }
+        loadLibrary("hsqldb");
+    }
+
+    private static void loadLibrary(String libname) {
+        // At least on Mac OS X Tiger, System.loadLibrary("hsqldb2") does not
+        // find the hsqldb2 library one directory above sdbc_hsqldb.jar, even
+        // though ".." is on the jar's Class-Path; however, the alternative
+        // code (needing Java 1.5, which is given for Mac OS X Tiger) works
+        // there:
+        try {
+            System.loadLibrary(libname);
+        } catch (UnsatisfiedLinkError e) {
+            ClassLoader cl = NativeLibraries.class.getClassLoader();
+            if (cl instanceof URLClassLoader) {
+                String sysname = System.mapLibraryName(libname);
+                // At least Oracle's 1.7.0_51 now maps to .dylib rather than
+                // .jnilib:
+                if (System.getProperty("os.name").startsWith("Mac")
+                    && sysname.endsWith(".dylib"))
+                {
+                    sysname
+                        = sysname.substring(
+                            0, sysname.length() - "dylib".length())
+                        + "jnilib";
+                }
+                URL url = ((URLClassLoader) cl).findResource(sysname);
+                if (url != null) {
+                    try {
+                        System.load(new File(url.toURI()).getAbsolutePath());
+                    } catch (Throwable t) {
+                        throw new UnsatisfiedLinkError(
+                            e.toString()+ " - " + t.toString());
+                    }
+                }
+            }
+        }
+    }
+
+    private NativeLibraries() {}
+}
diff --git 
a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java 
b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java
new file mode 100644
index 000000000000..6445f24139d4
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java
@@ -0,0 +1,60 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package com.sun.star.sdbcx.comp.hsqldb;
+
+public class NativeOutputStreamHelper extends java.io.OutputStream{
+
+    private final String key;
+    private final String file;
+    private final StorageNativeOutputStream out;
+    /** Creates a new instance of NativeOutputStreamHelper */
+    public NativeOutputStreamHelper(String key,String _file) {
+        file = _file;
+        this.key = key;
+        out = new StorageNativeOutputStream(file,key);
+    }
+
+    @Override
+    public void write(byte[] b, int off, int len)  throws java.io.IOException{
+        out.write(key,file,b, off, len);
+    }
+
+    @Override
+    public void write(byte[] b)  throws java.io.IOException{
+        out.write(key,file,b);
+    }
+
+    @Override
+    public void close()  throws java.io.IOException{
+        out.close(key,file);
+    }
+
+    @Override
+    public void write(int b)  throws java.io.IOException{
+        out.write(key,file,b);
+    }
+
+    @Override
+    public void flush()  throws java.io.IOException{
+        out.flush(key,file);
+    }
+
+    public void sync()  throws java.io.IOException{
+        out.sync(key,file);
+    }
+}
diff --git 
a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java 
b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java
new file mode 100644
index 000000000000..5a9bc8bb6c4c
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java
@@ -0,0 +1,62 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package com.sun.star.sdbcx.comp.hsqldb;
+
+public class NativeStorageAccess {
+    static { NativeLibraries.load(); }
+
+    public static final int READ            = 1;
+    private static final int SEEKABLE        = 2;
+    private static final int SEEKABLEREAD    = 3;
+    public static final int WRITE           = 4;
+    private static final int READWRITE       = 7;
+    public static final int TRUNCATE        = 8;
+
+    /** Creates a new instance of StorageAccess */
+    public NativeStorageAccess(String name,String _mode,Object key) throws 
java.io.IOException{
+        try {
+            int mode = NativeStorageAccess.SEEKABLEREAD;
+            if ( _mode.equals("rw") )
+                mode = NativeStorageAccess.READWRITE | 
NativeStorageAccess.SEEKABLE;
+
+            openStream(name, (String)key, mode);
+        } catch(Exception ex1){
+            java.io.IOException ex2 = new java.io.IOException();
+            ex2.initCause(ex1);
+            throw ex2;
+        }
+    }
+    private native void openStream(String name,String key, int mode);
+    public native void close(String name,String key) throws 
java.io.IOException;
+
+    public native long getFilePointer(String name,String key) throws 
java.io.IOException;
+
+    public native long length(String name,String key) throws 
java.io.IOException;
+
+    public native int read(String name,String key) throws java.io.IOException;
+
+    public native int read(String name,String key,byte[] b, int off, int len) 
throws java.io.IOException;
+
+
+
+    public native void seek(String name,String key,long position) throws 
java.io.IOException;
+
+    public native void write(String name,String key,byte[] b, int offset, int 
length) throws java.io.IOException;
+
+
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java 
b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java
new file mode 100644
index 000000000000..6a53d110e661
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java
@@ -0,0 +1,126 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+@SuppressWarnings("ucd")
+public class StorageAccess implements org.hsqldb.lib.Storage {
+    String key;
+    String name;
+    boolean readonly;
+    NativeStorageAccess access;
+    /** Creates a new instance of StorageAccess */
+    public StorageAccess(String name,Boolean readonly,Object key) throws 
java.io.IOException{
+        this.key = (String)key;
+        this.name = name;
+        this.readonly = readonly.booleanValue();
+        try {
+            access = new NativeStorageAccess(name,
+                    this.readonly ? "r" : "rw"
+                    ,key);
+        } catch(Exception ex1){
+            java.io.IOException ex2 = new java.io.IOException();
+            ex2.initCause(ex1);
+            throw ex2;
+        }
+    }
+    public void close() throws java.io.IOException{
+        access.close(name,key);
+    }
+
+    public long getFilePointer() throws java.io.IOException{
+        return access.getFilePointer(name,key);
+    }
+
+    public long length() throws java.io.IOException{
+        return access.length(name,key);
+    }
+
+    public int read() throws java.io.IOException{
+        return access.read(name,key);
+    }
+
+    public void read(byte[] b, int off, int len) throws java.io.IOException{
+        access.read(name,key,b,off,len);
+    }
+
+    // based on the same code that reads an int from the .data file in HSQLDB
+    public int readInt() throws java.io.IOException{
+        byte [] tmp = new byte [4];
+
+        int count = access.read(name,key,tmp,0, 4);
+
+        if (count != 4){
+            throw new java.io.IOException();
+        }
+
+        count = 0;
+        int ch0 = tmp[count++] & 0xff;
+        int ch1 = tmp[count++] & 0xff;
+        int ch2 = tmp[count++] & 0xff;
+        int ch3 = tmp[count] & 0xff;
+
+        return ((ch0 << 24) + (ch1 << 16) + (ch2 << 8) + (ch3));
+    }
+
+    public void seek(long position) throws java.io.IOException{
+        access.seek(name,key,position);
+    }
+
+    public void write(byte[] b, int offset, int length) throws 
java.io.IOException{
+        access.write(name,key,b,offset,length);
+    }
+
+    public void writeInt(int v) throws java.io.IOException{
+        byte [] oneByte = new byte [4];
+        oneByte[0] = (byte) ((v >>> 24) & 0xFF);
+        oneByte[1] = (byte) ((v >>> 16) & 0xFF);
+        oneByte[2] = (byte) ((v >>>  8) & 0xFF);
+        oneByte[3] = (byte) ((v >>>  0) & 0xFF);
+
+        write(oneByte,0,4);
+    }
+
+    public boolean isReadOnly() {
+        return readonly;
+    }
+
+    @SuppressWarnings("cast")
+    public long readLong() throws java.io.IOException {
+        return (((long) readInt()) << 32) + (((long) readInt()) & 0xFFFFFFFFL);
+    }
+
+    public boolean wasNio() {
+        return false;
+    }
+
+    public void writeLong(long v) throws java.io.IOException {
+        byte [] oneByte = new byte [8];
+
+        oneByte[0] = (byte) ((v >>> 56) & 0xFF);
+        oneByte[1] = (byte) ((v >>> 48) & 0xFF);
+        oneByte[2] = (byte) ((v >>> 40) & 0xFF);
+        oneByte[3] = (byte) ((v >>> 32) & 0xFF);
+        oneByte[4] = (byte) ((v >>> 24) & 0xFF);
+        oneByte[5] = (byte) ((v >>> 16) & 0xFF);
+        oneByte[6] = (byte) ((v >>>  8) & 0xFF);
+        oneByte[7] = (byte) ((v >>>  0) & 0xFF);
+
+        write(oneByte,0,8);
+    }
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java 
b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java
new file mode 100644
index 000000000000..0dd640c4ec57
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java
@@ -0,0 +1,90 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package com.sun.star.sdbcx.comp.hsqldb;
+
+import org.hsqldb.lib.FileAccess;
+import org.hsqldb.lib.FileSystemRuntimeException;
+
+@SuppressWarnings("ucd")
+public class StorageFileAccess implements org.hsqldb.lib.FileAccess{
+    static { NativeLibraries.load(); }
+
+    String ds_name;
+    String key;
+    /** Creates a new instance of StorageFileAccess */
+    public StorageFileAccess(Object key) throws java.lang.Exception{
+        this.key = (String)key;
+    }
+
+    public void createParentDirs(String filename) {
+    }
+
+    public boolean isStreamElement(String elementName)  {
+        return isStreamElement(key,elementName);
+    }
+
+    public java.io.InputStream openInputStreamElement(String streamName) 
throws java.io.IOException {
+        return new NativeInputStreamHelper(key,streamName);
+    }
+
+    public java.io.OutputStream openOutputStreamElement(String streamName) 
throws java.io.IOException {
+        return new NativeOutputStreamHelper(key,streamName);
+    }
+
+    public void removeElement(String filename) throws 
java.util.NoSuchElementException {
+        try {
+            if ( isStreamElement(key,filename) )
+                removeElement(key,filename);
+        } catch (java.io.IOException e) {
+           throw new FileSystemRuntimeException( e );
+       }
+    }
+
+    public void renameElement(String oldName, String newName) throws 
java.util.NoSuchElementException {
+        try {
+            if ( isStreamElement(key,oldName) ){
+                removeElement(key,newName);
+                renameElement(key,oldName, newName);
+            }
+       } catch (java.io.IOException e) {
+           throw new FileSystemRuntimeException( e );
+       }
+    }
+
+    private static class FileSync implements FileAccess.FileSync
+    {
+        private final NativeOutputStreamHelper os;
+        private FileSync(NativeOutputStreamHelper _os)
+        {
+            os = _os;
+        }
+        public void sync() throws java.io.IOException
+        {
+            os.sync();
+        }
+    }
+
+    public FileAccess.FileSync getFileSync(java.io.OutputStream os) throws 
java.io.IOException
+    {
+        return new FileSync((NativeOutputStreamHelper)os);
+    }
+
+    static native boolean isStreamElement(String key,String elementName);
+    static native void removeElement(String key,String filename) throws 
java.util.NoSuchElementException, java.io.IOException;
+    static native void renameElement(String key,String oldName, String 
newName) throws java.util.NoSuchElementException, java.io.IOException;
+}
diff --git 
a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java 
b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java
new file mode 100644
index 000000000000..cf147c9b5005
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package com.sun.star.sdbcx.comp.hsqldb;
+
+public class StorageNativeInputStream {
+    static { NativeLibraries.load(); }
+
+    /** Creates a new instance of StorageNativeInputStream */
+    public StorageNativeInputStream(String key,String _file) {
+        openStream(key,_file, NativeStorageAccess.READ);
+    }
+    private native void openStream(String key,String name, int mode);
+    public native int read(String key,String name) throws java.io.IOException;
+    public native int read(String key,String name,byte[] b, int off, int len) 
throws java.io.IOException;
+    public native void close(String key,String name) throws 
java.io.IOException;
+    public native long skip(String key,String name,long n) throws 
java.io.IOException;
+    public native int available(String key,String name) throws 
java.io.IOException;
+    public native int read(String key,String name,byte[] b) throws 
java.io.IOException;
+}
diff --git 
a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java 
b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java
new file mode 100644
index 000000000000..8cc6cb07d353
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java
@@ -0,0 +1,145 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package com.sun.star.sdbcx.comp.hsqldb;
+
+public class StorageNativeOutputStream {
+    static { NativeLibraries.load(); }
+
+    /** Creates a new instance of StorageNativeOutputStream */
+    public StorageNativeOutputStream(String _name, Object key) {
+        openStream(_name, (String)key, NativeStorageAccess.WRITE | 
NativeStorageAccess.TRUNCATE);
+    }
+
+    private native void openStream(String name,String key, int mode);
+    /**
+     * Writes <code>len</code> bytes from the specified byte array
+     * starting at offset <code>off</code> to this output stream.
+     * The general contract for <code>write(b, off, len)</code> is that
+     * some of the bytes in the array <code>b</code> are written to the
+     * output stream in order; element <code>b[off]</code> is the first
+     * byte written and <code>b[off+len-1]</code> is the last byte written
+     * by this operation.
+     * <p>
+     * The <code>write</code> method of <code>OutputStream</code> calls
+     * the write method of one argument on each of the bytes to be
+     * written out. Subclasses are encouraged to override this method and
+     * provide a more efficient implementation.
+     * <p>
+     * If <code>b</code> is <code>null</code>, a
+     * <code>NullPointerException</code> is thrown.
+     * <p>
+     * If <code>off</code> is negative, or <code>len</code> is negative, or
+     * <code>off+len</code> is greater than the length of the array
+     * <code>b</code>, then an <tt>IndexOutOfBoundsException</tt> is thrown.
+     * @param key The name of the data source.
+     * @param _file The name of the file to write to.
+     * @param b the data.
+     * @param off the start offset in the data.
+     * @param len the number of bytes to write.
+     * @exception java.io.IOException if an I/O error occurs. In particular,
+     *             an <code>IOException</code> is thrown if the output
+     *             stream is closed.
+     */
+    public native void write(String key,String _file,byte[] b, int off, int 
len) throws java.io.IOException;
+
+    /**
+     * Writes <code>b.length</code> bytes from the specified byte array
+     * to this output stream. The general contract for <code>write(b)</code>
+     * is that it should have exactly the same effect as the call
+     * <code>write(b, 0, b.length)</code>.
+     *
+     * @param      b   the data.
+     * @exception  java.io.IOException  if an I/O error occurs.
+     * @see        java.io.OutputStream#write(byte[], int, int)
+     */
+    public native void write(String key,String _file,byte[] b) throws 
java.io.IOException;
+
+    /**
+     * Closes this output stream and releases any system resources
+     * associated with this stream. The general contract of <code>close</code>
+     * is that it closes the output stream. A closed stream cannot perform
+     * output operations and cannot be reopened.
+     * <p>
+     * The <code>close</code> method of <code>OutputStream</code> does nothing.
+     * @param key The name of the data source.
+     * @param _file The name of the file to write to.
+     *
+     * @exception  java.io.IOException  if an I/O error occurs.
+     */
+    public native void close(String key,String _file) throws 
java.io.IOException;
+
+    /**
+     * Writes the specified byte to this output stream. The general
+     * contract for <code>write</code> is that one byte is written
+     * to the output stream. The byte to be written is the eight
+     * low-order bits of the argument <code>b</code>. The 24
+     * high-order bits of <code>b</code> are ignored.
+     * <p>
+     * Subclasses of <code>OutputStream</code> must provide an
+     * implementation for this method.
+     *
+     * @param key The name of the data source.
+     * @param _file The name of the file to write to.
+     * @param      b   the <code>byte</code>.
+     * @exception  java.io.IOException  if an I/O error occurs. In particular,
+     *             an <code>IOException</code> may be thrown if the
+     *             output stream has been closed.
+     */
+    public native void write(String key,String _file,int b) throws 
java.io.IOException;
+
+    /**
+     * Flushes this output stream and forces any buffered output bytes
+     * to be written out. The general contract of <code>flush</code> is
+     * that calling it is an indication that, if any bytes previously
+     * written have been buffered by the implementation of the output
+     * stream, such bytes should immediately be written to their
+     * intended destination.
+     * <p>
+     * The <code>flush</code> method of <code>OutputStream</code> does nothing.
+     * @param key The name of the data source.
+     * @param _file The name of the file to write to.
+     *
+     * @exception  java.io.IOException  if an I/O error occurs.
+     */
+    public native void flush(String key,String _file) throws 
java.io.IOException;
+
+    /**
+     * Force all system buffers to synchronize with the underlying
+     * device.  This method returns after all modified data and
+     * attributes have been written to the relevant device(s).
+     *
+     * sync is meant to be used by code that requires physical
+     * storage (such as a file) to be in a known state  For
+     * example, a class that provided a simple transaction facility
+     * might use sync to ensure that all changes to a file caused
+     * by a given transaction were recorded on a storage medium.
+     *
+     * sync only affects buffers downstream.  If
+     * any in-memory buffering is being done by the application (for
+     * example, by a BufferedOutputStream object), those buffers must
+     * be flushed (for example, by invoking
+     * OutputStream.flush) before that data will be affected by sync.
+     *
+     * @exception java.io.IOException
+     *        Thrown when the buffers cannot be flushed,
+     *        or because the system cannot guarantee that all the
+     *        buffers have been synchronized with physical media.
+     */
+    public native void sync(String key,String _file) throws 
java.io.IOException;
+
+}
diff --git 
a/connectivity/registry/hsqldb/org/openoffice/Office/DataAccess/Drivers.xcu 
b/connectivity/registry/hsqldb/org/openoffice/Office/DataAccess/Drivers.xcu
new file mode 100644
index 000000000000..59dc5b86ea21
--- /dev/null
+++ b/connectivity/registry/hsqldb/org/openoffice/Office/DataAccess/Drivers.xcu
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<oor:component-data oor:name="Drivers" 
oor:package="org.openoffice.Office.DataAccess" 
xmlns:install="http://openoffice.org/2004/installation"; 
xmlns:oor="http://openoffice.org/2001/registry"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema";>
+  <node oor:name="Installed" install:module="hsqldb">
+    <node oor:name="sdbc:embedded:hsqldb" oor:op="replace">
+      <prop oor:name="Driver">
+        <value>com.sun.star.sdbcx.comp.hsqldb.Driver</value>
+      </prop>
+      <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+        <value xml:lang="en-US">HSQLDB Embedded</value>
+      </prop>
+      <node oor:name="Features">
+        <node oor:name="UseDOSLineEnds" oor:op="replace">
+          <prop oor:name="Value" oor:type="xs:boolean">
+            <value>true</value>
+          </prop>
+        </node>
+        <node oor:name="FormsCheckRequiredFields" oor:op="replace">
+          <prop oor:name="Value" oor:type="xs:boolean">
+            <value>true</value>
+          </prop>
+        </node>
+        <node oor:name="EscapeDateTime" oor:op="replace">
+          <prop oor:name="Value" oor:type="xs:boolean">
+            <value>true</value>
+          </prop>
+        </node>
+        <node oor:name="AddIndexAppendix" oor:op="replace">
+          <prop oor:name="Value" oor:type="xs:boolean">
+            <value>false</value>
+          </prop>
+        </node>
+        <node oor:name="UseKeywordAsBeforeAlias" oor:op="replace">
+          <prop oor:name="Value" oor:type="xs:boolean">
+            <value>true</value>
+          </prop>
+        </node>
+      </node>
+      <node oor:name="MetaData">
+        <node oor:name="SupportsTableCreation" oor:op="replace">
+          <prop oor:name="Value" oor:type="xs:boolean">
+            <value>true</value>
+          </prop>
+        </node>
+        <node oor:name="UseJava" oor:op="replace">
+          <prop oor:name="Value" oor:type="xs:boolean">
+            <value>true</value>
+          </prop>
+        </node>
+        <node oor:name="AutoIncrementIsPrimaryKey" oor:op="replace">
+          <prop oor:name="Value" oor:type="xs:boolean">
+            <value>true</value>
+          </prop>
+        </node>
+      </node>
+    </node>
+  </node>
+</oor:component-data>
diff --git a/connectivity/source/commontools/DriversConfig.cxx 
b/connectivity/source/commontools/DriversConfig.cxx
index 29f5b22de880..a6b78b0d0330 100644
--- a/connectivity/source/commontools/DriversConfig.cxx
+++ b/connectivity/source/commontools/DriversConfig.cxx
@@ -76,7 +76,6 @@ namespace
 
             OUString sDriverTypeDisplayName;
             aURLPatternNode.getNodeValue("DriverTypeDisplayName") >>= 
sDriverTypeDisplayName;
-
             OSL_ENSURE(!sDriverTypeDisplayName.isEmpty(),"No valid 
DriverTypeDisplayName property!");
             if ( !sDriverTypeDisplayName.isEmpty() )
                 _rInstalledDriver.sDriverTypeDisplayName = 
sDriverTypeDisplayName;
@@ -113,7 +112,9 @@ const TInstalledDrivers& 
DriversConfigImpl::getInstalledDrivers(const uno::Refer
             {
                 TInstalledDriver aInstalledDriver;
                 
lcl_readURLPatternNode(m_aInstalled,*pPatternIter,aInstalledDriver);
-                if ( !aInstalledDriver.sDriverFactory.isEmpty() )
+                if ( !aInstalledDriver.sDriverFactory.isEmpty() &&
+                     ( aMiscOptions.IsExperimentalMode() ||
+                       aInstalledDriver.sDriverFactory != 
"com.sun.star.comp.sdbc.firebird.Driver" ))
                     m_aDrivers.emplace(*pPatternIter,aInstalledDriver);
             }
         } // if ( m_aInstalled.isValid() )
diff --git a/connectivity/source/drivers/hsqldb/HCatalog.cxx 
b/connectivity/source/drivers/hsqldb/HCatalog.cxx
new file mode 100644
index 000000000000..9824ead35dc8
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HCatalog.cxx
@@ -0,0 +1,150 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hsqldb/HCatalog.hxx>
+#include <hsqldb/HUsers.hxx>
+#include <hsqldb/HTables.hxx>
+#include <hsqldb/HViews.hxx>
+#include <com/sun/star/sdbc/SQLException.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <comphelper/types.hxx>
+
+
+using namespace connectivity;
+using namespace connectivity::hsqldb;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+OHCatalog::OHCatalog(const Reference< XConnection >& _xConnection) : 
sdbcx::OCatalog(_xConnection)
+                ,m_xConnection(_xConnection)
+{
+}
+
+void OHCatalog::refreshObjects(const Sequence< OUString >& 
_sKindOfObject,::std::vector< OUString>& _rNames)
+{
+    Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
+                                                            "%",
+                                                            "%",
+                                                            _sKindOfObject);
+    fillNames(xResult,_rNames);
+}
+
+void OHCatalog::refreshTables()
+{
+    ::std::vector< OUString> aVector;
+
+    Sequence< OUString > sTableTypes(2);
+    sTableTypes[0] = "VIEW";
+    sTableTypes[1] = "TABLE";
+
+    refreshObjects(sTableTypes,aVector);
+
+    if ( m_pTables )
+        m_pTables->reFill(aVector);
+    else
+        m_pTables.reset( new OTables(m_xMetaData,*this,m_aMutex,aVector) );
+}
+
+void OHCatalog::refreshViews()
+{
+    Sequence< OUString > aTypes { "VIEW" };
+
+    bool bSupportsViews = false;
+    try
+    {
+        Reference<XResultSet> xRes = m_xMetaData->getTableTypes();
+        Reference<XRow> xRow(xRes,UNO_QUERY);
+        while ( xRow.is() && xRes->next() )
+        {
+            if ( (bSupportsViews = 
xRow->getString(1).equalsIgnoreAsciiCase(aTypes[0])) )
+            {
+                break;
+            }
+        }
+    }
+    catch(const SQLException&)
+    {
+    }
+
+    ::std::vector< OUString> aVector;
+    if ( bSupportsViews )
+        refreshObjects(aTypes,aVector);
+
+    if ( m_pViews )
+        m_pViews->reFill(aVector);
+    else
+        m_pViews.reset( new HViews( m_xConnection, *this, m_aMutex, aVector ) 
);
+}
+
+void OHCatalog::refreshGroups()
+{
+}
+
+void OHCatalog::refreshUsers()
+{
+    ::std::vector< OUString> aVector;
+    Reference< XStatement > xStmt = m_xConnection->createStatement(  );
+    Reference< XResultSet >  xResult = xStmt->executeQuery("select User from 
hsqldb.user group by User");
+    if ( xResult.is() )
+    {
+        Reference< XRow > xRow(xResult,UNO_QUERY);
+        while( xResult->next() )
+            aVector.push_back(xRow->getString(1));
+        ::comphelper::disposeComponent(xResult);
+    }
+    ::comphelper::disposeComponent(xStmt);
+
+    if(m_pUsers)
+        m_pUsers->reFill(aVector);
+    else
+        m_pUsers.reset( new OUsers(*this,m_aMutex,aVector,m_xConnection,this) 
);
+}
+
+Any SAL_CALL OHCatalog::queryInterface( const Type & rType )
+{
+    if ( rType == cppu::UnoType<XGroupsSupplier>::get())
+        return Any();
+
+    return OCatalog::queryInterface(rType);
+}
+
+Sequence< Type > SAL_CALL OHCatalog::getTypes(  )
+{
+    Sequence< Type > aTypes = OCatalog::getTypes();
+    std::vector<Type> aOwnTypes;
+    aOwnTypes.reserve(aTypes.getLength());
+    const Type* pBegin = aTypes.getConstArray();
+    const Type* pEnd = pBegin + aTypes.getLength();
+    for(;pBegin != pEnd;++pBegin)
+    {
+        if ( !(*pBegin == cppu::UnoType<XGroupsSupplier>::get()))
+        {
+            aOwnTypes.push_back(*pBegin);
+        }
+    }
+    return Sequence< Type >(aOwnTypes.data(), aOwnTypes.size());
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/HColumns.cxx 
b/connectivity/source/drivers/hsqldb/HColumns.cxx
new file mode 100644
index 000000000000..da9b8bbd442b
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HColumns.cxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hsqldb/HColumns.hxx>
+#include <TConnection.hxx>
+
+
+using namespace ::comphelper;
+using namespace connectivity::hsqldb;
+using namespace connectivity::sdbcx;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+OHSQLColumns::OHSQLColumns( ::cppu::OWeakObject& _rParent
+                                ,::osl::Mutex& _rMutex
+                                ,const ::std::vector< OUString> &_rVector
+            ) : 
OColumnsHelper(_rParent,true/*_bCase*/,_rMutex,_rVector,true/*_bUseHardRef*/)
+{
+}
+
+Reference< XPropertySet > OHSQLColumns::createDescriptor()
+{
+    return new OHSQLColumn;
+}
+
+
+OHSQLColumn::OHSQLColumn()
+    : connectivity::sdbcx::OColumn( true/*_bCase*/ )
+{
+    construct();
+}
+
+void OHSQLColumn::construct()
+{
+    m_sAutoIncrement = "IDENTITY";
+    
registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_AUTOINCREMENTCREATION),PROPERTY_ID_AUTOINCREMENTCREATION,0,&m_sAutoIncrement,
 cppu::UnoType<decltype(m_sAutoIncrement)>::get());
+}
+
+::cppu::IPropertyArrayHelper* OHSQLColumn::createArrayHelper( sal_Int32 
/*_nId*/ ) const
+{
+    return doCreateArrayHelper();
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL OHSQLColumn::getInfoHelper()
+{
+    return *OHSQLColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
+}
+
+Sequence< OUString > SAL_CALL OHSQLColumn::getSupportedServiceNames(  )
+{
+    Sequence< OUString > aSupported { "com.sun.star.sdbcx.Column" };
+
+    return aSupported;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/HStorageMap.cxx 
b/connectivity/source/drivers/hsqldb/HStorageMap.cxx
new file mode 100644
index 000000000000..ff5df7b01fe3
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HStorageMap.cxx
@@ -0,0 +1,367 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hsqldb/HStorageMap.hxx>
+#include <comphelper/types.hxx>
+#include <com/sun/star/embed/XTransactionBroadcaster.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <osl/diagnose.h>
+#include <osl/thread.h>
+#include <uno/mapping.hxx>
+#include <algorithm>
+
+namespace connectivity
+{
+
+    namespace hsqldb
+    {
+
+        using namespace ::com::sun::star::uno;
+        using namespace ::com::sun::star::lang;
+        using namespace ::com::sun::star::embed;
+        using namespace ::com::sun::star::io;
+
+        StreamHelper::StreamHelper(const Reference< XStream>& _xStream)
+            : m_xStream(_xStream)
+        {
+        }
+
+        StreamHelper::~StreamHelper()
+        {
+            try
+            {
+                m_xStream.clear();
+                m_xSeek.clear();
+                if ( m_xInputStream.is() )
+                {
+                    m_xInputStream->closeInput();
+                    m_xInputStream.clear();
+                }
+                // this is done implicitly by the closing of the input stream
+                else if ( m_xOutputStream.is() )
+                {
+                    m_xOutputStream->closeOutput();
+                    try
+                    {
+                        ::comphelper::disposeComponent(m_xOutputStream);
+                    }
+                    catch(const DisposedException&)
+                    {
+                    }
+                    catch(const Exception&)
+                    {
+                        OSL_FAIL("Could not dispose OutputStream");
+                    }
+                    m_xOutputStream.clear();
+                }
+            }
+            catch(const Exception&)
+            {
+                OSL_FAIL("Exception caught!");
+            }
+        }
+
+        Reference< XInputStream> const & StreamHelper::getInputStream()
+        {
+            if ( !m_xInputStream.is() )
+                m_xInputStream = m_xStream->getInputStream();
+            return m_xInputStream;
+        }
+
+        Reference< XOutputStream> const & StreamHelper::getOutputStream()
+        {
+            if ( !m_xOutputStream.is() )
+                m_xOutputStream = m_xStream->getOutputStream();
+            return m_xOutputStream;
+        }
+
+        Reference< XSeekable> const & StreamHelper::getSeek()
+        {
+            if ( !m_xSeek.is() )
+                m_xSeek.set(m_xStream,UNO_QUERY);
+            return m_xSeek;
+        }
+
+        css::uno::Reference<css::embed::XStorage> StorageData::mapStorage()
+            const
+        {
+            css::uno::Environment env(css::uno::Environment::getCurrent());
+            if (!(env.is() && storageEnvironment.is())) {
+                throw css::uno::RuntimeException("cannot get environments");
+            }
+            if (env.get() == storageEnvironment.get()) {
+                return storage;
+            } else {
+                css::uno::Mapping map(storageEnvironment, env);
+                if (!map.is()) {
+                    throw css::uno::RuntimeException("cannot get mapping");
+                }
+                css::uno::Reference<css::embed::XStorage> mapped;
+                map.mapInterface(
+                    reinterpret_cast<void **>(&mapped), storage.get(),
+                    cppu::UnoType<css::embed::XStorage>::get());
+                return mapped;
+            }
+        }
+
+        TStorages& lcl_getStorageMap()
+        {
+            static TStorages s_aMap;
+            return s_aMap;
+        }
+
+        OUString lcl_getNextCount()
+        {
+            static sal_Int32 s_nCount = 0;
+            return OUString::number(s_nCount++);
+        }
+
+        OUString StorageContainer::removeURLPrefix(const OUString& _sURL,const 
OUString& _sFileURL)
+        {
+            return _sURL.copy(_sFileURL.getLength()+1);
+        }
+
+        OUString StorageContainer::removeOldURLPrefix(const OUString& _sURL)
+        {
+            OUString sRet = _sURL;
+#if defined(_WIN32)
+            sal_Int32 nIndex = sRet.lastIndexOf('\\');
+#else
+            sal_Int32 nIndex = sRet.lastIndexOf('/');
+#endif
+            if ( nIndex != -1 )
+            {
+                sRet = _sURL.copy(nIndex+1);
+            }
+            return sRet;
+
+        }
+        
/*****************************************************************************/
+        /* convert jstring to rtl_uString */
+
+        OUString StorageContainer::jstring2ustring(JNIEnv * env, jstring jstr)
+        {
+            if (env->ExceptionCheck())
+            {
+                env->ExceptionClear();
+                OSL_FAIL("ExceptionClear");
+            }
+            OUString aStr;
+            if ( jstr )
+            {
+                jboolean bCopy(true);
+                const jchar* pChar = env->GetStringChars(jstr,&bCopy);
+                jsize len = env->GetStringLength(jstr);
+                aStr = OUString(
+                    reinterpret_cast<sal_Unicode const *>(pChar), len);
+
+                if(bCopy)
+                    env->ReleaseStringChars(jstr,pChar);
+            }
+
+            if (env->ExceptionCheck())
+            {
+                env->ExceptionClear();
+                OSL_FAIL("ExceptionClear");
+            }
+            return aStr;
+        }
+
+
+        OUString StorageContainer::registerStorage(const Reference< XStorage>& 
_xStorage,const OUString& _sURL)
+        {
+            OSL_ENSURE(_xStorage.is(),"Storage is NULL!");
+            TStorages& rMap = lcl_getStorageMap();
+            // check if the storage is already in our map
+            TStorages::const_iterator aFind = 
std::find_if(rMap.begin(),rMap.end(),
+                [&_xStorage] (const TStorages::value_type& storage) {
+                    return storage.second.mapStorage() == _xStorage;
+                });
+
+            if ( aFind == rMap.end() )
+            {
+                aFind = rMap.insert(TStorages::value_type(lcl_getNextCount(), 
{_xStorage, css::uno::Environment::getCurrent(), _sURL, TStreamMap()})).first;
+            }
+
+            return aFind->first;
+        }
+
+        TStorages::mapped_type StorageContainer::getRegisteredStorage(const 
OUString& _sKey)
+        {
+            TStorages::mapped_type aRet;
+            TStorages& rMap = lcl_getStorageMap();
+            TStorages::const_iterator aFind = rMap.find(_sKey);
+            OSL_ENSURE(aFind != rMap.end(),"Storage could not be found in 
list!");
+            if ( aFind != rMap.end() )
+                aRet = aFind->second;
+
+            return aRet;
+        }
+
+        OUString StorageContainer::getRegisteredKey(const Reference< 
XStorage>& _xStorage)
+        {
+            OUString sKey;
+            OSL_ENSURE(_xStorage.is(),"Storage is NULL!");
+            TStorages& rMap = lcl_getStorageMap();
+            // check if the storage is already in our map
+            TStorages::const_iterator aFind = 
std::find_if(rMap.begin(),rMap.end(),
+                [&_xStorage] (const TStorages::value_type& storage) {
+                    return storage.second.mapStorage() == _xStorage;
+                });
+
+            if ( aFind != rMap.end() )
+                sKey = aFind->first;
+            return sKey;
+        }
+
+        void StorageContainer::revokeStorage(const OUString& _sKey,const 
Reference<XTransactionListener>& _xListener)
+        {
+            TStorages& rMap = lcl_getStorageMap();
+            TStorages::iterator aFind = rMap.find(_sKey);
+            if ( aFind != rMap.end() )
+            {
+                try
+                {
+                    if ( _xListener.is() )
+                    {
+                        Reference<XTransactionBroadcaster> 
xBroad(aFind->second.mapStorage(),UNO_QUERY);
+                        if ( xBroad.is() )
+                            xBroad->removeTransactionListener(_xListener);
+                        Reference<XTransactedObject> 
xTrans(aFind->second.mapStorage(),UNO_QUERY);
+                        if ( xTrans.is() )
+                            xTrans->commit();
+                    }
+                }
+                catch(const Exception&)
+                {
+                }
+                rMap.erase(aFind);
+            }
+        }
+
+        TStreamMap::mapped_type StorageContainer::registerStream(JNIEnv * 
env,jstring name, jstring key,sal_Int32 _nMode)
+        {
+            TStreamMap::mapped_type pHelper;
+            TStorages& rMap = lcl_getStorageMap();
+            OUString sKey = jstring2ustring(env,key);
+            TStorages::iterator aFind = rMap.find(sKey);
+            OSL_ENSURE(aFind != rMap.end(),"Storage could not be found in 
list!");
+            if ( aFind != rMap.end() )
+            {
+                TStorages::mapped_type aStoragePair = 
StorageContainer::getRegisteredStorage(sKey);
+                auto storage = aStoragePair.mapStorage();
+                OSL_ENSURE(storage.is(),"No Storage available!");
+                if ( storage.is() )
+                {
+                    OUString sOrgName = 
StorageContainer::jstring2ustring(env,name);
+                    OUString sName = 
removeURLPrefix(sOrgName,aStoragePair.url);
+                    TStreamMap::iterator aStreamFind = 
aFind->second.streams.find(sName);
+                    OSL_ENSURE( aStreamFind == aFind->second.streams.end(),"A 
Stream was already registered for this object!");
+                    if ( aStreamFind != aFind->second.streams.end() )
+                    {
+                        pHelper = aStreamFind->second;
+                    }
+                    else
+                    {
+                        try
+                        {
+                            try
+                            {
+                                pHelper.reset(new 
StreamHelper(storage->openStreamElement(sName,_nMode)));
+                            }
+                            catch(const Exception&)
+                            {
+                                OUString sStrippedName = 
removeOldURLPrefix(sOrgName);
+
+                                if ( (_nMode & ElementModes::WRITE) != 
ElementModes::WRITE )
+                                {
+                                    bool bIsStream = true;
+                                    try
+                                    {
+                                       bIsStream = 
storage->isStreamElement(sStrippedName);
+                                    }
+                                    catch(const Exception&)
+                                    {
+                                        bIsStream = false;
+                                    }
+                                    if ( !bIsStream )
+                                        return pHelper; // readonly file 
without data stream
+                                }
+                                pHelper.reset( new 
StreamHelper(storage->openStreamElement( sStrippedName, _nMode ) ) );
+                            }
+                            aFind->second.streams.emplace(sName,pHelper);
+                        }
+                        catch(const Exception& e)
+                        {
+                            SAL_WARN( "connectivity.hsqldb", "[HSQLDB-SDBC] 
caught an exception while opening a stream\n"
+                                "Name: " << sName
+                                << "\nMode: 0x" <<  ( _nMode < 16 ? "0" : "")
+                                << std::hex << _nMode );
+                            StorageContainer::throwJavaException(e,env);
+                        }
+                    }
+                }
+            }
+            return pHelper;
+        }
+
+        void StorageContainer::revokeStream( JNIEnv * env,jstring name, 
jstring key)
+        {
+            TStorages& rMap = lcl_getStorageMap();
+            TStorages::iterator aFind = rMap.find(jstring2ustring(env,key));
+            OSL_ENSURE(aFind != rMap.end(),"Storage could not be found in 
list!");
+            if ( aFind != rMap.end() )
+                
aFind->second.streams.erase(removeURLPrefix(jstring2ustring(env,name),aFind->second.url));
+        }
+
+        TStreamMap::mapped_type StorageContainer::getRegisteredStream( JNIEnv 
* env,jstring name, jstring key)
+        {
+            TStreamMap::mapped_type  pRet;
+            TStorages& rMap = lcl_getStorageMap();
+            TStorages::const_iterator aFind = 
rMap.find(jstring2ustring(env,key));
+            OSL_ENSURE(aFind != rMap.end(),"Storage could not be found in 
list!");
+            if ( aFind != rMap.end() )
+            {
+                TStreamMap::const_iterator aStreamFind = 
aFind->second.streams.find(removeURLPrefix(jstring2ustring(env,name),aFind->second.url));
+                if ( aStreamFind != aFind->second.streams.end() )
+                    pRet = aStreamFind->second;
+            }
+
+            return pRet;
+        }
+
+        void StorageContainer::throwJavaException(const Exception& 
_aException,JNIEnv * env)
+        {
+            if (env->ExceptionCheck())
+                env->ExceptionClear();
+            SAL_WARN("connectivity.hsqldb", "forwarding Exception: " << 
_aException );
+            OString cstr( OUStringToOString(_aException.Message, 
RTL_TEXTENCODING_JAVA_UTF8 ) );
+            env->ThrowNew(env->FindClass("java/io/IOException"), 
cstr.getStr());
+        }
+
+    }   // namespace hsqldb
+
+
+}
+// namespace connectivity
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/HTables.cxx 
b/connectivity/source/drivers/hsqldb/HTables.cxx
new file mode 100644
index 000000000000..bde5866b9d92
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HTables.cxx
@@ -0,0 +1,186 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hsqldb/HTables.hxx>
+#include <hsqldb/HViews.hxx>
+#include <hsqldb/HTable.hxx>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <hsqldb/HCatalog.hxx>
+#include <comphelper/extract.hxx>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/dbexception.hxx>
+#include <cppuhelper/interfacecontainer.h>
+#include <comphelper/types.hxx>
+#include <TConnection.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace ::cppu;
+using namespace connectivity::hsqldb;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace dbtools;
+
+sdbcx::ObjectType OTables::createObject(const OUString& _rName)
+{
+    OUString sCatalog,sSchema,sTable;
+    
::dbtools::qualifiedNameComponents(m_xMetaData,_rName,sCatalog,sSchema,sTable,::dbtools::EComposeRule::InDataManipulation);
+
+    Sequence< OUString > sTableTypes(3);
+    sTableTypes[0] = "VIEW";
+    sTableTypes[1] = "TABLE";
+    sTableTypes[2] = "%";    // just to be sure to include anything else ....
+
+    Any aCatalog;
+    if ( !sCatalog.isEmpty() )
+        aCatalog <<= sCatalog;
+    Reference< XResultSet > xResult = 
m_xMetaData->getTables(aCatalog,sSchema,sTable,sTableTypes);
+
+    sdbcx::ObjectType xRet = nullptr;
+    if ( xResult.is() )
+    {
+        Reference< XRow > xRow(xResult,UNO_QUERY);
+        if ( xResult->next() ) // there can be only one table with this name
+        {
+            sal_Int32 nPrivileges = ::dbtools::getTablePrivileges( 
m_xMetaData, sCatalog, sSchema, sTable );
+            if ( m_xMetaData->isReadOnly() )
+                nPrivileges &= ~( Privilege::INSERT | Privilege::UPDATE | 
Privilege::DELETE | Privilege::CREATE | Privilege::ALTER | Privilege::DROP );
+
+            // obtain privileges
+            OHSQLTable* pRet = new OHSQLTable( this
+                                                
,static_cast<OHCatalog&>(m_rParent).getConnection()
+                                                ,sTable
+                                                ,xRow->getString(4)
+                                                ,xRow->getString(5)
+                                                ,sSchema
+                                                ,sCatalog
+                                                ,nPrivileges);
+            xRet = pRet;
+        }
+        ::comphelper::disposeComponent(xResult);
+    }
+
+    return xRet;
+}
+
+void OTables::impl_refresh(  )
+{
+    static_cast<OHCatalog&>(m_rParent).refreshTables();
+}
+
+void OTables::disposing()
+{
+m_xMetaData.clear();
+    OCollection::disposing();
+}
+
+Reference< XPropertySet > OTables::createDescriptor()
+{
+    return new 
OHSQLTable(this,static_cast<OHCatalog&>(m_rParent).getConnection());
+}
+
+// XAppend
+sdbcx::ObjectType OTables::appendObject( const OUString& _rForName, const 
Reference< XPropertySet >& descriptor )
+{
+    createTable(descriptor);
+    return createObject( _rForName );
+}
+
+// XDrop
+void OTables::dropObject(sal_Int32 _nPos,const OUString& _sElementName)
+{
+    Reference< XInterface > xObject( getObject( _nPos ) );
+    bool bIsNew = connectivity::sdbcx::ODescriptor::isNew( xObject );
+    if (!bIsNew)
+    {
+        Reference< XConnection > xConnection = 
static_cast<OHCatalog&>(m_rParent).getConnection();
+
+
+        OUString sCatalog,sSchema,sTable;
+        
::dbtools::qualifiedNameComponents(m_xMetaData,_sElementName,sCatalog,sSchema,sTable,::dbtools::EComposeRule::InDataManipulation);
+
+        OUString aSql(  "DROP " );
+
+        Reference<XPropertySet> xProp(xObject,UNO_QUERY);
+        bool bIsView;
+        if((bIsView = (xProp.is() && 
::comphelper::getString(xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))
 == "VIEW"))) // here we have a view
+            aSql += "VIEW ";
+        else
+            aSql += "TABLE ";
+
+        OUString sComposedName(
+            ::dbtools::composeTableName( m_xMetaData, sCatalog, sSchema, 
sTable, true, ::dbtools::EComposeRule::InDataManipulation ) );
+        aSql += sComposedName;
+        Reference< XStatement > xStmt = xConnection->createStatement(  );
+        if ( xStmt.is() )
+        {
+            xStmt->execute(aSql);
+            ::comphelper::disposeComponent(xStmt);
+        }
+        // if no exception was thrown we must delete it from the views
+        if ( bIsView )
+        {
+            HViews* pViews = 
static_cast<HViews*>(static_cast<OHCatalog&>(m_rParent).getPrivateViews());
+            if ( pViews && pViews->hasByName(_sElementName) )
+                pViews->dropByNameImpl(_sElementName);
+        }
+    }
+}
+
+void OTables::createTable( const Reference< XPropertySet >& descriptor )
+{
+    Reference< XConnection > xConnection = 
static_cast<OHCatalog&>(m_rParent).getConnection();
+    OUString aSql = 
::dbtools::createSqlCreateTableStatement(descriptor,xConnection);
+
+    Reference< XStatement > xStmt = xConnection->createStatement(  );
+    if ( xStmt.is() )
+    {
+        xStmt->execute(aSql);
+        ::comphelper::disposeComponent(xStmt);
+    }
+}
+
+void OTables::appendNew(const OUString& _rsNewTable)
+{
+    insertElement(_rsNewTable,nullptr);
+
+    // notify our container listeners
+    ContainerEvent aEvent(static_cast<XContainer*>(this), 
makeAny(_rsNewTable), Any(), Any());
+    OInterfaceIteratorHelper2 aListenerLoop(m_aContainerListeners);
+    while (aListenerLoop.hasMoreElements())
+        
static_cast<XContainerListener*>(aListenerLoop.next())->elementInserted(aEvent);
+}
+
+OUString OTables::getNameForObject(const sdbcx::ObjectType& _xObject)
+{
+    OSL_ENSURE(_xObject.is(),"OTables::getNameForObject: Object is NULL!");
+    return ::dbtools::composeTableName( m_xMetaData, _xObject, 
::dbtools::EComposeRule::InDataManipulation, false );
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/HTerminateListener.cxx 
b/connectivity/source/drivers/hsqldb/HTerminateListener.cxx
new file mode 100644
index 000000000000..df325efb75e8
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HTerminateListener.cxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+#include "HTerminateListener.hxx"
+#include <hsqldb/HDriver.hxx>
+
+
+namespace connectivity
+{
+
+    using namespace hsqldb;
+    using namespace ::com::sun::star::uno;
+    using namespace ::com::sun::star::lang;
+
+// XEventListener
+void SAL_CALL OConnectionController::disposing( const EventObject& /*Source*/ )
+{
+}
+
+// XTerminateListener
+void SAL_CALL OConnectionController::queryTermination( const EventObject& 
/*aEvent*/ )
+{
+    m_pDriver->flushConnections();
+}
+
+void SAL_CALL OConnectionController::notifyTermination( const EventObject& 
/*aEvent*/ )
+{
+    m_pDriver->shutdownConnections();
+}
+
+
+}   // namespace connectivity
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/HTerminateListener.hxx 
b/connectivity/source/drivers/hsqldb/HTerminateListener.hxx
new file mode 100644
index 000000000000..62e8ec79d660
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HTerminateListener.hxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_HSQLDB_HTERMINATELISTENER_HXX
+#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_HSQLDB_HTERMINATELISTENER_HXX
+
+#include <cppuhelper/implbase.hxx>
+#include <com/sun/star/frame/XTerminateListener.hpp>
+
+
+namespace connectivity
+{
+
+
+    namespace hsqldb
+    {
+        class ODriverDelegator;
+        class OConnectionController : public ::cppu::WeakImplHelper< 
css::frame::XTerminateListener >
+        {
+            ODriverDelegator* m_pDriver;
+            protected:
+                virtual ~OConnectionController() override {m_pDriver = 
nullptr;}
+            public:
+                explicit OConnectionController(ODriverDelegator* _pDriver) : 
m_pDriver(_pDriver){}
+
+                // XEventListener
+                virtual void SAL_CALL disposing( const css::lang::EventObject& 
Source ) override;
+
+                // XTerminateListener
+                virtual void SAL_CALL queryTermination( const 
css::lang::EventObject& aEvent ) override;
+                virtual void SAL_CALL notifyTermination( const 
css::lang::EventObject& aEvent ) override;
+        };
+    }
+
+}   // namespace connectivity
+
+#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_HSQLDB_HTERMINATELISTENER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/HTools.cxx 
b/connectivity/source/drivers/hsqldb/HTools.cxx
new file mode 100644
index 000000000000..9a31ace4602b
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HTools.cxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hsqldb/HTools.hxx>
+
+
+namespace connectivity { namespace hsqldb
+{
+
+    void HTools::appendTableFilterCrit( OUStringBuffer& _inout_rBuffer, const 
OUString& _rCatalog,
+        const OUString& _rSchema, const OUString& _rName, bool _bShortForm )
+    {
+        _inout_rBuffer.append( " WHERE " );
+        if ( !_rCatalog.isEmpty() )
+        {
+            _inout_rBuffer.appendAscii( _bShortForm ? "TABLE_CAT" : 
"TABLE_CATALOG" );
+            _inout_rBuffer.append( " = '" );
+            _inout_rBuffer.append     ( _rCatalog );
+            _inout_rBuffer.append( "' AND " );
+        }
+        if ( !_rSchema.isEmpty() )
+        {
+            _inout_rBuffer.appendAscii( _bShortForm ? "TABLE_SCHEM" : 
"TABLE_SCHEMA" );
+            _inout_rBuffer.append( " = '" );
+            _inout_rBuffer.append     ( _rSchema );
+            _inout_rBuffer.append( "' AND " );
+        }
+        _inout_rBuffer.append( "TABLE_NAME = '" );
+        _inout_rBuffer.append     ( _rName );
+        _inout_rBuffer.append( "'" );
+    }
+
+
+} } // namespace connectivity::hsqldb
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/HUser.cxx 
b/connectivity/source/drivers/hsqldb/HUser.cxx
new file mode 100644
index 000000000000..5fd38f739a51
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HUser.cxx
@@ -0,0 +1,327 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hsqldb/HUser.hxx>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/dbexception.hxx>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/PrivilegeObject.hpp>
+#include <TConnection.hxx>
+#include <strings.hrc>
+
+using namespace connectivity;
+using namespace connectivity::hsqldb;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+OHSQLUser::OHSQLUser(   const css::uno::Reference< css::sdbc::XConnection >& 
_xConnection) : connectivity::sdbcx::OUser(true)
+                ,m_xConnection(_xConnection)
+{
+    construct();
+}
+
+OHSQLUser::OHSQLUser(   const css::uno::Reference< css::sdbc::XConnection >& 
_xConnection,
+                const OUString& Name
+            ) : connectivity::sdbcx::OUser(Name,true)
+                ,m_xConnection(_xConnection)
+{
+    construct();
+}
+
+void OHSQLUser::refreshGroups()
+{
+}
+
+OUserExtend::OUserExtend(   const css::uno::Reference< css::sdbc::XConnection 
>& _xConnection) : OHSQLUser(_xConnection)
+{
+    construct();
+}
+
+void OUserExtend::construct()
+{
+    
registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD),
    PROPERTY_ID_PASSWORD,0,&m_Password,::cppu::UnoType<OUString>::get());
+}
+
+cppu::IPropertyArrayHelper* OUserExtend::createArrayHelper() const
+{
+    Sequence< Property > aProps;
+    describeProperties(aProps);
+    return new cppu::OPropertyArrayHelper(aProps);
+}
+
+cppu::IPropertyArrayHelper & OUserExtend::getInfoHelper()
+{
+    return *OUserExtend_PROP::getArrayHelper();
+}
+typedef connectivity::sdbcx::OUser_BASE OUser_BASE_RBHELPER;
+
+sal_Int32 SAL_CALL OHSQLUser::getPrivileges( const OUString& objName, 
sal_Int32 objType )
+{
+    ::osl::MutexGuard aGuard(m_aMutex);
+    checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+
+    sal_Int32 nRights,nRightsWithGrant;
+    findPrivilegesAndGrantPrivileges(objName,objType,nRights,nRightsWithGrant);
+    return nRights;
+}
+
+void OHSQLUser::findPrivilegesAndGrantPrivileges(const OUString& objName, 
sal_Int32 objType,sal_Int32& nRights,sal_Int32& nRightsWithGrant)
+{
+    nRightsWithGrant = nRights = 0;
+    // first we need to create the sql stmt to select the privs
+    Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+    OUString sCatalog,sSchema,sTable;
+    
::dbtools::qualifiedNameComponents(xMeta,objName,sCatalog,sSchema,sTable,::dbtools::EComposeRule::InDataManipulation);
+    Reference<XResultSet> xRes;
+    switch(objType)
+    {
+        case PrivilegeObject::TABLE:
+        case PrivilegeObject::VIEW:
+            {
+                Any aCatalog;
+                if ( !sCatalog.isEmpty() )
+                    aCatalog <<= sCatalog;
+                xRes = xMeta->getTablePrivileges(aCatalog,sSchema,sTable);
+            }
+            break;
+
+        case PrivilegeObject::COLUMN:
+            {
+                Any aCatalog;
+                if ( !sCatalog.isEmpty() )
+                    aCatalog <<= sCatalog;
+                xRes = xMeta->getColumnPrivileges(aCatalog,sSchema,sTable,"%");
+            }
+            break;
+    }
+
+    if ( xRes.is() )
+    {
+        static const char sYes      [] = "YES";
+
+        nRightsWithGrant = nRights = 0;
+
+        Reference<XRow> xCurrentRow(xRes,UNO_QUERY);
+        while( xCurrentRow.is() && xRes->next() )
+        {
+            OUString sGrantee    = xCurrentRow->getString(5);
+            OUString sPrivilege  = xCurrentRow->getString(6);
+            OUString sGrantable  = xCurrentRow->getString(7);
+
+            if (!m_Name.equalsIgnoreAsciiCase(sGrantee))
+                continue;
+
+            if (sPrivilege.equalsIgnoreAsciiCase("SELECT"))
+            {
+                nRights |= Privilege::SELECT;
+                if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+                    nRightsWithGrant |= Privilege::SELECT;
+            }
+            else if (sPrivilege.equalsIgnoreAsciiCase("INSERT"))
+            {
+                nRights |= Privilege::INSERT;
+                if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+                    nRightsWithGrant |= Privilege::INSERT;
+            }
+            else if (sPrivilege.equalsIgnoreAsciiCase("UPDATE"))
+            {
+                nRights |= Privilege::UPDATE;
+                if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+                    nRightsWithGrant |= Privilege::UPDATE;
+            }
+            else if (sPrivilege.equalsIgnoreAsciiCase("DELETE"))
+            {
+                nRights |= Privilege::DELETE;
+                if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+                    nRightsWithGrant |= Privilege::DELETE;
+            }
+            else if (sPrivilege.equalsIgnoreAsciiCase("READ"))
+            {
+                nRights |= Privilege::READ;
+                if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+                    nRightsWithGrant |= Privilege::READ;
+            }
+            else if (sPrivilege.equalsIgnoreAsciiCase("CREATE"))
+            {
+                nRights |= Privilege::CREATE;
+                if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+                    nRightsWithGrant |= Privilege::CREATE;
+            }
+            else if (sPrivilege.equalsIgnoreAsciiCase("ALTER"))
+            {
+                nRights |= Privilege::ALTER;
+                if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+                    nRightsWithGrant |= Privilege::ALTER;
+            }
+            else if (sPrivilege.equalsIgnoreAsciiCase("REFERENCE"))
+            {
+                nRights |= Privilege::REFERENCE;
+                if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+                    nRightsWithGrant |= Privilege::REFERENCE;
+            }
+            else if (sPrivilege.equalsIgnoreAsciiCase("DROP"))
+            {
+                nRights |= Privilege::DROP;
+                if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+                    nRightsWithGrant |= Privilege::DROP;
+            }
+        }
+        ::comphelper::disposeComponent(xRes);
+    }
+}
+
+sal_Int32 SAL_CALL OHSQLUser::getGrantablePrivileges( const OUString& objName, 
sal_Int32 objType )
+{
+    ::osl::MutexGuard aGuard(m_aMutex);
+    checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+
+    sal_Int32 nRights,nRightsWithGrant;
+    findPrivilegesAndGrantPrivileges(objName,objType,nRights,nRightsWithGrant);
+    return nRightsWithGrant;
+}
+
+void SAL_CALL OHSQLUser::grantPrivileges( const OUString& objName, sal_Int32 
objType, sal_Int32 objPrivileges )
+{
+    if ( objType != PrivilegeObject::TABLE )
+    {
+        ::connectivity::SharedResources aResources;
+        const OUString sError( 
aResources.getResourceString(STR_PRIVILEGE_NOT_GRANTED));
+        ::dbtools::throwGenericSQLException(sError,*this);
+    } // if ( objType != PrivilegeObject::TABLE )
+
+
+    ::osl::MutexGuard aGuard(m_aMutex);
+
+    OUString sPrivs = getPrivilegeString(objPrivileges);
+    if(!sPrivs.isEmpty())
+    {
+        Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+        OUString sGrant = "GRANT " +  sPrivs +
+            " ON " + 
::dbtools::quoteTableName(xMeta,objName,::dbtools::EComposeRule::InDataManipulation)
 +
+            " TO " + ::dbtools::quoteName(xMeta->getIdentifierQuoteString(), 
m_Name);
+
+        Reference<XStatement> xStmt = m_xConnection->createStatement();
+        if(xStmt.is())
+            xStmt->execute(sGrant);
+        ::comphelper::disposeComponent(xStmt);
+    }
+}
+
+void SAL_CALL OHSQLUser::revokePrivileges( const OUString& objName, sal_Int32 
objType, sal_Int32 objPrivileges )
+{
+    if ( objType != PrivilegeObject::TABLE )
+    {
+        ::connectivity::SharedResources aResources;
+        const OUString sError( 
aResources.getResourceString(STR_PRIVILEGE_NOT_REVOKED));
+        ::dbtools::throwGenericSQLException(sError,*this);
+    } // if ( objType != PrivilegeObject::TABLE )
+
+    ::osl::MutexGuard aGuard(m_aMutex);
+    checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+    OUString sPrivs = getPrivilegeString(objPrivileges);
+    if(!sPrivs.isEmpty())
+    {
+        Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+        OUString sGrant = "REVOKE " + sPrivs +
+            " ON " + 
::dbtools::quoteTableName(xMeta,objName,::dbtools::EComposeRule::InDataManipulation)
 +
+            " FROM " + ::dbtools::quoteName(xMeta->getIdentifierQuoteString(), 
m_Name);
+
+        Reference<XStatement> xStmt = m_xConnection->createStatement();
+        if(xStmt.is())
+            xStmt->execute(sGrant);
+        ::comphelper::disposeComponent(xStmt);
+    }
+}
+
+// XUser
+void SAL_CALL OHSQLUser::changePassword( const OUString& /*oldPassword*/, 
const OUString& newPassword )
+{
+    ::osl::MutexGuard aGuard(m_aMutex);
+    checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+
+    Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+
+    if( m_Name != xMeta->getUserName() )
+    {
+        ::dbtools::throwGenericSQLException("HSQLDB can only change password 
of the current user.", *this);
+    }
+
+    OUString sAlterPwd = "SET PASSWORD " +
+        ::dbtools::quoteName(xMeta->getIdentifierQuoteString(), newPassword);
+
+    Reference<XStatement> xStmt = m_xConnection->createStatement();
+    if ( xStmt.is() )
+    {
+        xStmt->execute(sAlterPwd);
+        ::comphelper::disposeComponent(xStmt);
+    }
+}
+
+OUString OHSQLUser::getPrivilegeString(sal_Int32 nRights)
+{
+    OUString sPrivs;
+    if((nRights & Privilege::INSERT) == Privilege::INSERT)
+        sPrivs += "INSERT";
+
+    if((nRights & Privilege::DELETE) == Privilege::DELETE)
+    {
+        if(!sPrivs.isEmpty())
+            sPrivs += ",";
+        sPrivs += "DELETE";
+    }
+
+    if((nRights & Privilege::UPDATE) == Privilege::UPDATE)
+    {
+        if(!sPrivs.isEmpty())
+            sPrivs += ",";
+        sPrivs += "UPDATE";
+    }
+
+    if((nRights & Privilege::ALTER) == Privilege::ALTER)
+    {
+        if(!sPrivs.isEmpty())
+            sPrivs += ",";
+        sPrivs += "ALTER";
+    }
+
+    if((nRights & Privilege::SELECT) == Privilege::SELECT)
+    {
+        if(!sPrivs.isEmpty())
+            sPrivs += ",";
+        sPrivs += "SELECT";
+    }
+
+    if((nRights & Privilege::REFERENCE) == Privilege::REFERENCE)
+    {
+        if(!sPrivs.isEmpty())
+            sPrivs += ",";
+        sPrivs += "REFERENCES";
+    }
+
+    return sPrivs;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/HUsers.cxx 
b/connectivity/source/drivers/hsqldb/HUsers.cxx
new file mode 100644
index 000000000000..c6992c9328c3
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HUsers.cxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hsqldb/HUsers.hxx>
+#include <hsqldb/HUser.hxx>
+#include <hsqldb/HTable.hxx>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <connectivity/sdbcx/IRefreshable.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include <TConnection.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::hsqldb;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+OUsers::OUsers( ::cppu::OWeakObject& _rParent,
+                ::osl::Mutex& _rMutex,
+                const ::std::vector< OUString> &_rVector,
+                const css::uno::Reference< css::sdbc::XConnection >& 
_xConnection,
+                connectivity::sdbcx::IRefreshableUsers* _pParent)
+    : sdbcx::OCollection(_rParent, true, _rMutex, _rVector)
+    ,m_xConnection(_xConnection)
+    ,m_pParent(_pParent)
+{
+}
+
+
+sdbcx::ObjectType OUsers::createObject(const OUString& _rName)
+{
+    return new OHSQLUser(m_xConnection,_rName);
+}
+
+void OUsers::impl_refresh()
+{
+    m_pParent->refreshUsers();
+}
+
+Reference< XPropertySet > OUsers::createDescriptor()
+{
+    OUserExtend* pNew = new OUserExtend(m_xConnection);
+    return pNew;
+}
+
+// XAppend
+sdbcx::ObjectType OUsers::appendObject( const OUString& _rForName, const 
Reference< XPropertySet >& descriptor )
+{
+    OUString aQuote  = m_xConnection->getMetaData()->getIdentifierQuoteString( 
 );
+    OUString sPassword;
+    
descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD))
 >>= sPassword;
+    OUString aSql =  "GRANT USAGE ON * TO " +
+        ::dbtools::quoteName(aQuote,_rForName) + " @\"%\" ";
+    if ( !sPassword.isEmpty() )
+    {
+        aSql += " IDENTIFIED BY '" + sPassword + "'";
+    }
+
+    Reference< XStatement > xStmt = m_xConnection->createStatement(  );
+    if(xStmt.is())
+        xStmt->execute(aSql);
+    ::comphelper::disposeComponent(xStmt);
+
+    return createObject( _rForName );
+}
+
+// XDrop
+void OUsers::dropObject(sal_Int32 /*nPos*/,const OUString& _sElementName)
+{
+    OUString aSql(  "REVOKE ALL ON * FROM " );
+    OUString aQuote  = m_xConnection->getMetaData()->getIdentifierQuoteString( 
 );
+    aSql += ::dbtools::quoteName(aQuote,_sElementName);
+
+    Reference< XStatement > xStmt = m_xConnection->createStatement(  );
+    if(xStmt.is())
+        xStmt->execute(aSql);
+    ::comphelper::disposeComponent(xStmt);
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/hsqldb/HViews.cxx 
b/connectivity/source/drivers/hsqldb/HViews.cxx
new file mode 100644
index 000000000000..c66d869e09a4
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HViews.cxx
@@ -0,0 +1,158 @@

... etc. - the rest is truncated
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to