Introduction

The PostgreSQL NetBeans plugin supports the execution of PostgeSQL files using PSQL. It supports PgSQL and PLpgSQL scripts, providing an execution action for any .pgsql or .plpgsql file.

These actions are in the file node’s popup actions, and also in the editor window’s popup actions.

A PostgreSQL Project is recognised by the presence of an postgresql.properties file at the root level of the project. The project will execute the scripts with a specific database, which is defined in this file.

Automatically saving modified documents before executing scripts is available. It is optional and is enabled/disabled by a property in the postgresql.properties file. By default it is enabled.

Caution
The predefined .pgsql and .plpgsql file actions are limited to Unix family systems (i.e. Linix and MacOS). No Windows implementation have yet been completed.

PostgreSQL NB-Plugin by Example

PostgreSQL file recognition

Any PostgreSQL file (.pgsql or .plpgsql) will be recognised by NetBeans and will have an Execute action included in it’s popup menu.

basic execution action

However if the files do not exist within a PostgreSQL project they will not be actioned. A database context is needed to execute a command, which is defined in the postgresql.properties file.

postgresql.properties

The output and error streams from the execution of the PSQL program, are routed to the NetBeans Output Window.

basic execution output

Save Before Executing Scripts

Save Before Executing, if enabled, saves any PostgreSQL files which have been modified but not saved, prior to executing the Execute action.

The feature is controlled by a property in the postgresql.properties file.

    save_before_execution: XXX (1)
  1. where XXX is one of NO, YES or ALL. This property is optional and its default value is YES.

This property controls how any modified files may be saved prior to running the execute action. Only files modified by NetBeans will be considered as a Save candidates.

The possible values for the property are:

  • NO - No modified file(s) are saved prior to script execution, so the execute action will use the version of files as last saved (ignoring the modifications).

  • YES - Only the file selected by the execute action (either via the file node or the editor action), will be saved, if modified, prior to running the execute action.

  • ALL - All modified files that are within the project folder will be saved prior to running the execute action.

Using the PostgreSQL NBM

Adding the NBM to NetBeans

To be able to use the Plugin it must be downloaded and then installed in NetBeans.

Releases of this product are stored in a Maven repository on GitHub. It is possible to download an NBM from Packages.

Once you have a downloaded copy on your machine, you follow the standard NetBeans process to install the downloaded file (Tools>Plugins).

The ActionsSupport NBM must be installed with or prior to installing this NBM.

  • Releases are stored in a Packages Maven repository on GitHub

  • Source Code is stored in a Git repository on GitHub as part of a monorepro containing NBMs.

  • Documentation can be found on the TRP website.

  • Documentation source is stored in a Git repository on GitHub as part of a monorepro containing documentation.

  • Development Process Guide for The-Retired-Programmer products can be found on the TRP website.