Access/MSSQL/Oracle/MySql获取当前用户连接数(downmoon收集)

201 篇文章 0 订阅
100 篇文章 0 订阅

一、MSSQL中可以用sp_who 获取连接的用户名信息,

二、Oracle也有类似的系统函数

  1. SQL> select count(*) from v $session    #连接数
  2. SQL> Select count(*) from v $session  where status= 'ACTIVE'   #并发连接数
  3. SQL> show parameter processes   #最大连接
  4. SQL> alter system set processes = value scope = spfile;重启数据库   #修改连接 

三、Access下有以下几种思路:

  第一:直接看ldb文件,有几行就有几个连接
格式基本上是

    hostname    workgroupUserId

  第二: 用vbscript

    有两段代码可以参考:

    Microsoft:

  1. Sub  ShowUserRosterMultipleUsers()
  2. Dim  cn  As   New  ADODB.Connection
  3. Dim  rs  As   New  ADODB.Recordset
  4. Dim  i, j  As   Long
  5. Set  cn = CurrentProject.Connection
  6. ' The user roster is exposed as a provider-specific schema rowset
  7. ' in the Jet 4.0 OLE DB provider.  You have to use a GUID to
  8. ' reference the schema, as provider-specific schemas are not
  9. ' listed in ADO's type library for schema rowsets
  10. Set  rs = cn.OpenSchema(adSchemaProviderSpecific, _
  11. "{947bb102-5d43-11d1-bdbf-00c04fb92675}" )
  12. 'Output the list of all users in the current database.
  13. Debug.Print rs.Fields(0).Name,  "" , rs.Fields(1).Name, _
  14. While   Not  rs.EOF
  15. Debug.Print rs.Fields(0), rs.Fields(1), _
  16. rs.Fields (2), rs.Fields(3)
  17. rs.MoveNext
  18. Wend
  19. End   Sub

   Access Web:

  1. ' This code was originally written by Dev Ashish.
  2. ' It is not to be altered or distributed,
  3. ' except as part of an application.
  4. ' You are free to use it in any application,
  5. ' provided the copyright notice is left unchanged.
  6. '
  7. ' Code Courtesy of
  8. ' Dev Ashish
  9. '
  10. Private   Declare   Function  apiGetUserName  Lib   "advapi32.dll"   Alias  _
  11. Function  fOSUserName()  As   String
  12. ' Returns the network login name
  13. Dim  lngLen  As   Long , lngX  As   Long
  14. Dim  strUserName  As   String
  15. strUserName =  String $(254, 0)
  16. lngLen = 255
  17. lngX = apiGetUserName(strUserName, lngLen)
  18. If  (lngX > 0)  Then
  19. fOSUserName = Left$(strUserName, lngLen - 1)
  20. Else
  21. fOSUserName = vbNullString
  22. End   If
  23. End   Function
  24. '******************** Code End **************************

四、MySql

  1. mysql>   show   processlist; 
  1. ./mysqladmin   processlist  

 

  例:

  C:/Documents   and   Settings/administrator>mysqladmin   processlist  

更详细的,查看当前所有连接的详细资料:

./mysqladmin -uadmin -p -h10.140.1.1 processlist


只查看当前连接数(Threads就是连接数.):

./mysqladmin  -uadmin -p -h10.140.1.1 status

 

 

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值