(888) 685-3101 ext. 2

SQL1035N  The database is currently in use.  SQLSTATE=57019

IBM UDB DB2 V9.7/10.1/10.5 on Windows/UNIX/Linux

I have been trying to create a script that will refresh the test database using QA data on a regular schedule. As part of the script I force all the connections and then deactivate the database. After this step when I attempt to restore the database, sometimes, I get the above mentioned error. Obviously the problem is that there are still some connections to the database. But unfortunately we can not stop all the connections when we restore the DB. To prevent this error in the future I came up with a different method.

All you need to do is reset the DB2 environment variable DB2COMM and when this is not set to TCPIP no remote applications can connect to the database. So after the restore you have to make sure that you enable remote connections by setting the DB2COMM variable to TCPIP, otherwise no one can connect to the database.

Following is the sample code that I use to achive this.

db2 force applications all;
db2 deactivate db SAMPLE;
db2set DB2COMM=
db2stop force
db2start
db2 restore db sample taken at 201405201234.............
db2set DB2COMM=TCPIP
db2stop force
db2start
db2 rollforward...........

At this point you should be able to connect to the database. Make sure you get all the permissions/change tickets approved before using this code. You might want to test thoroughly before configuring any DB2 environment variable.

Share This