Language

The Free and Open Productivity Suite
Released: Apache OpenOffice 4.1.15

OpenOfficeHow to register a new database driver
into OpenOffice UI?


Contents

The Problem
The Solution
The Macro

The Problem

You may want to use a new database driver for your database in OpenOffice but OpenOffice doesn't know it.

The Solution

The OpenOffice.org UI supports the extension of database drivers through a configuration entry.

Two steps have to be done before you can use your new driver with OpenOffice.
The first step is to copy the new driver in the folder $office/user/uno_packages. After that you have to run the command $office/program/pkgchk. This command register the new driver. In the future it will be possible to run only the pkgchk program to register the driver and to insert the configuration entry.
The second step is to adjust the macro and run it to insert a configuration entry.

Three names have to be set in the macro:

DriverPageDisplayName

This name will be used for the Tabpage of the new database driver.

DriverTypeDisplayName

This name will be used in the database type listbox on the general tabpage in the data source administration dialog.

DriverDsnPrefix

This name will be the prefix for the URL of the new database driver. This name has to end with a colon.

Extension

The file extension, which match to this type. Only set when it is file based driver.

The Macro

REM  *****  BASIC  *****

Sub Main
	' access the global configuration provider
	Dim aConfigProvider As Object
	aConfigProvider = createUnoService( "com.sun.star.configuration.ConfigurationProvider" )

	' create an access object for the driver settings key
	Dim aDriverSettings As Object
	Dim aParams(0) As new com.sun.star.beans.PropertyValue
	aParams(0).Name = "nodepath"
	aParams(0).Value = "/org.openoffice.Office.DataAccess/UserDefinedDriverSettings"
	aDriverSettings = aConfigProvider.createInstanceWithArguments( _
	"com.sun.star.configuration.ConfigurationUpdateAccess", _
	aParams() )

	aDrv = aDriverSettings.createInstance()

	aDrv.DriverPageDisplayName ="Ocke's own private Driver page"
	aDrv.DriverTypeDisplayName = "Neo_1" ' this name will be displayed in the Type listbox on the general tabpage
	aDrv.DriverDsnPrefix ="sdbc:matrix:"    ' this name will be the prefix of the URL
	aDrv.Extension = "*.OJ" ' will be used by the fileopen dialog

	' create an access object for the mozilla preferences node

	aDriverSettings.insertByName( "Neo_1",aDrv ) ' just a name to make it distinct


	' commit the changes done
	aDriverSettings.commitChanges
End Sub



Auhor: Ocke Janssen
Last Modified: $Date: 2004/10/15 08:12:12 $
Copyright © 2001 OpenOffice.org



Apache Software Foundation

Copyright & License | Privacy | Contact Us | Donate | Thanks

Apache, OpenOffice, OpenOffice.org and the seagull logo are registered trademarks of The Apache Software Foundation. The Apache feather logo is a trademark of The Apache Software Foundation. Other names appearing on the site may be trademarks of their respective owners.