On this page

CONNECT

Core command OPEN CONN CON

Opens a connection to a database, or sets the API session context with CONNECT API.

Syntax

CONNECT <connection>
CONNECT $CDF
CONNECT API <api>:<environment>

Quick start

SHOW ALL CONNECTIONS;
CONNECT WORLD;

Lists the connections, then opens WORLD.

Arguments

ArgumentRequiredValuesDefault
<connection>Yes, for a databaseThe ID of an active connection of the CDFNone
$CDFYes, for CDF maintenanceOpens CDF maintenance mode after asking for the master passwordNone
API <api>:<environment>Yes, for an APIAn active imported API and one of its active environmentsNone

Examples

CONNECT db01;
OPEN WORLD;
CONNECT API DESK_DEFINITION:PROD;

Example session

BroadSQL> SELECT * FROM COUNTRY;
ERROR: No active database connection.
Use CONNECT <connection> first.
BroadSQL> CONNECT WORLD;
WORLD>
SQL before and after CONNECT

Details

Connecting to a database

The connection ID must be an active connection of the Connections Definition File (CDF); an inactive one is refused with a message saying how to reactivate it. CONNECT works from the BroadSQL> prompt, when no database is connected, as from any connection.

  • The new connection is opened first. If that fails, the command reports it and the current connection stays open, with the same prompt.
  • On success, the current connection is closed and the prompt shows the new one. SHOW DBINFOS and SHOW AUTOCOMMIT summarize the new connection, then its login script runs.
  • When logging is on by default, the session is written to the query log file.
  • A connection whose URL opens BroadSQL's own configuration database (the CDF), under any name or path, or a copy of the CDF, is refused: the CDF is never an ordinary connection.

CDF maintenance: CONNECT $CDF

CONNECT $CDF asks for the master password, every time, then opens CDF maintenance mode: a direct SQL session on the configuration database, for diagnosis and repair, with the prompt $CDF [MAINTENANCE]>. It must be typed at the prompt (it is refused in a Script, a REPEAT and an Editor run) and takes no argument. A wrong or empty password changes nothing. DISCONNECT leaves maintenance mode. For normal configuration changes, use CONFIG and the connection commands instead. CONNECT <id> always means a connection, never an Environment: to switch by Environment within the current Database Group, use ENV <environment>, which opens the connection exactly the same way.

Missing JDBC driver

When no JDBC driver is available for the connection's database type, the test fails with an error naming the missing driver class. Copy the matching driver .jar file into the drivers/ or lib/ folder, restart BroadSQL and try again.

API session context

CONNECT API <api>:<environment> sets the API and environment that RUN and SHOW ENDPOINTS use when the command line does not repeat them. The API and its environment must exist and be active. The two contexts are independent: connecting to an API never closes the database connection, and connecting to a database never clears the API context. The prompt shows both when both are active, for example WORLD [API DESK:PROD]>. DISCONNECT API clears only the API context.

Used in these how-tos

Last modified in release development.

Found something wrong or unclear on this page? , with the page address.