Database drivers: PostgreSQL | Linux MDB | SQLite
postgresql-sdbc-driver
Content
- Introduction
- Requirements
- Download
- Installation and usage in OO3.x/OOo2.x
- Installation and usage in OO1.1.x
- Changes
- Features and know bugs
- Using the driver via the API
- Building from source
- Reporting bugs
- Outdated versions
- Author
Introduction
The postgresql SDBC Driver allows to use the postgresql database from OpenOffice.org without any wrapper layer such as odbc or jdbc.The current version 0.7.6a can be considerded as good beta quality ( with some known issues and missing features).
The driver is aimed at the OpenOffice.org versions 3.x/2.x/1.1.x, it does not work with OOo1.0.x trees.
The final aim is to have an easier to use, faster, more feature rich database driver than the jdbc-odbc solution. The current version should already allow this in most places (though I actually have never compared them feature by feature).
Requirements
Install a postgresql server if you haven't one already. The current driver version was tested using postgresql-7.3.2. It does not work with postgresql 7.2.x server version. It should work with all other currently available including 8.x versions.Install OpenOffice.org.
Download
Download the binary version of the driver (depending on your OOo version). Follow below installation instructions.Version | OOo version | Platform | Location | md5sum |
---|---|---|---|---|
0.7.6b (released 2010-08-12) | OOo 3.3 and above |
Windows, Linux x86 (multi platform package) |
http://dba.openoffice.org/drivers/ |
ae8915cfd031b2c4c0cd970f9409a736 |
0.7.6a (released 2010-02-06) | OOo 2.x -> 3.2 |
Windows, Linux x86 (multi platform package) |
http://dba.openoffice.org/drivers/ |
1723de995efd1ad69ee59b5e15e805a6 |
0.7.5 | OOo 1.1.x |
Windows, Linux x86 (multi platform package) |
http://dba.openoffice.org/drivers/ |
03484e135e2b3517a633936b211e7c7a |
Older (outdated) builds can be found below. If your platform does not appear in the above list, you can build the driver from source.
Installation with OOo 3.x/2.x
OOo 2.x |
There are two different ways to install the driver:
Then start the OpenOffice.org Base program ./sbase. In the upcoming dialog choose the option connect to an existing database. In the combobox should appear postgresql (if the it is not there, the installation of the driver has failed). In the upcoming dialog, you can enter space separated name/value pairs describing the database connection. Note that there must not be a leading nor a trailing space surrounding the attributes. At the simplest level, this string can be empty ( which means connecting to the user's database instance running on the same machine ). A typical url e.g. is dbname=pqtest host=mydatabaseserver. A full list of possible options can be found on the postgresql site . User/password can be given in the following dialog (so that the password does not appear in plain text). You can press the Test Connection button to verify, that your settings work. Then press the Finish button, and you can work with your postgresql database. Tip: Open the Tools/Table Filter dialog afterwards and deselect the schemas and tables, you don't want to work with (typically you won't want to work with the pg_catalog (postgresql intern) schema. |
Installation with OOo 1.1.x
OOo 1.1 |
In case you have used an older version of this driver, you have to deinstall the old one before. This can simply be done by deleting the postgresql-sdbc-$(VERSION).zip (e.g. 0.5.0 or 0.6.0) file from the OpenOffice1.1.0/user/uno_packages folder.
Copy the postgresql-sdbc-0.7.5-for-oo11.zip file in pkgchk tool (assuming that you have a . in your PATH). It should deinstall the old and install the new version during in one run in case you have followed the steps as described above. On success, no output is given.
Alternatively, you can install the driver for all users of a OpenOffice.org
network installation. This must be done by the user, who installed the network installation
(typically root or Administrator). All users should terminate there office before, running
offices won't see an effect until next restart and at worst may crash during or
after the installation. Place the file into the
pkgchk --shared (again assuming that you have a . in PATH). You can uninstall the package by deleting the file in the uno_packages directory and starting pkgchk (or as root pkgchk --shared) again. Adding a datasourceIn case you have used an older version of this driver, you can continue to use your earlier configured datasources.
You can add a new datasource via the common Tools/Data Sources dialog.
Click on new datasource and select postgresql from the Database type combobox.
You should currently put all connection information into url line by using the
following format (except for user/password, which optionally can be entered differently, see below ):
Format:
The URL must start with the If you want to connect with a password and you don't want to have it appear in the url, you can instead activate the second (in OOo1.1.x unnamed) tab page between General and Tables, fill in the user in the appropriate input field and check the password required box. You are now prompted for the password when connecting to the data source. After you have entered the url, you should switch to the tables tab in the same dialog. The driver connects to the database and shows the found schemas and tables. Select the schemas you want to work with (in general, you won't want to work with the pg_catalog schema). |
Supported and missing features
- Integration into OpenOffice GUI via DataSources
- Viewing, inserting and updating tables via the beamer window (press F4)
- Creation of a new table, view or index
- Structural modifications to existing tables
- Viewing and creation of table's relationships (relational keys)
- Supported data types include now strings, numbers, binaries, date and time.
- Renaming tables
You can only change the schema of table or view, when your postgresql server's version is 8.1 or later. Note that the change is not transactional, (the alter table statement does not allow this). First the driver changes the schema and if this succeeds, it tries to change the table's name. With former versions, you can only change the table's name. - Data modifcation
Modification of data in tables via the UI (e.g. via the beamer window) is only possible, when your table has a primary key and the primary key is part of the used select statement (otherwise the OOo framework has no possibility to find the row again to write the modification). - The serial datatype (and default values)
Support for serial (= auto increment ) datatype is difficult to implement, because it is not really a type in postgresql.You can create tables with serial columns. Therefor you have to choose a int or big int as data type of the column and set the autoincrement flag to true. Note, that you can only do this during creation of the table (before you press the save button the first time), as postgresql does not support serials in ALTER TABLE statements.
Additionally it is difficult to retrieve the generated value after an insertion in such a table. The driver follows two strategies here. When the table supports posgresql oids, it uses oid to find the just inserted row again. In case it does not, it queries for the structure of the primary key of the table and uses the curr_val() function to retrieve the last increment of the serial in this session.
This is a little slow (because these reflection queries are executed for every insertion). It might be sped up with cashing the reflection data when too many people complain.
- Updateable resultsets
Updateable resultsets are currently implemented for selects on simple tables only. Resultsets containing data from multiple tables raise errors in case a modification is attempted. - Creating and editing table structures
Creating and editing table structures works, but keep the following problems in mind- The table wizard does not yet work with the postgresql driver (see i74185).
- You cannot change the type (including the lengths for
fixed width types) of a column. Instead delete the column,
press save, add a column with the same name and choose your new type
and press save again. This data stored in this column is lost.
When you change the type by accident, OOo behaves somewhat strange. When you press the save button, you don't get an error message but the save button does not become disabled as it does normally. You have to close the window without saving, otherwise you are locked up in this window.
- Note also, that
all column comments are stored into the user's office
configuration and not within the postgresql database.
Consequently, the comments already stored in the postgresql
database are not shown.
This is currently a limitation in the OOo framework itself, so the framework will need to change to allow this.
- Logging
For diagnostic purposes, a rudimentary logging has been implemented in the driver. The loglevel can be set by editing a .ini or rc file in the extracted package. The file is located in the following path : ~/openoffice.org2/uno_packages/cache/uno_packages/postgresql-sdbc-0.7.6.zip.1086437099/postgresql-sdbc.unorc , where the number is different on your system. The file can be edited with a texteditor. The logevel can be set to NONE (no logging), ERROR (only errornouss situations are logged), INFO (some more verbose output) and SQL (every SQL statement sent to the server is logged including access time in milliseconds ). The data gets logged into the sdbc-pqsql.log in the program directory. It would be nice, if someone with some database knowledge woud review the queries needed to reflect the postgresql database for performance problems, but just give me hints on the internal structure of the queries. I can't do anything against the fact, that some queries are executed multiple times (this must be done in the OOo framework). - User Administration
Priviliges are not shown and cannot be modified in the user administration dialog. - Knwon issues
#i30059# | Updates may fail on tables with non-primary-indexes |
#i16426# | Table design dialog offer not-existent schema name |
- data types like clobs, blobs and arrays are not yet supported. The whole datatype handling for non-standard datatypes is crippled currently, here needs to be developed a concept first.
- Callable statements (XConnection.prepareCall())
Using the driver via the API
You may use the driver via the API directly by instantiatingorg.openoffice.comp.connectivity.pq.Driver
service. You can use the driver also from within a python process or with a standalone java/C++ program.
Building from source
Build in a OO1.1 environment (this is needed to keep up compatibility with OOo1.1). I have actually never checked, whether the driver builds in OOo2.0 env also.
Download the postgresql module from here, it
contains the makefiles to build postgresql client API. You must place the
postgresql-7.3.2 tarball into the
download directory. Build and deliver the postgresql
module.
Note, that the driver just uses the client part of the API. As postgresql
interprocess protocol is backward compatible, it shouldn't be problem to
later connect also to newer versions of the database.
Check out the connectivity project (e.g.
cvs co -r OpenOffice_1_1_rc3 connectivity
and then retrieve the postgresql driver code with this special tag OO_PQSDBC_x_y_z (where x,y,z are the major, minor, micro of the version you wish to build).
cvs update -d connectivity/source/drivers/postgresql
connectivity/workben/postgresql
cvs update -r OO_PQSDBC_0_6_1 connectivity/source/drivers/postgresql connectivity/workben/postgresql
. Build connectivity/source/drivers/postgresql. You will then find a postgresql-sdbc-0.x.y.zip
uno-package in the bin or lib output directory.
Test
In order to test your build, you need a running instance of postgresql database server and PyUNO. The test can be found in connectivity/workben/postgresql. The test syntax for the dmake command isdmake runtest
"dburl=sdbc:postgresql:dbname=pqtest"
. You should create a fresh
database pqtest (or any other name) as the test also writes data and drops
tables.
(Note, when you have never used postgresql server before and just want to test your build, this short series of calls should give you an postgresql test-server [note, that this is not the suggested way to install a postgresql server, follow the postgresql instructions therefor]).
gunzip < postgresql-7.3.2.tar.gz | tar -xvf - |
- Version 0.7.6b
- i113494 the driver caused an error on OOo3.3 startup. This was fixed (an outdated configfile was removed from the package).
- Version 0.7.6a
- i108928 the driver didn't work with OOo3.2. This was fixed (an additional configuration file within the package was necessary).
- Version 0.7.6
- i89685 numeric columns can now be edited again. The problem showed up since some OOo2.x version, it does not occur in OOo1.x. As this is the only change, there is no 0.7.6 for OOo1.x.
- Version 0.7.5
- i52352 you get now results when executing native (postgresql) queries
- minor build issues ( i80085, i77337, i77336 )
- i80904 a quoted single quote within a statement is now correctly recognized.
- There are now two different packages, one targeted at 1.1 version of OpenOffice, the other one targeted at 2.x version of OpenOffice. The linux version differ, the windows version is the same in both packages (both built in the OO1.1 build enviroment)
- Version 0.7.4a
- identical source tree to 0.7.4, just ensures, that the driver also works, when OOo2.x is started with soffice.bin. (see i77188). Works only on Linux x86 with OOo2.2 and above.
- Version 0.7.4
- Earlier versions of the driver couldn't interoperate with OOo's table wizard. There had to be done changes within the driver (integrated in 0.7.4 release) and OOo's table wizard (see i74185). The fixes for the table wizard have not yet been integrated into OOo (probably not before OOo 2.3).
- The varchar type is now reflected as varchar (You realize the change only in the table's design view, there is now the type 'Text' instead of 'Text fix').
- Regression: The linux version of 0.7.3 had logging enabled by default, therefor the driver logs information into the program directory (sdbc-pqsql.log), this has been disabled again as it should.
- Version 0.7.3
- Now both schema and table name can be changed via "table's context menu / Rename", when postgresql-server's version is 8.1 or later. Note that the change is not transactional, (the alter table statement does not allow this). First the driver changes the schema and if this succeeds, it tries to change the table's name.
- In former version, the retrieval of auto values failed, when the table/primary key column names had to be quoted. This bug has been fixed.
- The driver now builds also in OOo 2.x build environment.
- Version 0.7.2
- postgresql >= 8.1.x fully supported
In former versions, the driver could not edit/create a table with postgresql 8.1.0 and above. This has been fixed (this was, because postgresql 8.1 does some stricter SQL checking). - Type content recognition
The postgresql function, that returns the type of a certain column of a result set was not used correctly, this has been fixed. No content type recognition is needed anymore (was introduced in 0.7.1) (thx a lot for the hint from the postgresql community).
- postgresql >= 8.1.x fully supported
- Version 0.7.1
- Domain types fully supported (
63918).
In former versions, the driver could not handle columns with with domain types ( domain type columns were simply empty within the UI), now they are fully supported. - Type content recognition
61887).
When the postgresql database API does not inform about the type of a certain column in a resultset, the driver now guesses the type of the column from content of the first 100 rows within the resultset. Integers, numerics, date, time and timestamps are guessed. The is useful e.g. when you drag data into a spreadsheet. - View renaming/deletion (
61777 )
Views can now be renamed or deleted using OOo UI.
- Domain types fully supported (
63918).
- Version 0.7.0
- raised driver from alpha to beta state ( no serious bugs have been reported for the earlier versions)
- fixed several issues with the former driver version and OO2.0.x ( problems with table creation, table renaming and crashes in user administration have been fixed)
- data can now be inserted into tables without oids and the addition gets correctly reflected in the UI. This also holds for tables with auto increment values in the primary key. In former versions, this was only the case for tables with oids. However the current solution requires some additional reflection queries, which makes it a little slow and resource consuming.
- fixed a crash when executing native sql (see i52352). The bug itself is not fixed though, native sql statements still return empty resultsets only.
- adding/deleting users and password change is now supported. Privilege administration is still not supported.
- Version 0.6.2
- Tables created by OOo should now appear immediatly in the list of available tables e.g. in the beamer window. Structural changes to tables (e.g. the addition of a column) are now shown after reselecting the table in the beamer window. In earlier versions, one had to a reconnect on the data source to see the changes.
- The driver now supports arrays, however, as the OOo framework itself currently does not display arrays correctly, they are still reflected as plain strings as in earlier versions. You can only make use of this new feature by using the driver via the API.
- An annoying bug has been fixed, that led to 'Input Error' pop up windows in forms. Under certain circumstances, the 'not null' column property could be transported transported incorrectly to OOo.
- Version 0.6.1
- Data type handling
Some postgresql data types are not yet correctly suppported by the driver ( arrays, blobs and 'esoteric types' such as circle, point, etc.). In prior version, values of this type were not displayed by the driver at all. Now, they are shown in their default string representation, which also allows modification of the values.All these types get currently mapped to the OOo Memo type, this is recognizable in the Edit-table window, where they are grouped together in the type selection box.
- Named parameters in prepared statements (or subform support)
In prior versions, only a '?' as a placeholder in prepared statements was supported, which did not work out properly with subforms. Now additionally named parameters (e.g. ':x' or ':myvar') are supported, which allows full subform support.
- Data type handling
Reporting bugs
Please read through the known bugs section before reporting bugs. Create an issue and assign the issue to myself (jbu@openoffice.org).Questions should be raised in dev@dba.openoffice.org mailinglist. Please don't fire usage questions directly at myself.Outdated versions
Version | Platform | Location | md5sum |
---|---|---|---|
0.7.6 for >= OO2.x and <= OOo3.1 (released 2008-08-23) |
Windows, Linux x86 (multi platform package) |
http://dba.openoffice.org/drivers/ |
f30bd071ce0e35da6eadedbec4f6eef5 |
0.7.5 for OO2.x (released 2007-08-27) |
Windows, Linux x86 (multi platform package) |
http://dba.openoffice.org/drivers/ |
6db1a4b3b811957e4c1191ae2ba736ac |
0.7.4 (released 2007-02-16) |
Windows, Linux x86 (multi platform package) Note: For Linux x86, use this only with OpenOffice.org 1.1 (see below) |
http://dba.openoffice.org/drivers/ |
4e15fa7dcb017b66dfb060498ab92f4d |
0.7.4a(recommended for OOo2.2 and above) (released 2007-05-27) | ONLY Linux x86 with OpenOffice.org 2.2 and above (see issue i77188) |
http://dba.openoffice.org/drivers/ |
02e30ed857e836230159ab052ce21a70 |
0.7.3 (released 2007-01-08 ) | Windows, Linux x86 (multi platform package) |
http://dba.openoffice.org/drivers/ |
8586328f1e57f17e458a42da949ea174 |
0.7.2 | Windows, Linux x86 (multi platform package) |
http://dba.openoffice.org/drivers/ |
f3fa2a7b859eb5d1ccc2859a739cf620 |
0.7.1 | Windows, Linux x86 (multi platform package) |
http://dba.openoffice.org/drivers/ |
213a34341a3c9e12476f58c76e29204b |
0.7.0 | Windows, Linux x86 (multi platform package) |
http://dba.openoffice.org/drivers/ |
3d5d7996474f75cee9de20d741ffa5d8 |
0.6.2 | Windows, Linux x86 (multi platform package) |
http://dba.openoffice.org/drivers/ |
9522c14a1bc45edc3b5b3b50c99c2f9a |
0.6.1 | Windows, Linux x86 (multi platform package) |
http://dba.openoffice.org/drivers/ |
058689603b18a4f9a050e47fb35921ec |
0.6.0 | Windows, Linux x86 (multi platform package) |
http://dba.openoffice.org/drivers/ |
e7866011e976641b206b43c269fa1fcf |
0.5.0 | Windows, Linux x86, Solaris sparc (multi platform uno package) |
http://dba.openoffice.org/drivers/ |
24edb8fac50676b486dc9534a73f9e3e |
0.5.0 | Linux PPC |
ftp://ftp.sunsite.utk.edu/pub |
n.a. |