Name

DISCONNECT — close a database connection

Function

Syntax

disconnect &key database pool => t

Arguments and Values

pool

A boolean flag indicating whether to put the database into a pool of opened databases. If T, rather than terminating the database connection, the connection is left open and the connection is placed into a pool of connections. Subsequent calls to connect can then reuse this connection. The default is NIL.

database

The database to disconnect, which defaults to the database indicated by *default-database*.

Description

This function takes a database object as returned by connect, and closes the connection. The class of the object passed is changed to closed-database after the disconnection succeeds, thereby preventing further use of the object as an argument to CLSQL functions, with the exception of database-name. If the user does pass a closed database object to any other CLSQL function, an error of type clsql-closed-error is signalled.

Examples

(disconnect :database (find-database "dent/newesim/dent"))
=> T
	

Side Effects

The database connection is closed, and the database object is removed from the list of connected databases as returned by connected-databases.

The class of the database object is changed to closed-database.

If the database object passed is the same under eq as the value of *default-database*, then *default-database* is set to the first remaining database from connected-databases or to nil if no further active database exists.

Affected by

*default-database*

Exceptional Situations

If during the disconnection attempt an error is detected (e.g. because of network trouble or any other cause), an error of type clsql-error might be signalled.

See Also

connect
closed-database

Notes

None.