Name

RECONNECT — Re-establishes the connection between a database object and its RDBMS.Function

Syntax

      reconnect &key database error force => result

Arguments and Values

database

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

error

A boolean flag indicating whether to signal an error if database is non-nil but cannot be found. The default value is NIL.

force

A Boolean indicating whether to signal an error if the database connection has been lost. The default value is T.

result

A Boolean indicating whether the database was successfully reconnected.

Description

Reconnects database which defaults to *default-database* to the underlying database management system. On success, T is returned and the variable *default-database* is set to the newly reconnected database. If database is a database instance, this object is closed. If database is a string, then a connected database whose name matches database is sought in the list of connected databases. If no matching database is found and error and database are both non-NIL an error is signaled, otherwise NIL is returned.

When the current database connection has been lost, if force is non-NIL as it is by default, the connection is closed and errors are suppressed. If force is NIL and the database connection cannot be closed, an error is signalled.

Examples

*default-database*
=> #<CLSQL-SQLITE:SQLITE-DATABASE :memory: OPEN {48CFBEA5}>
(reconnect)
=> #<CLSQL-SQLITE:SQLITE-DATABASE :memory: OPEN {48D64105}>
      

Side Effects

A database connection is re-established and *default-database* may be rebound to the supplied database object.

Affected by

*default-database*

Exceptional Situations

An error may be signalled if the specified database cannot be located or if the database cannot be closed.

See Also

connect
disconnect
disconnect-pooled

Notes

None.