When doing a database migration or other maintenance, you need to pause access on the application side, and we can view the IP connected to the data through the view. For ADO, we can also see the name of the app that's connected, but when it comes to Java programs using JDBC, it's hard to know exactly which application is going to access our database, especially when there are many applications running on the application server.
--=============================================
First, for the ADO access, use the following code
SELECT [net_ip]. session_id,[net_ip]. Connect_time,[net_ip]. Net_transport,[net_ip]. Client_net_address,[net_ip]. Client_tcp_port, se.host_process_id,[net_ip]. Local_net_address,[net_ip]. Local_tcp_port,[hostname]. Hostname,[hostname].[db_name] , [hostname]. Net_address,[hostname]. Loginame,[hostname]. Program_name,[net_ip]. Num_reads,[net_ip]. Num_writes,[hostname].text fromSys.dm_exec_connections as [net_ip] JOIN(SELECT DISTINCThostname, SPID,db_name(sp.dbid) as [db_name], Net_address, Loginame, Program_name, text fromMaster.. sysprocesses SP CrossAPPLY sys.dm_exec_sql_text (sp.sql_handle)WHEREHostname is not NULL andHostname<> "' ) asHostname on [net_ip]. session_id= [hostname]. SPID Left JOINsys.dm_exec_sessions SE on [net_ip]. session_id=se.session_id
We can locate the requested server IP according to local_net_address, through host_process_id to view the PID that sends the request, log on to the request server, use Task Manager to find the application of PID.
--=============================================
First of all, for JDBC access, the host_process_id is 0, it is not possible to provide us with valid information, we can use Client_tcp_port to locate the application.
First log on to the requested server, open the cmd window, run the Netstat-ano command to view the server's port usage
In the local address column, look for the value of Client_tcp_port, find the PID for the line, and then find the application based on the PID.
Wow haha, is not very powerful.
Little tricks:
Run netstat-ano>d:\net.txt in cmd, so that the result is saved to d:\net.txt, in the text editor to find the corresponding client_tcp_port, more convenient and quick.
--====================================================
Work overtime in the middle of the night to a hydrology, sister suppression under monsters