Connect command

Syntax

CONNECT ConnectionURLString [ PROTOCOL Identifier ]
    [ AS Identifier ] [ USER String 
     PASSWORD String ]

Description

Connects to the database indicated by the ConnectionURLString. Specifically, takes the value of the string database connection URL and issues a java.sql.DriverManager.getConnection request to set the current connection to that database connection URL.

You have the option of specifying a name for your connection. Use the Set Connection command to switch between connections. If you do not name a connection, the system generates a name automatically.

You also have the option of specifying a named protocol previously created with the Protocol command or the ij.protocol.protocolName property.

If the connection requires a user name and password, supply those with the optional user and password parameters.

If the connect succeeds, the connection becomes the current one and ij displays a new prompt for the next command to be entered. If you have more than one open connection, the name of the connection appears in the prompt.

All further commands are processed against the new, current connection.

Example

ij> connect 'jdbc:derby:menuDB;create=true';
ij> -- we create a new table in menuDB:
CREATE TABLE menu(course CHAR(10), item CHAR(20), price INTEGER);
ij> protocol 'jdbc:derby:';
ij> connect 'sample' as sample1;
ij(SAMPLE1)> connect 'newDB;create=true' as newDB;
ij(NEWDB)> show connections;
CONNECTION0 - jdbc:derby:menuDB
NEWDB* - jdbc:derby:anotherDB
SAMPLE1 - jdbc:derby:newDB
ij>
ij> connect 'jdbc:derby:sample' user 'sa' password 'cloud3x9';
ij>
Related concepts
ij commands
ij errors
Related reference
Absolute command
After Last command
Async command
Autocommit command
Before First command
Close command
Commit command
Describe command
Disconnect command
Driver command
Elapsedtime command
Execute command
Exit command
First command
Get Cursor command
Get Scroll Insensitive Cursor command
Help command
Last command
LocalizedDisplay command
MaximumDisplayWidth command
Next command
Prepare command
Previous command
Protocol command
Readonly command
Relative command
Remove command
Rollback command
Run command
Set Connection command
Show command
Wait For command
Syntax for comments in ij commands
Syntax for identifiers in ij commands
Syntax for strings in ij commands