Difference between revisions of "FAQ (Base)"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (How do I setup support for 'split' HSQL databases in Base?)
m (How do I setup support for 'split' HSQL databases in Base?)
Line 112: Line 112:
 
=== How do I setup support for '[http://en.wikipedia.org/wiki/Microsoft_Access#Split_Database_Architecture split]' HSQL databases in Base? ===
 
=== How do I setup support for '[http://en.wikipedia.org/wiki/Microsoft_Access#Split_Database_Architecture split]' HSQL databases in Base? ===
  
See: [http://forum.openoffice.org/en/forum/viewtopic.php?f=83&t=61183 Wizard - Create an new split HSQL database] or follow the manual steps below. But understand that these two methods are [http://forum.openoffice.org/en/forum/viewtopic.php?p=278555#p278555 mutually exclusive].
+
See: [http://forum.openoffice.org/en/forum/viewtopic.php?f=83&t=61183 Wizard - Portable 'split' HSQL database template] or follow the manual steps below. But understand that these two methods are [http://forum.openoffice.org/en/forum/viewtopic.php?p=278555#p278555 mutually exclusive].
  
It is highly recommended that you avoid this manual, global, Class Path setup when using HSQLDB 2.3.x -- except when running in 'server mode.' Otherwise, the danger of corrupting you legacy 'embedded databases' with an inadvertent upgrade to HSQLDB 2.3.x is simply too risky. Always use a macro-enhanced Base template (.odb) as offered in the link above for single-user split-database access. So with that warning in mind, here's the steps necessary to setup a global Class Path in Base, such as for 'server mode' (multi-user) access:
+
A [http://forum.openoffice.org/en/forum/viewtopic.php?f=83&t=61183 macro-enhanced Base template] (.odb) as offered in the link above is ''highly'' recommended for single-user, split-database access. These templates '''do not''' require manual Class Path setup as outlined below. The templates use a macro-derived 'session' Class Path as opposed to a manually-setup 'global' Class Path. So unless you're running a split HSQL database in server-mode (multi-user support), there's no good reason to setup the global Class Path manually in Base. In fact, a global Class Path has the potential to corrupt your legacy 'embedded database' (.odb) files, through inadvertent upgrade of the internal database to HSQLDB 2.3.x. Once, upgraded, these 'embedded database' files become unusable. So before proceeding with the following Class Path setup steps, make good backups of all your legacy 'embedded database' files (.odb). You've been warned.
  
Create a global "Class Path" in *Office as outlined below. Java database engines are typically packaged as a single zip-archive file (.jar extension). This JAR file will normally contain all the necessary components including a JDBC driver for external connection purposes. Therefore, Base simply needs to know the path to the engine's JAR file. This one-time setup becomes necessary on each computer used to access a 'split HSQL database' without the use of a macro-enhanced Base front-end (.odb) file, or when setting up 'server mode' access to your split HSQL database.
+
 
 +
To manually setup a global "Class Path" in *Office, such as for server-mode access to a split HSQL database, follow the steps below. Java database engines are typically packaged as a single zip-archive file (.jar extension). This JAR file will normally contain all the necessary components including a JDBC driver for external connection purposes. Therefore, Base simply needs to know the path to the engine's JAR file. This one-time setup becomes necessary on each computer used to access a 'split HSQL database' without the use of a macro-enhanced Base front-end (.odb) file, such as when running the database in server-mode.
  
 
*Open the <code>Tools > Options</code> dialog
 
*Open the <code>Tools > Options</code> dialog
Line 134: Line 135:
  
 
*Click: OK twice and re-start *Office while also closing the Quickstarter (taskbar-app) manually as applicable...or simply restart your computer to make sure.
 
*Click: OK twice and re-start *Office while also closing the Quickstarter (taskbar-app) manually as applicable...or simply restart your computer to make sure.
**CAUTION: When using this global Class Path setting (as opposed to a macro-enhanced template) to setup HSQLDB 2.3.x support in Base, make a safe backup of all your databases based on the built-in HSQLDB 1.8 engine. Accidentally opening a legacy HSQLDB 1.8 database, to include your 'embedded database' files, will perform an automatic upgrade to HSQLDB 2.3.x when opened (when accessing the Tables). This upgrade will render your 'embedded database' files unusable. So unless you're running HSQLDB 2.x in 'server mode' it is highly recommended that you adopt a macro-enhanced Base template in order to avoid global Class Path setup altogether.
 
  
 
=== How do I create a new 'split' HSQL database using Base? ===
 
=== How do I create a new 'split' HSQL database using Base? ===

Revision as of 09:58, 18 December 2013


Base

Is Base a database?

Not technically. Base is strictly a graphical user interface (GUI) used primarily to connect OpenOffice documents to various databases. A Base file (.odb) is produced which connects to the database through special software drivers. This two-tiered software model is the industry standard for database applications largely due to it's flexibility, while leaving the heavy-lifting to specialized database drivers/engines with proven reliability. Base contributes only "front-end" components including the driver-connection file and various GUI elements such as table-views, stored queries, forms, reports and macros. OpenOffice is also bundled with various "back-end" components including several drivers and a nice, third-party, SQL database-engine (HSQLDB). Base also supports standard JDBC and ODBC connectivity using drivers provided by all the popular RDBMS engines including: HSQLDB (built-in), H2, PostgreSQL, MySQL, Firebird, Oracle, SQL Server, etc. These engines add full relational-database function to your project including SQL commands, role-based security, advanced data-types, stored procedures, ACID reliability, encryption, and more. So it's important to understand the distinctions as we seek to integrate the features/functions of the separate front-end and back-end components.

  • NOTE: Several drivers are included with Base. Some provide read-only data access, while others provide read-write data access. For example, the included read-only drivers provide access to existing data stored in tabular-spreadsheets (.ods/.xls), delimited text files (.csv), or popular address-book formats. The bundled "dBase" driver provides full read-write access to flat-file "dBase" tables, to include table creation and simple-query through Base (requires write-privileges to the database folder); this dBase driver adds flat-file database functionality comparable to MS Works. Base also supports standard JDBC or ODBC drivers, as well as native-SDBC drivers written specifically for *Office (see: PostgreSQL, MySQL, etc.). The bundled HSQL relational database engine relies on a native SDBC driver for its tight integration with Base, but an external JDBC driver option is also included for increased reliability and multi-user database access (see 'split HSQL database' below). A new relational database may be created automatically through Base (HSQLDB, H2, etc.), but full-scale (RDBMS's) generally require an alternate database manager for such DDL tasks -- although you can send the appropriate low-level commands using the Tools > SQL console in Base.


A full installation of *Office including Writer is necessary to access all available functions of Base. Available Base functions and configurations include:

  • Base is a database connection tool. Base can be used to generate connections to various data-sources, thereby enabling data access/integration across the *Office suite. To provide this function, a Base wizard is used to create a connection file (.odb). This standalone file is then 'registered' in *Office for universal access to the data-source. This process may be repeated to gain access to additional data-sources. Simply press the 'F4' key from any *Office application to view all registered data-sources.
    • Typical data-source usage includes:
      • Writer (mail-merge, forms),
      • Calc (pivot tables, graphs, forms),
      • Impress (dynamic slide data, graphs),
      • Base (stored queries, forms, reports).
    • Supported data sources include:
      • spreadsheets (tabular data; read-only),
      • delimited text files (CSV; read-only),
      • popular address book formats,
      • dBase tables (one table per file; read/write to include table creation),
      • SQL relational databases (multiple tables; read/write plus many additional functions).
  • Base is a well-rounded front-end. Base provides database management tools (DDL / DML), as well as, stored queries, forms, reports and macros. The associated tools include:
  • Base provides a database application development environment. Base is merely a front-end, but it's bundled with a few 'back-end' database options. These options become a source of confusion, because they run seamlessly with Base. You'll find both flat-file (non-relational) and relational database functionality included. "Flat-file" connection drivers (dBase, Spreadsheet and/or Text) may offer SQL-like functions, but don't expect them to be as extensive as those available when connecting Base to an SQL engine. Some additional function is provided by Base SubForms, which support filtering and ad hoc relationships even among flat-file tables. Beyond these Base functions, Calc 'pivot tables' offer pseudo-queries including aggregate functions, while Calc charting is suitable for reports. So flat-file tables can provide entry-level database functionality, sufficient for many home-projects including a simple contact list, inventory, etc. But when data redundancies become a liability, or the full power of SQL is desired, it's time to connect Base to an SQL engine such as the bundled HSQL database engine. In this case, the 'existing database' wizard should be used to create a 'JDBC' connection with HSQL (see the 'split database' setup steps below). This engine adds a plethora of features, functions, and query options to the mix. So, while you're not limited to the installed back-end database options, everything required to create a complete *Office database application is included with Base. A quick summary of the bundled back-end options include:
    • flat-file table (Calc spreadsheet with tabular data, CSV, or dBase file)
    • flat-file table queries (dBase file-format generated through Base; single-table query support; one table per file; similar to MS Works)
    • flat-file based functions (provided by Base through selected flat-file 'drivers' such as dBase, Text, etc.)
    • flat-file filtering and ad hoc relationships (provided by SubForms in Base/Writer/Calc)
    • flat-file pseudo queries (provided by Calc through Pivot Tables)
    • SQL relational database (multiple related tables and extensive functionality through the included HSQL database engine; similar to MS Access + MS Jet engine).
  • Base offers to create an all-in-one 'embedded database' file similar to MS Access. In this configuration, the front-end components (queries, forms, reports and macros) are packaged together with the database files produced by HSQLDB, all within a single Base (.odb) file. Unfortunately, this single-file concept has proven unreliable with Base, leading to rampant data corruption. So it's best to avoid the 'Create a new database' wizard in Base thereby avoiding 'embedded database' files (perhaps with the exception of developing prototypes or distributing examples). Fortunately, Base offers an alternative wizard which produces a robust 'split-database' configuration in which the database itself (tables and user-data) is maintained as a separate file (or files) as necessary for the proper stability. Steps for creating a new 'split-database' utilizing the built-in HSQL database-engine with Base are outlined below.


So when paired with a bundled data-source Base can be mistaken for "database." But in reality, Base contributes only connection- and front-end functionality. This distinction is admittedly blurred by the bundled database options (flat-file drivers and a relational HSQLDB engine) which are installed with *Office.

Java

Do I need Java to use Base?

Not necessarily. Java is used to run various wizards and data sources such as the built-in “HSQL relational database engine.” And Java is necessary to utilize the popular 'JDBC' connection option available with a variety of external database engines. But Base, itself, does not require Java. So while Base can offer greater function out-of-the-box with Java installed, the Java components are optional.


Data sources usable without Java include: delimited Text files (CSV), spreadsheets, address books, dBase files, as well as many relational-database options. In addition, tables and views created with MS Access are accessible on the Windows platform. The dBase option is particularly handy for creating non-relational, flat-file databases through Base, similar to MS Works. For relational database needs, Base connects to a variety of non-Java engines such as PostgreSQL, MySQL, MariaDB, Firebird, Oracle or MS SQL Server. These RDBMS's may be installed locally or on a network for database sharing among multiple users. Base connects to these full-scale RDBMS's in non-Java environments through standard ODBC, or native SDBC, drivers as available. But unlike dBase or HSQLDB, these RDBMS's require additional tools for database creation, schema development (DDL) tasks, and for daily chores such as engine start-up and shutdown...so they're not exactly "seamless" with Base. SQLite is another relational-database option with Base in non-Java environments. SQLite is not a full-scale RDBMS, but it can be adequate for smaller projects confined to a single-user (throughout the database life-cycle) and with rather basic relational-database requirements (no DATE data-types, etc.). Like the full-scale RDBMS options, SQLite installation requires third-party drivers, and additional tools for database creation and schema development (DDL) tasks. But after setup an SQLite database runs seamlessly with Base, so there's no daily administration (start/stop) involved.


Otherwise, with a Java Runtime Environment (JRE) installed (even portably) Base runs seamlessly with various Java databases including the built-in HSQLDB. This has some advantages over SQLite, and perhaps over other relational database (RDBMS) options. Like SQLite, Java database-engines are light-weight, fast, cross-platform and run seamlessly (auto start/stop) with Base. But Java databases enjoy broad support by the Base GUI including most database creation (DDL) and data manipulation (DML) tasks. And Java databases are particularly rich in features. For example, modern Java databases like HSQLDB 2.x, H2 and perhaps Apache Derby offer advanced features including: ACID transactions, modern SQL syntax, data-typing, custom functions, stored procedures, encryption, hot-backups, and advanced multi-user support (MVCC). These additional features can ease project-development to a degree. For instance Base queries, forms and reports thrive in a full-featured SQL environment, thereby avoiding macros. Something as simple as 'data-typing' enables flexible queries based on date/time fields; something that becomes a nightmare with a weak data-typed engine like SQLite. And as the need arises, these Java engines scale modestly in support of multiple, concurrent users. So Java database engines occupy a niche on the desktop and pair well with Base, expanding the scope and potential of Base projects while easing application development. Given the advantages, it's no wonder that HSQLDB 1.8 (released July 2005) was selected over SQLite as the default with Base -- albeit a rather dated/crippled version of HSQLDB by today's standards. But you're not confined to the bundled version/engine. HSQLDB 2.x and H2 are much more advanced and particularly well-suited for Base projects. You'll also find wide support for HSQLDB and H2 in the Base community forums and other support channels.


In summary, if you don't have Java (JRE), then the following functionality will not be available:

  • You will not be able to create or open all-in-one “embedded database” files.
  • You will not be able to run wizards including the table, query, form, or report wizard.
  • You will not be able to utilize the JDBC link option.
  • You will not be able to utilize, seamless, Java relational-database options such as HSQLDB 2.x and H2.

.

Why can't Base load/find my JDBC driver?

OpenOffice.org must know the path to the JDBC driver for a given Java database engine. This path is known as a "Class Path" in *Office.

To add a JDBC driver (.jar file) to the Class Path:

  • Open the Tools > Options dialog
  • Open the embedded Java dialog
  • Press the Class Path button
  • Press the Browse button to locate the .jar file associated with the Java database engine
  • Re-start *Office and close Quickstarter (tray-app) as applicable...or simply restart your computer

HSQLDB

What is HSQLDB?

HSQLDB is an open source, cross-platform, SQL, relational database management system (RDBMS). It's also known as HyperSQL or HSQL database engine. It's written in Java so a JRE (Java Runtime Environment) must be installed (or available as a portable app) in order to utilize this database engine.

Version 1.8.0.10 (circa 2005) of HSQLDB is integrated with *Office (AOO/LibO).

The integrated JDBC driver supports several HSQLDB operating modes including two with Base.

  • In-process ('file mode') provides seamless, single-user access with Base. "Seamless" implies automated database access with no need to start/stop a database server; similar to H2, dBase, and SQLite.
  • Client-server ('server mode') provides multi-user access on a network or locally from client-applications such as Base.

Is HSQLDB reliable?

Yes, HSQLDB is a robust, transactional, database engine with ACID properties and a mature code base. These same technologies are at the heart of PostgreSQL, MySQL, Oracle, DB2, MS SQL Server, etc. In addition, HSQLDB employs a transaction log with auto-recovery. An automatic backup file is also maintained if enabled. The end-user can supplement these measures by storing the database files in a folder protected by automatic backup software or cloud-sync services. It's also prudent to run database applications on a computer protected by an 'uninterruptable power supply' (UPS) or on a laptop with the battery installed. These measures avoid loss (rollback) of any buffered data in the event of a power failure. Speaking of buffered data, all transactional database engines employ a write-delay buffer to enhance performance. The buffer can be set to 0 seconds at the expense of write performance. HSQLDB uses a modest 500ms buffer by default, so new data is safely written to disk after a half-second delay. Base sets this write-delay buffer to 60 seconds for all 'embedded databases' files, which is excessive, but most folks can recover from the loss of one minute's productivity in the event of a power failure or similar event. In all cases, buffered data is written immediately to disk upon normal shutdown. Advanced, enterprise-level, reliability measures such as hot backups, clustering and replication, designed for 24/7 availability, are not available with HSQLDB 1.8 -- although hot backups are supported by HSQLDB 2.x, while clustering is oddly-enough a feature of H2 database.

So why should I avoid 'embedded databases'?

In Base parlance, an 'embedded database' is a single-file database. Specifically, this refers to the inclusion of both front-end and back-end database components within a single, zip-archive file. So with Base, an 'embedded database' is simply a zip-archive file (.odb) which includes files generated by OpenOffice as well as HSQLDB. This (.odb) file is unzipped to a temporary folder upon opening in OpenOffice. When the file is "closed," the latest contents are repackaged into a single zip-archive by OpenOffice. This re-packaging process is problematic and commonly leads to file-corruption, despite the auto-recovery feature built-into OpenOffice. The first signs of a corrupted Base .odb file is a popup dialog offering to open the file with the proper "filter" selection. In many cases the file is recoverable through tedious manual recovery. But much like recovering a crashed hard-drive, the process requires some expertise with file-recovery tools and knowledge of HSQLDB's automatic backup system.

So it's best to avoid these 'embedded database' files whenever possible. This means avoiding the wizard dubbed 'Create a new database' in Base. Thankfully, this particular wizard isn't necessary to create new HSQL databases with Base.

In fact, Base offers a robust alternative leveraging the 'Connect to an existing database' wizard. The wizard connects Base to various data-sources in a traditional 'split database' architacture. In this configuration the database files remain separate. The Base (.odb) file, in this case, contains only front-end components (connection parameters, stored queries, forms, reports, and macros). The back-end database files are accessed exclusively by their respective driver or database engine. Due to the separation of roles at the file-level, a Base crash cannot corrupt the back-end database files. This 'split' configuration is the normal Base configuration with PostgreSQL, MySQL, H2, etc. As expected, connecting Base with HSQLDB in this configuration also achieves the proper data-reliability. Everything we need to generate a 'split HSQL database' is included with Base. But manual setup is tedious, and the resulting database is scarcely portable. Things certainly don't get any easier with PostgreSQL, MySQL, etc. In response, the user-community developed macro-enhanced Base templates. These templates have become the best way to generate a new, full-featured, portable database using Base with the latest HSQLDB engine.

How do I setup support for 'split' HSQL databases in Base?

See: Wizard - Portable 'split' HSQL database template or follow the manual steps below. But understand that these two methods are mutually exclusive.

A macro-enhanced Base template (.odb) as offered in the link above is highly recommended for single-user, split-database access. These templates do not require manual Class Path setup as outlined below. The templates use a macro-derived 'session' Class Path as opposed to a manually-setup 'global' Class Path. So unless you're running a split HSQL database in server-mode (multi-user support), there's no good reason to setup the global Class Path manually in Base. In fact, a global Class Path has the potential to corrupt your legacy 'embedded database' (.odb) files, through inadvertent upgrade of the internal database to HSQLDB 2.3.x. Once, upgraded, these 'embedded database' files become unusable. So before proceeding with the following Class Path setup steps, make good backups of all your legacy 'embedded database' files (.odb). You've been warned.


To manually setup a global "Class Path" in *Office, such as for server-mode access to a split HSQL database, follow the steps below. Java database engines are typically packaged as a single zip-archive file (.jar extension). This JAR file will normally contain all the necessary components including a JDBC driver for external connection purposes. Therefore, Base simply needs to know the path to the engine's JAR file. This one-time setup becomes necessary on each computer used to access a 'split HSQL database' without the use of a macro-enhanced Base front-end (.odb) file, such as when running the database in server-mode.

  • Open the Tools > Options dialog
  • Select the Java dialog
  • Press the Class Path button
  • Press the Add Archive... button
  • Navigate among your installed programs to locate hsqldb.jar
    • To use the built-in version of HSQLDB 1.8.0.10, look for hsqldb.jar in the *Office installation path:
      • For AOO or OOo navigate to: OpenOffice.org X.x\basis\program\classes\hsqldb.jar
      • For LibreOffice navigate to: LibreOffice X.x\program\classes\hsqldb.jar
    • To use an installation of HSQLDB 2.2.8, look in the associated folder ...\lib\hsqldb.jar.
  • Click: OK twice and re-start *Office while also closing the Quickstarter (taskbar-app) manually as applicable...or simply restart your computer to make sure.

How do I create a new 'split' HSQL database using Base?

See: Wizard - Create an new split HSQL database or follow the manual steps below. But understand that these two methods are mutually exclusive.

To create a new split-database from Base:

  • Ensure you've setup the Class Path to hsqldb.jar as outlined above.
    • Note: The above 'Class Path' procedure must be accomplished on every computer used to access 'split' HSQL databases.
  • Download this pre-configured Base front-end file: mydb.file.odb (feel free to rename this file)
  • Click the file to open it in Base
  • Then click on the Tables icon to create a new 'split-database'
  • ...and you're done!
    • Note: The provided Base file is configured for "file-mode" (single-user) access to the associated HSQL database. The database files are created automatically in a dedicated folder named 'mydb' as specified in the 'data source URL' within the Base file (mydb.file.odb). The full path to the database is: \users\public\databases\mydb\mydb.*. The database path and name are flexible, but any manual changes must also be recorded in the 'Data-source URL' string as outlined below. "File mode" is a single-user access mode, but we can reconfigure this Base file for "server-mode" access to the same database thereby allowing concurrent, read/write access among multiple users. In any case, a 'split database' consists of two major components:
      • 1. A Base front-end file (such as mydb.file.odb) contains the database connection information, plus any Queries, Forms, Reports and Macros that you develop using Base;
      • 2. The back-end HSQL database files consisting of four (4) separate files containing your Tables and Data: mydb.script, mydb.properties, mydb.data, mydb.backup.
    • Note: These files makeup your portable database application, so they're best maintained in a dedicated database folder. Other supporting files may also be included in the database folder, such as your 'server mode' batch/script files (discussed in the note below). In any case, a properly configured Base "database application" will consist of at least two files including the Base (.odb) file and the database file(s). So while H2 and SQLite utilize a single file per database, when combined with Base, it's generally best to maintain a dedicated database folder per database application.


To create additional, new databases:

See: Wizard - Create an new split HSQL database or follow the manual steps below. But understand that these two methods are mutually exclusive.

  • 1. Download a new copy of 'mydb.file.odb' (feel free to rename this file), or create your own copy using the steps under the 'Alternative' heading below.
  • 2. Select Edit > Database > Properties... to access the 'Data source URL' settings.
  • 3. Then change only the folder name or the entire path to the 'mydb' database in the 'Data source URL' string.
    • For instance, change the path to:
      • \users\public\databases\contacts\mydb.*
      • \users\public\databases\inventory\mydb.*
      • \users\myname\databases\contacts\mydb.*
    • Note: You can also change the database name (from 'mydb') in this manner in order to create a new database. While this is logical, it will also affect server mode access (as opposed to file mode access). The server mode start-up and shutdown strings reference the database name ('mydb' in this case). So any change to the database name must also be applied to the start-up/shutdown strings. These strings are complex, and they're not stored within the Base file, so we typically store and run them using a convenient batch/script file. These batch/script files can remain relatively universal/unchanged as long as we keep the database name constant across database folders. store a copy of these batch/script files in each database folder for server mode access. So as a recommendation, change only the folder name within the 'data source URL' in order to create a new 'split' HSQL database, identified by folder name. Feel free to change the name of your Base (.odb) files as necessary to differentiate database access (change mydb.file.odb to AddressBook.odb perhaps matching the name of the folder).


Alternatively you can create this master Base .odb file manually using the 'Connect to an existing database' Base wizard as follows:

  • Select: File > New > Database -or- Press: Ctrl-N
  • Select Option: Connect to an existing database
  • Select Connection type: JDBC
  • Press: Next >>
  • Data Source URL (file mode): hsqldb:file:<path>/<database name>;default_schema=true;shutdown=true;hsqldb.default_table_type=cached;get_column_name=false
    • For example (database folder named 'mydb' with database also named 'mydb'):
      • hsqldb:file:/users/public/databases/mydb/mydb;default_schema=true;shutdown=true;hsqldb.default_table_type=cached;get_column_name=false
    • HSQLDB 2.x supports the wildcard character (~) to specify/derive the current user's folder:
      • hsqldb:file:~/databases/mydb/mydb;default_schema=true;shutdown=true;hsqldb.default_table_type=cached;get_column_name=false
  • JDBC driver class: org.hsqldb.jdbcDriver
  • Press: Test Class
    • Errors may indicate Class Path setup issues
    • Errors may indicate JDBC driver class syntax issues such as a space after the string: org.hsqldb.jdbcDriver
  • Press: Next >>
  • User name: SA
  • Password required: leave un-checked at this stage.
  • Press: Test Connection
    • Errors may indicate Data Source URL syntax issues
    • Errors may indicate database authentication issues. Check user name and password.
    • Errors may indicate user-access privileges (file or folder not shared) imposed by the operating system and managed by the system administrator.
  • Optionally enable database-folder portability using the macro and instructions provided here: Wizard - Create an new split HSQL database

How do I convert an "embedded database" to a "split-database" ?

Under construction...

How do I edit the Field properties of a 'split database' Table ?

Under construction...

How do I setup multi-user 'server mode' access to my HSQL database?

To run HSQLDB in 'server mode' and configure clients for multi-user access from Base:

  • Ensure you've setup the Class Path to hsqldb.jar as outlined above.
    • NOTE: Class Path setup is required on the server and on each client using an identical hsqldb.jar file.
  • Download this pre-configured Base front-end file: mydb.server.odb
  • Open it in Base,
  • Then click on the Tables icon to access an existing 'split-database' in the same folder (a new database is created automatically if none exists)...
  • ...and you're done!
    • Note: The provided Base file is configured for "server-mode" (multi-user capable) access to the associated HSQL database. The database files are created automatically in the same folder as the Base file (mydb.server.odb) with the prefix 'mydb'. If a database named 'mydb' is already present in the folder, and that database is currently running in server-mode, then Base will simply be connected to the existing database. For instance, you may have created a database named 'mydb' in that folder using 'mydb.file,odb' which runs HSQLDB automatically in file-mode. It's best to save all server-mode batch/script files used to start-up/shutdown the HSQLDB server in each database folder as well. Also consider this Windows app for server-mode management.
    • Note: Any Base front-end file (.odb) created with the 'Connect to an existing database' wizard may be re-configured for 'server-mode' access. This includes both 'mydb.file.odb' and 'mydb.server.odb'. Simply make a copy of the (.odb) file and follow the steps below to re-configure the file. Access these settings in an existing Base .odb file from the menu bar: Edit > Database > Properties... If this option is not available in Base, then your .odb file was created with the wrong Base wizard, so a new .odb file must be created as follows (don't worry, you can extract your existing embedded-database, while migrating your queries, forms, etc. in most cases).
    • Alternatively ...you can create this Base .odb file manually using the 'Connect to an existing database' Base wizard as follows:
      • Select: File > New > Database -or- Press: Ctrl-N
      • Select Option: Connect to an existing database
      • Select Connection type: JDBC
      • Press: Next >> and fill-in the 'Data Source URL' and 'JDBC driver class' as follows:
      • Data Source URL (server mode): hsqldb:hsql:// localhost or IP-address:port /;default_schema=true;get_column_name=false
        • For example with HSQLDB running on the local machine: hsqldb:hsql://localhost/;default_schema=true;get_column_name=false
        • For example with HSQLDB running on a network computer: hsqldb:hsql://192.168.1.101/;default_schema=true;get_column_name=false
      • JDBC driver class: org.hsqldb.jdbcDriver
      • Press: Test Class
        • Errors may indicate Class Path setup issues
          • Each client must have a local copy of hsqldb.jar with the Class Path setup locally
        • Errors may indicate JDBC driver class syntax issues such as a space after the string: org.hsqldb.jdbcDriver
      • Press: Next >>
      • User name: SA
      • Password required: leave un-checked at this stage
      • Press: Test Connection
        • Errors may indicate that HSQLDB is not running in server-mode
        • Errors may indicate database authentication issues. Check user name and password
        • Errors may indicate folder access privileges imposed by the operating system and managed by the system administrator
        • Errors may indicate network issues: database folder is not accessible from the client computer
        • Errors may indicate network issues: Data Source URL syntax reflects the wrong IP address or port for the database server
        • Errors may indicate network issues: Router or firewall is blocking the default port 9001 (or 554 if encrypted) to the database server
    • NOTE: each client should have a local installation of *Office with Class Path setup as previously outlined. And it's probably best to distribute separate Base (.odb) front-end files to each client in order to maximize stability and flexibility (custom user Queries, Forms, Reports, etc.). Windows clients can even run *Office/Base portably from USB flash drive with confidence (data reliability) in client-server configurations since no critical data is stored in the Base file or otherwise on the flash drive (see LibreOffice Portable & JavaPortable). On the other hand, it may be advantageous to maintain a single, shared, Base (.odb) file exclusively on the database host computer in order to ease administration and distribution tasks overall, particularly in the early phases of production use. Again, the Base file contains only front-end components, which are easily replaced with any old backup. So critical production data is not at risk even if Base crashes in this configuration due to the transactional nature of the HSQLDB engine. All critical production data is maintained on the database host computer (server) in this client-server configuration.
    • NOTE: A database 'server' does not imply a specialized server operating system. Any available networked computer capable of running *Office and Java will do as the database host (shared folder and HSQLDB server). A modern laptop with battery can be a good choice due to battery backup automation, while offering both wired and encrypted wireless access. User authentication is best handled by the database engine (RDBMS), with true security requiring protocol- and database-encryption. These features and more are available with HSQLDB 2.x, H2, and Apache Derby, as well as with enterprise-oriented options listed above.

How do I determine which version of HSQLDB is in use with Base?

In Base, open the SQL console: Tools > SQL...

  • If you suspect the default HSQLDB 1.8.0.10 engine, then type-in (copy & paste):
    • Call "org.hsqldb.Library.getDatabaseFullProductVersion"()
  • If you suspect HSQLDB 2.x, then type-in (copy & paste):
    • Select DISTINCT DATABASE_VERSION() as "HSQL Version" From INFORMATION_SCHEMA.SYSTEM_TABLES

Database Conversions

How to convert a table to CSV

  1. register the database under "Tools > Options > OpenOffice.org Base > Databases"
  2. open a calc sheet
  3. press F4
  4. choose the table in your database
  5. copy the content into the calc sheet


dBase

How can I, in dBase, create queries for more than one table?

You cannot. Queries spanning more than one table are currently not supported in OpenOffice.org's own dBase implementation. There is an issue requesting this, so if you're interested in this feature, go and vote for it.

Why can't I delete a record in my dBase Table?

You probably checked the "Display deleted records as well" option in Edit|Database|Properties, didn't you?


Spreadsheets

How can I import a spreadsheet table to a database?

(answer originally provided by Regina Henschel in users@dba.openoffice.org)

There are two ways:

  • You can create a database file which gives you access to the calc-table. You cannot alter the table within base, instead you must use the calc-table
  • You can create a new database file and import your calc table.

I prefer to use the second way:

  • Create a new, empty database or open an existing one. Leave it open.
  • Open your Spreadsheet-table.
  • Select your data in the Calc-table and copy them into the Clipboard.
  • Go to the databasefile and use Edit - Paste.

You will get the "Copy Table" dialog, which leads you through the import.

Instead of copy & paste, you can also use drag & drop.

  • Reduce the windows so that you can see the Database pane of the databasefile window beside the calc table.
  • Mark all your data in the Calc-table, including the headings.
  • Drag them to the database file window and drop them to the "Tables"-Icon in the Database-pane.

You will get the "Copy Table" dialog too.


Forms

How do I create a form with a sub form?

Look here for an excellent document (OpenOffice.org Text Document, 850K) giving you a step-by-step description.


Miscellaneous

I can access my tables with *Office, but I can't update or insert any data - why?

There are three possible reasons (counting the frequent ones only :):

  • *Office requires a table (or, more specifically, the data in a row set) to contain a primary key or a a unique index in order to allow data manipulation. Alternatively, it suffices if the driver supports bookmarks (like some ODBC drivers or the internal dBase implementation do).
    The reason for this is that this is the only secure way to ensure that the changes you do affect the proper record (in case of updates), resp. that you, later on, can work with your newly inserted record.
  • You are using a spreadsheet, a text (CSV/TXT), or an address data source. All of these are not yet writable. It's not a bug, it's a missing feature.
  • *Office asks the database (in reality its the databases driver) for the privileges (if any) the current user has for the table you want to access. If the driver doesn't report that you have INSERT/UPDATE permissions, then the respective functionality is disabled in *Office. There are various drivers out there (for various databases, most often reported is MySQL) which handle the permissions improperly, and return wrong or too few privileges. Please try the latest possible driver for your database.

Which Database Type do I use?

  • Q: I'm asked which database type I use - how do I know?
  • A: If you don't know, it's probably HSQLDB. To be sure, open the database document (.odb) in OpenOffice.org, and look into the middle part of the status bar at the bottom of the main window. It should read something like "HSQL database engine", "JDBC", "MySQL (ODBC)" ...

How are my Address Book fields mapped to OpenOffice.org columns?

Why does my table show the wrong number of records?

Base developers chose not to load all records for performance and bandwidth reasons. Unfortunately, they also chose to inform you of this incremental approach by displaying a count of only the loaded records. So initially, Base will report a smaller number of records than you actually have. To indicate this, Base will show a small asterisk (*) after the record count. So a number without asterisk 23 means there a total of 23 records in your table, while 23 (*) means there are 23 known records currently loaded, but there are additional unloaded records in the table/result-set.

This record-count display philosophy is not related to performance or bandwidth considerations. Record count retrieval is instantaneous. It's a poor design, but some workarounds may suffice (SubForm workaround / macro workaround).

Why is searching in my form/table so incredibly slow?

This is because when you search (as opposed to filter) the data with OpenOffice.org, then Base retrieves all the data from the server, and looks up itself, instead of letting the server do this. This, of course, is slow. But, though *Office's search is probably not the fastest possible on earth, it's more a problem of you doing the wrong thing to get the right results. Filter your form, to let the server do the work. More information is available in the archive of our mailing list.

Personal tools