Skip to content

Running SQL at Connect and Disconnect

With connection hooks, you can run SQL statements automatically when DbVisualizer connects to a database and just before it disconnects. DbVisualizer can open several physical connections for one database connection, for example one for each SQL Commander tab, and the hooks run for each of them. They are typically used to initialize the session with custom settings, and to clean up at disconnect.

To set connection hooks for a connection:

  1. Open the Object View tab for the connection, and select its Properties tab.
  2. Select the Connection Hooks category.
  3. Enter the SQL in the fields under Run SQL at Connect and Run SQL at Disconnect. The SQL only runs while its checkbox is selected, which it is by default.

To set connection hooks for all connections of a database type, open Tools → Tool Properties, select the database type in the Database tab, and select the Connection Hooks category.

Errors from the connection hooks are shown in Tools → Debug Window.