Adsense

Friday, September 26, 2014

Db2 Terminate Vs Connect Reset , Disconnect

db2 Terminate and db2 connect Reset both break the connection to a database.

             Connect Reset breaks a connection to a database, but does not terminate the back-end process. The Terminate command does both ie. break the connection to a database and terminate the back-end process.

Suppose an application is connected to a database, or a process may be in the middle of a of work. We can use TERMINATE to make the database connection to be lost. When Terminate is issued, an internal commit is also performed.

When issue the command db2stop, it may not stop the database manager, if an application is connected to a database. In this situation, you have to issue db2 Terminate command or db2 connect reset, then issue the command db2stop.

Db2 Disconnect is used to clear the database connection of a particular database or all

Syntax : db2 disconnect dbname

eg. db2 disconnect sample

db2 disconnect all

db2 release all

Note : Even after disconnecting database, some times you may get the error message "Database already in use "  when you execute the commands like   "db2 Restore db databasename , etc ..". 

That means current data base is connected by some other applications. Applications connected to the database can be listed out by the following command

db2 list applications

Auth Id Application Name Appl. Handle Application Id DB Name # of Agents
------- -------------- ---------- ------------------------------ -------- -----

TEST javaw.exe 78 *LOCAL.DB2.110722172106 EMPLOYEE 1

TEST javaw.exe 77 *LOCAL.DB2.110722172103 EMPLOYEE 1


Now you can use db2 "force applications all" This command is used to kill  all the applications forcefully at instance level .

To force a particular application with application handle 78
db2  "force application(78)"

2 comments: