Available with Standard or Advanced license.
As the geodatabase administrator, you occasionally need to identify who is connected to the geodatabase and which connections are locking resources. You also may need to remove certain connections if people are not present to disconnect themselves. For example, an editor may have left ArcGIS Pro open while editing, locking the data in the edit session and preventing other editors from accessing it and preventing the data owner from altering the schema of the tables. Or you may require everyone to disconnect so you can apply a patch to the database, restore the database, or compress the geodatabase.
You can connect to the geodatabase as the sde user from ArcGIS Pro to view and, if necessary, drop connections. Alternatively, you can use ArcPy functions to complete the same workflow.
To disconnect users from a geodatabase in IBM Db2 on Linux, UNIX, or Windows, the sde user must be granted either SYSCTRL or SYSADM authority and DBADM authority.
Caution:
Use caution when disconnecting users. Avoid disconnecting active sessions, especially if the connected user is in the process of editing. Only disconnect sessions that were left open but are not being used (for example, if someone left the session open over the weekend), orphaned sessions that are locking an object, or sessions involved in a deadlock situation.
First, determine who is connected to the geodatabase. If necessary, you can then remove connections.
Identify and remove connections in ArcGIS Pro
You can connect to the geodatabase as sde in ArcGIS Pro to view connections from within the Geodatabase Administration dialog box.
- Start ArcGIS Pro.
- Connect to the geodatabase as the sde user.
- Right-click the database connection and click Administration > Connections.
A list is displayed showing all sessions that are currently connected to the geodatabase. Your session is displayed in italic text.
- Contact individuals and ask them to close their sessions. If you are unable to contact them and still need to disconnect them from the geodatabase, proceed with the next step.
- Right-click the specific session you want to remove from the geodatabase and click Disconnect.
The session is immediately dropped from the geodatabase.
- Close the Geodatabase Administration dialog box.
Identify and remove connections using Python
You can run ArcPy functions to create a geodatabase connection file for the sde user, use that connection file to connect to the geodatabase and get a list of all current geodatabase connections, and remove a connection from the geodatabase if necessary.
- Create a database connection file by running the CreateDatabaseConnection_management function in a Python window. Save the username and password with the file.
In this example, a connection file (dgdb.sde) is created in the temp folder. It connects to the cataloged database spdb2, logging in as the sde user.
import arcpy arcpy.CreateDatabaseConnection_management ("c:\\temp", "dgdb.sde", "DB2", "spdb2", "DATABASE_AUTH", "sde", "mysdepwd", "SAVE_USERNAME")
- Run the ListUsers function to get a list of all current connections to the spdb2 geodatabase.
Specify the connection file you created in the previous step.
##No need to import arcpy if you are running functions in the same Python window. import arcpy arcpy.ListUsers("c:\\temp\dgdb.sde")
A list of user connections is returned.
[user(ClientName=u'PC4', ConnectionTime=datetime.datetime(2018, 2, 18, 8, 30, 19), ID=18, IsDirecConnection=True, Name=u'publisher1')] [user(ClientName=u'PC25', ConnectionTime=datetime.datetime(2018, 2, 21, 14, 10, 43), ID=33, IsDirecConnection=True, Name=u'editor2')] [user(ClientName=u'PC11', ConnectionTime=datetime.datetime(2018, 2, 22, 9, 18, 26), ID=39, IsDirecConnection=True, Name=u'reader5')] [user(ClientName=u'PCA2', ConnectionTime=datetime.datetime(2018, 2, 22, 11, 21, 2), ID=41, IsDirecConnection=True, Name=u'sde')]
- Contact individuals and ask them to close their sessions. If you are unable to contact them and still need to disconnect them from the geodatabase, proceed with the next step.
- Use the information obtained from the ListUsers function to identify which connection to remove using the DisconnectUser function.
Specify the ID of the connection to remove. Here, the connection with ID 33 is removed:
##No need to import arcpy if you are running functions in the same Python window. import arcpy arcpy.DisconnectUser("c:\\temp\dgdb.sde",33)
The session is immediately dropped from the geodatabase.