(888) 685-3101 ext. 2

Error Message

SQL1024N  A database connection does not exist.  SQLSTATE=08003

or sometimes:

DB21034E  The command was processed as an SQL statement because it was not a 
valid Command Line Processor command.  During SQL processing it returned:
SQL1024N  A database connection does not exist.  SQLSTATE=08003

What is Really Happening?

This error message occurs when you are attempting to perform an action that requires a database connection, but a database connection has not been established. Actions that require database connections include issuing SQL statements – including those that access monitoring table functions, creating or altering objects (DDL), and querying or updating database configuration without specifying a database in the command, among others.

How to Resolve

To resolve this, simply establish a database connection using the CONNECT statement. For more information on how to connect to a DB2 LUW database, see How to Connect to a DB2 Database

Databases must be cataloged on the server you are on before you can connect to them. Creating a database automatically catalogs it, or you can explicitly catalog a remote database. For more information on cataloging a database, see How to Catalog A DB2 Database

If you have only one database on a DB2 instance and want DB2 to implicitly connect to it for any command requiring a connection, you can set the DB2 registry variable DB2DBDFT. This will cause DB2 to implicitly establish a connection to the database specified for most commands that require connections. If there is more than one database on an instance, you may want to avoid setting this, so people do not think they are working with one database and accidentally work with another database. I prefer not to set it in most situations.

Share This