jaydebeapi可以连接_Python安装jpype调用java,安装jaydebeapi通过jdbc连接数据库
1 importjpype,os,time,timer2 from jpype importjava3 from jpype importjavax4
5 HOST=‘192.168.48.103‘
6 PORT=9999
7 USER=‘‘
8 PASS=‘‘
9
10 URL = "service:jmx:rmi:///jndi/rmi://%s:%d/jmxrmi" %(HOST, PORT)11 print(‘1‘,URL)12 jvmPath =jpype.getDefaultJVMPath()13 print(jvmPath)14 #this it the path of your libjvm /usr/lib/jvm/sun-jdk-1.6/jre/lib/amd64/server/libjvm.so on linux
15 #jpype.startJVM("C:\Program Files\Java\jre1.8.0_191\bin\server\jvm.dll")
16 if notjpype.isJVMStarted():17 jpype.startJVM(jvmPath)18 jpype.java.lang.System.out.println(‘Hello world!‘)19 #print(jpype.startJVM("C:\Program Files\Java\jre1.8.0_191\bin\server\jvm.dll"))
20 jhash =java.util.HashMap()21 jarray =jpype.JArray(java.lang.String)([USER,PASS])22 jhash.put(javax.management.remote.JMXConnector.CREDENTIALS, jarray);23 jmxurl =javax.management.remote.JMXServiceURL(URL)24 print(‘2‘,jmxurl)25 jmxsoc =javax.management.remote.JMXConnectorFactory.connect(jmxurl,jhash)26 try:27 connection =jmxsoc.getMBeanServerConnection();28 exceptException as e:29 print(e)30 print(‘3‘,connection)31 #32 #33 whileTrue:34 time.sleep(60)35 object="java.lang:type=Threading"
36 attribute="ThreadCount"
37 attr=connection.getAttribute(javax.management.ObjectName(object),attribute)38 print(‘4‘,attribute, attr)39 #40 #Memory is a special case the answer is a Treemap in a CompositeDataSupport
41 object="java.lang:type=Memory"
42 attribute="HeapMemoryUsage"
43 attr=connection.getAttribute(javax.management.ObjectName(object),attribute)44 print(‘5‘,attr.contents.get("used"))45 #ceshi
46 object="kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec"
47 attribute="Count"
48 attr=connection.getAttribute(javax.management.ObjectName(object),attribute)49 print(‘6‘,attribute,attr)50
51 object="java.lang:type=OperatingSystem"
52 attribute="Version"
53 attr=connection.getAttribute(javax.management.ObjectName(object),attribute)54 print(‘7‘,attribute,attr)55
56 object="kafka.server:type=ReplicaManager,name=PartitionCount"
57 attribute="Value"
58 attr=connection.getAttribute(javax.management.ObjectName(object),attribute)59 print(‘8‘,attribute,attr)
總結
以上是生活随笔為你收集整理的jaydebeapi可以连接_Python安装jpype调用java,安装jaydebeapi通过jdbc连接数据库的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: checking for mysql_c
- 下一篇: python安装第三方包总是超时_(py