Share My Creation [Tool] Set Sqlite journal mode to DELETE

Version: 1.00
GitHub: https://github.com/pyhoon/closedb-b4j

Description​

When we initialized a sqlite database file with journal mode = WAL, it will create 3 files, a sample.db, sample.db-shm and sample.db-wal files.
We may want a single file downloaded from FTP client from our VPS.
This tool will set the journal mode to DELETE if it is not, e.g journal mode is WAL.

References:
https://www.b4x.com/android/forum/threads/b4x-sql-setting-the-journal-mode.136211/
https://www.b4x.com/android/forum/threads/webapp-concurrent-access-to-sqlite-databases.39904/

Installation

  1. Download the jar: https://github.com/pyhoon/closedb-b4j/releases/download/v1.00/closedb.jar (3.12MB)
  2. Put the jar file inside
    • B4J project or jar path (Objects folder in development)
    • B4J Additional Libraries folder (see the last section at bottom)

Usage

Option 1: Using Macro to call closedb.jar with argument (most straight forward)
  1. Add the following Macro
    B4X:
    #Macro: Title, CloseDB, ide://run?File=closedb.jar&Args=sample.db
  2. Activate the Macro from B4J IDE
Option 2: Using Macro to call closedb.jar without argument
  1. Download sample sqlite.ini file: https://github.com/pyhoon/closedb-b4j/releases/download/v1.00/sqlite.ini
  2. Note: You can also reuse the sqlite.ini in Pakai Server project
  3. Put sqlite.ini inside B4J server app or project Objects folder
  4. Edit sqlite.ini with your DbDir and DbFile
  5. Add the following Macro
    B4X:
    #Macro: Title, CloseDB, ide://run?File=closedb.jar
  6. Activate the Macro from B4J IDE
Option 3: Using Macro to call closedb.bat batch file
  1. Download sample batch file: https://github.com/pyhoon/closedb-b4j/releases/download/v1.00/closedb.bat
  2. Put closedb.bat inside B4J server app or project Objects folder
  3. Edit closedb.bat to include path of the sqlite db file e.g C:\Java\jdk-19.0.2\bin\java -jar closedb.jar sample.db
  4. Add the following Macro
    B4X:
    #Macro: Title, CloseDB, ide://run?File=%PROJECT%\Objects\closedb.bat
  5. Activate the Macro from B4J IDE
Option 4: Using Macro to call closedb.bat batch file and sqlite.ini
  1. Download sample batch file: https://github.com/pyhoon/closedb-b4j/releases/download/v1.00/closedb.bat
  2. Download sample sqlite.ini file: https://github.com/pyhoon/closedb-b4j/releases/download/v1.00/sqlite.ini
  3. Note: You can also reuse the sqlite.ini in Pakai Server project
  4. Put sqlite.ini inside B4J server app or project Objects folder
  5. Edit sqlite.ini with your DbDir and DbFile
  6. Add the following Macro
    B4X:
    #Macro: Title, CloseDB, ide://run?File=%PROJECT%\Objects\closedb.bat
  7. Activate the Macro from B4J IDE
Option 5: Execute closedb.bat batch file
  1. Download sample batch file: https://github.com/pyhoon/closedb-b4j/releases/download/v1.00/closedb.bat
  2. Put closedb.bat inside B4J server app or project Objects folder
  3. Edit closedb.bat to include path of the sqlite db file e.g C:\Java\jdk-19.0.2\bin\java -jar closedb.jar sample.db
  4. Execute the closedb.bat
Option 6: Execute closedb.bat batch file with path from sqlite.ini (useful for VPS)
  1. Download sample batch file: https://github.com/pyhoon/closedb-b4j/releases/download/v1.00/closedb.bat
  2. Download sample sqlite.ini file: https://github.com/pyhoon/closedb-b4j/releases/download/v1.00/sqlite.ini
  3. Note: You can reuse the sqlite.ini in Pakai Server project
  4. Put both files inside B4J server app or project Objects folder
  5. Edit sqlite.ini with your DbDir and DbFile
  6. Execute the closedb.bat

Call from B4J Additional Libraries folder​

If you put the closedb.jar inside B4J Additional Libraries folder, update the Macro from
B4X:
#Macro: Title, CloseDB, ide://run?File=closedb.jar&Args=sample.db
to
B4X:
#Macro: Title, CloseDB, ide://run?File=%ADDITIONAL%\closedb.jar&Args=sample.db
 
Last edited:

aeric

Expert
Licensed User
Longtime User
It can be use during maintenance or troubleshooting where the server has already stopped.
 
Top