Bananiel-1944 wrote:but I have no idea how to do that.
It seems that simply changing the path name as it appears in the bottom line would be the best, but I have no idea how to do that.
Dim oDatabase As Object, oDataSource As Object, sURL As String, sNewURL As String
Set oDatabase = ThisDatabaseDocument
sURL = Join(Split(oDatabase.URL, "%20"), " ")
Set oDataSource = oDatabase.Datasource
sNewURL = "jdbc:hsqldb:" & Left(sURL, Len(sURL) - 4) & ";default_schema=true;shutdown=true;hsqldb.default_table_type=cached;get_column_name=false"
If oDataSource.URL <> sNewURL Then oDataSource.URL = sNewURL ' To avoid file update if not necessary
F3K Total wrote:Bananiel-1944 wrote:but I have no idea how to do that.
Edit->Database->Properties
R
Bananiel-1944 wrote:I tried to put my split-database completely on a USB-stick.
Villeroy wrote:Is it a good idea to run a database on a stick?Bananiel-1944 wrote:I tried to put my split-database completely on a USB-stick.
JPL wrote:It seems that simply changing the path name as it appears in the bottom line would be the best, but I have no idea how to do that.
I use next Basic code to allow to install a split database, including its hsqldb files and the .odb file, wherever the user wants and whatever the OS (Wondows or Linux). It requires that all files are in the same directory.
- Code: Select all Expand viewCollapse view
Dim oDatabase As Object, oDataSource As Object, sURL As String, sNewURL As String
Set oDatabase = ThisDatabaseDocument
sURL = Join(Split(oDatabase.URL, "%20"), " ")
Set oDataSource = oDatabase.Datasource
sNewURL = "jdbc:hsqldb:" & Left(sURL, Len(sURL) - 4) & ";default_schema=true;shutdown=true;hsqldb.default_table_type=cached;get_column_name=false"
If oDataSource.URL <> sNewURL Then oDataSource.URL = sNewURL ' To avoid file update if not necessary
The code can be put in a routine linked to the Open Document event of the database document. The first time the Save button in the toolbar will be greyed out. As soon as the user has saved the database, the next times the macro is executed without user-visible effect.
If the database is moved again, the URL will be re-adapted.
Hoping this helps.
JPL
Bananiel-1944 wrote:In the bottom line of the db window is the text:
JDBC hsqldb:file:/home/name/.../members;default_schema=true;shutdown=true;hsqldb.default_table_type=cached;get_column_name=false
NB: the new, empty database made according to the recipe in the internet link given above gave in the bottom line the new path name /media/.../mydb (on the USB-stick)
It seems that simply changing the path name as it appears in the bottom line would be the best, but I have no idea how to do that.
I hope someone has an easy solution!
Bananiel-1944 wrote:
Oops, I realise I am using Libreoffice and not Openoffice. That may be the reason that the code above does not work for me.
I have to check on the difference in syntax (LibreOffice found a syntax error on each (!) line).
Sub Main
Dim oDatabase As Object, oDataSource As Object, sURL As String, sNewURL As String
Set oDatabase = ThisDatabaseDocument
sURL = Join(Split(oDatabase.URL, "%20"), " ")
Set oDataSource = oDatabase.Datasource
sNewURL = "jdbc:hsqldb:" & Left(sURL, Len(sURL) - 4) & ";default_schema=true;shutdown=true;hsqldb.default_table_type=cached;get_column_name=false"
If oDataSource.URL <> sNewURL Then oDataSource.URL = sNewURL ' To avoid file update if not necessary
End Sub
JPL wrote:Bananiel-1944 wrote:
Oops, I realise I am using Libreoffice and not Openoffice. That may be the reason that the code above does not work for me.
I have to check on the difference in syntax (LibreOffice found a syntax error on each (!) line).
There is no difference in the syntax between LibreOffice and OpenOffice. The given code works in both suites.
Did you enclose the code in a Sub before running it ? Like in:
- Code: Select all Expand viewCollapse view
Sub Main
Dim oDatabase As Object, oDataSource As Object, sURL As String, sNewURL As String
Set oDatabase = ThisDatabaseDocument
sURL = Join(Split(oDatabase.URL, "%20"), " ")
Set oDataSource = oDatabase.Datasource
sNewURL = "jdbc:hsqldb:" & Left(sURL, Len(sURL) - 4) & ";default_schema=true;shutdown=true;hsqldb.default_table_type=cached;get_column_name=false"
If oDataSource.URL <> sNewURL Then oDataSource.URL = sNewURL ' To avoid file update if not necessary
End Sub
JPL
DACM wrote:Bananiel-1944 wrote:In the bottom line of the db window is the text:
JDBC hsqldb:file:/home/name/.../members;default_schema=true;shutdown=true;hsqldb.default_table_type=cached;get_column_name=false
NB: the new, empty database made according to the recipe in the internet link given above gave in the bottom line the new path name /media/.../mydb (on the USB-stick)
It seems that simply changing the path name as it appears in the bottom line would be the best, but I have no idea how to do that.
I hope someone has an easy solution!
A split database folder is fully portable when using the template with macros enabled. Or when converting an 'existing' database to a split database, you can add the provided macro to enable the same level of portability automation (while skipping the drag&drop steps and the need to transfer personal macros).
You can then move the entire folder to a USB stick, cloud folder, or between Linux, Windows and Macs. Upon opening the macro-enhanced .odb, the macro will instantly configure the necessary database connection path and save it to the .odb file. It's all seamless after initial setup, but each machine/installation must have macros enabled in *Office.
It's probably not an option in your case, but in a Windows environment, you don't even have to enable macros on the host machine (or have *Office installed) if you utilize LibreOffice Portable with jPortable (Java) to run your database entirely through a cloud folder (recommended) or from a USB device. In other words, LibreOffice Portable, jPortable, and your split-database folder can all reside in a cloud folder or entirely on a USB device for a completely portable database/office (Windows) environment.
It's also worth noting that the current macro is designed to support a single-user database environment, so concurrent multi-user (server mode) operation is beyond the scope of this discussion.
papijo wrote:...created using a split HSQLDB database.
How can I transform it [into] a single file ... to attach it to a post to this forum, or make it available to other AOO or LO users?
Portable 'split' HSQL database template wrote:
Instructions for use:
(1) Ensure global macro security in *Office is set to Medium (or Low):
(2) Remove any global Class Path to hsqldb.jar that you may have setup manually in *Office:Tools (*Office) > Options (Preferences) > *Office > Java/Advanced > Class Path > Remove
Users browsing this forum: No registered users and 7 guests