Many DB2 administrators encounter the frustrating SQL1035N error when attempting to drop a database, even after executing proper connection termination procedures. Here's a comprehensive approach to resolving this stubborn issue in DB2 9.5 environments.
When standard methods fail to release database connections, we need deeper investigation tools:
-- Check for all database connections (more thorough than list applications)
db2pd -db mydatabase -applications
db2pd -db mydatabase -agents
db2pd -db mydatabase -transactions
When conventional methods don't work, try this multi-step approach:
-- Step 1: Force all connections to terminate
db2 force applications all
-- Step 2: Quiesce with maximum force
db2 quiesce database immediate force connections with global reference
-- Step 3: Deactivate the database
db2 deactivate database mydatabase
-- Step 4: Final drop attempt
db2 drop database mydatabase
On Windows servers, additional steps may be necessary:
-- Check for zombie processes
tasklist /svc | findstr db2sys
-- Stop and restart the DB2 service
net stop "IBM DB2"
net start "IBM DB2"
For absolutely stubborn cases where the database metadata is corrupted:
-- First identify the database's physical location
db2 list database directory
-- Then use the DB2DART tool (run from DB2 instance owner)
db2dart MYDATABASE /DDEL
Many DB2 administrators encounter the frustrating SQL1035N error when trying to drop a database that appears to have no active connections. The standard approach of using quiesce database
followed by drop database
often fails unexpectedly.
First, let's verify there are truly no active connections. Run these commands in sequence:
db2 list applications for database mydatabase
db2 list active databases
db2pd -applications
db2pd -database
If these show no connections but you still can't drop the database, try this nuclear option:
This three-step process has worked for me in stubborn cases:
-- Step 1: Force all connections off
db2 force applications all
-- Step 2: Put database in quiesced mode
db2 quiesce database immediate force connections
-- Step 3: Terminate the instance to clear all handles
db2stop force
db2start
-- Now attempt the drop
db2 drop database mydatabase
On Windows systems, sometimes system processes maintain hidden handles. Try these additional steps:
-- Run as administrator
net stop DB2 - DB2COPY1
net start DB2 - DB2COPY1
-- Then connect and drop
db2 connect to mydatabase
db2 drop database mydatabase
If all else fails, you can manually uncatalog the database:
db2 uncatalog database mydatabase
db2 drop database mydatabase
Note this may leave residual files that need manual cleanup from the filesystem.
To avoid this situation in the future:
- Always use connection pooling with proper timeout settings
- Implement application connection cleanup routines
- Consider using DB2's AUTODELETE option when creating test databases