//来源: http://middlewaremagic.com/weblogic/?p=606 import java.io.IOException; import java.util.Hashtable; import java.util.Iterator; import java.util.Set; import javax.management.AttributeNotFoundException; import javax.management.InstanceNotFoundException; import javax.management.IntrospectionException; import javax.management.MBeanException; import javax.management.MBeanServerConnection; import javax.management.ObjectName; import javax.management.ReflectionException; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; import javax.naming.Context; import weblogic.jndi.Environment; import weblogic.management.MBeanHome; import weblogic.management.WebLogicMBean; import weblogic.management.configuration.ComponentMBean; import weblogic.management.configuration.JDBCConnectionPoolMBean; import weblogic.management.configuration.JDBCTxDataSourceMBean; public class ConnectionPoolParamsChecker { static MBeanServerConnection connection; static JMXConnector connector; static ObjectName service; public static void main(String [] args){ try { //////////////// Enter the Admin Server Details here///////////////////// String protocol = "t3"; int port = 7001; String hostname = "localhost"; String jndiroot = "/jndi/"; String mserver = "weblogic.management.mbeanservers.domainruntime"; JMXServiceURL serviceURL = new JMXServiceURL(protocol, hostname, port, jndiroot + mserver); service = new ObjectName("com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean"); Hashtable h = new Hashtable(); h.put(Context.SECURITY_PRINCIPAL, "weblogic"); h.put(Context.SECURITY_CREDENTIALS, "weblogic"); h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,"weblogic.management.remote"); connector = JMXConnectorFactory.connect(serviceURL, h); connection = connector.getMBeanServerConnection(); new ConnectionPoolParamsChecker().getJdbcRuntime(); } catch(Exception e) { e.printStackTrace(); } } private ObjectName getJDBCDriverParamsBean(ObjectName jdbcSystemResourceMBean) throws AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException, IOException, IntrospectionException { ObjectName jdbcDataSourceBean = (ObjectName) getObjectName(jdbcSystemResourceMBean, "JDBCResource"); return (ObjectName) getObjectName(jdbcDataSourceBean, "JDBCDriverParams"); } private Object getObjectName(ObjectName objectName, String attributeName) throws AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException, IOException { return connection.getAttribute(objectName, attributeName); } public void getJdbcRuntime() throws Exception { ObjectName[] serverRT = (ObjectName[])connection.getAttribute(service, "ServerRuntimes"); int length = (int) serverRT.length; for (int i = 0; i < length; i++) { String name = (String) connection.getAttribute(serverRT[i],"Name"); ObjectName[] appRT = (ObjectName[]) connection.getAttribute(new ObjectName("com.bea:Name="+name+",ServerRuntime="+name+",Location="+name+",Type=JDBCServiceRuntime"),"JDBCDataSourceRuntimeMBeans"); int appLength = (int) appRT.length; for (int x = 0; x < appLength; x++) { System.out.println("\n\t******SERVER NAME: <<"+name+">> \tDataSource Name: " + (String)connection.getAttribute(appRT[x], "Name")+"..........\n"); System.out.println("ActiveConnectionsCurrentCount : " + connection.getAttribute(appRT[x], "ActiveConnectionsCurrentCount")); System.out.println("ActiveConnectionsAverageCount : " + connection.getAttribute(appRT[x], "ActiveConnectionsAverageCount")); System.out.println("ActiveConnectionsAverageCount : " + connection.getAttribute(appRT[x], "ActiveConnectionsAverageCount")); System.out.println("ConnectionsTotalCount : " + connection.getAttribute(appRT[x], "ConnectionsTotalCount")); System.out.println("CurrCapacity : " + connection.getAttribute(appRT[x], "CurrCapacity")); System.out.println("CurrCapacityHighCount : " + connection.getAttribute(appRT[x], "CurrCapacityHighCount")); System.out.println("HighestNumAvailable : " + connection.getAttribute(appRT[x], "HighestNumAvailable")); System.out.println("HighestNumAvailable : " + connection.getAttribute(appRT[x], "HighestNumAvailable")); System.out.println("LeakedConnectionCount : " + connection.getAttribute(appRT[x], "LeakedConnectionCount")); System.out.println("WaitSecondsHighCount : " + connection.getAttribute(appRT[x], "WaitSecondsHighCount")); System.out.println("WaitingForConnectionCurrentCount: " + connection.getAttribute(appRT[x], "WaitingForConnectionCurrentCount")); System.out.println("WaitingForConnectionFailureTotal: " + connection.getAttribute(appRT[x], "WaitingForConnectionFailureTotal")); System.out.println("WaitingForConnectionTotal : " + connection.getAttribute(appRT[x], "WaitingForConnectionTotal")); System.out.println("WaitingForConnectionHighCount : " + connection.getAttribute(appRT[x], "WaitingForConnectionHighCount")); String poolName = (String)connection.getAttribute(appRT[x], "Name"); ObjectName jdbcSystemResource = new ObjectName("com.bea:Name=" + poolName+ ",Type=JDBCSystemResource"); ObjectName jdbcDataSourceBean = (ObjectName) getObjectName(jdbcSystemResource, "JDBCResource"); //////////////////// System.out.println("\n\t Connection Pool Parameters: \n"); ObjectName jdbcConnectionPoolParams = (ObjectName) getObjectName(jdbcDataSourceBean, "JDBCConnectionPoolParams"); Integer CapacityIncrement = (Integer) getObjectName(jdbcConnectionPoolParams, "CapacityIncrement"); System.out.println("\t CapacityIncrement :"+CapacityIncrement); Integer ConnectionCreationRetryFrequencySeconds = (Integer) getObjectName(jdbcConnectionPoolParams, "ConnectionCreationRetryFrequencySeconds"); System.out.println("\t ConnectionCreationRetryFrequencySeconds:"+ConnectionCreationRetryFrequencySeconds); Integer ConnectionReserveTimeoutSeconds = (Integer) getObjectName(jdbcConnectionPoolParams, "ConnectionReserveTimeoutSeconds"); System.out.println("\t ConnectionReserveTimeoutSeconds :"+ConnectionReserveTimeoutSeconds); Integer HighestNumWaiters = (Integer) getObjectName(jdbcConnectionPoolParams, "HighestNumWaiters"); System.out.println("\t HighestNumWaiters :"+HighestNumWaiters); Integer InactiveConnectionTimeoutSeconds = (Integer) getObjectName(jdbcConnectionPoolParams, "InactiveConnectionTimeoutSeconds"); System.out.println("\t InactiveConnectionTimeoutSeconds :"+CapacityIncrement); Integer InitialCapacity = (Integer) getObjectName(jdbcConnectionPoolParams, "InitialCapacity"); System.out.println("\t InitialCapacity :"+InitialCapacity); Integer JDBCXADebugLevel = (Integer) getObjectName(jdbcConnectionPoolParams, "JDBCXADebugLevel"); System.out.println("\t JDBCXADebugLevel :"+JDBCXADebugLevel); Integer LoginDelaySeconds = (Integer) getObjectName(jdbcConnectionPoolParams, "LoginDelaySeconds"); System.out.println("\t LoginDelaySeconds :"+LoginDelaySeconds); Integer MaxCapacity = (Integer) getObjectName(jdbcConnectionPoolParams, "MaxCapacity"); System.out.println("\t MaxCapacity :"+MaxCapacity); Integer ProfileHarvestFrequencySeconds = (Integer) getObjectName(jdbcConnectionPoolParams, "ProfileHarvestFrequencySeconds"); System.out.println("\t ProfileHarvestFrequencySeconds :"+ProfileHarvestFrequencySeconds); Integer ProfileType = (Integer) getObjectName(jdbcConnectionPoolParams, "ProfileType"); System.out.println("\t ProfileType :"+ProfileType); Integer SecondsToTrustAnIdlePoolConnection = (Integer) getObjectName(jdbcConnectionPoolParams, "SecondsToTrustAnIdlePoolConnection"); System.out.println("\t SecondsToTrustAnIdlePoolConnection :"+SecondsToTrustAnIdlePoolConnection); Integer ShrinkFrequencySeconds = (Integer) getObjectName(jdbcConnectionPoolParams, "ShrinkFrequencySeconds"); System.out.println("\t ShrinkFrequencySeconds :"+ShrinkFrequencySeconds); Integer StatementTimeout = (Integer) getObjectName(jdbcConnectionPoolParams, "StatementTimeout"); System.out.println("\t StatementTimeout :"+StatementTimeout); Integer TestFrequencySeconds = (Integer) getObjectName(jdbcConnectionPoolParams, "TestFrequencySeconds"); System.out.println("\t TestFrequencySeconds :"+TestFrequencySeconds); String TestTableName = (String) getObjectName(jdbcConnectionPoolParams, "TestTableName"); System.out.println("\t TestTableName :"+TestTableName); String StatementCacheType = (String) getObjectName(jdbcConnectionPoolParams, "StatementCacheType"); System.out.println("\t StatementCacheType :"+StatementCacheType); String InitSql = (String) getObjectName(jdbcConnectionPoolParams, "InitSql"); System.out.println("\t InitSql :"+InitSql); Boolean CredentialMappingEnabled = (Boolean) getObjectName(jdbcConnectionPoolParams, "CredentialMappingEnabled"); System.out.println("\t CredentialMappingEnabled :"+CredentialMappingEnabled); Boolean IdentityBasedConnectionPoolingEnabled = (Boolean) getObjectName(jdbcConnectionPoolParams, "IdentityBasedConnectionPoolingEnabled"); System.out.println("\t IdentityBasedConnectionPoolingEnabled :"+IdentityBasedConnectionPoolingEnabled); Boolean IgnoreInUseConnectionsEnabled = (Boolean) getObjectName(jdbcConnectionPoolParams, "IgnoreInUseConnectionsEnabled"); System.out.println("\t IgnoreInUseConnectionsEnabled :"+IgnoreInUseConnectionsEnabled); Boolean PinnedToThread = (Boolean) getObjectName(jdbcConnectionPoolParams, "PinnedToThread"); System.out.println("\t PinnedToThread :"+PinnedToThread); Boolean RemoveInfectedConnections = (Boolean) getObjectName(jdbcConnectionPoolParams, "RemoveInfectedConnections"); System.out.println("\t RemoveInfectedConnections :"+RemoveInfectedConnections); ///////////////////// ObjectName jdbcDriverParams=(ObjectName) getObjectName(jdbcDataSourceBean, "JDBCDriverParams"); ObjectName jdbcProperties=(ObjectName) getObjectName(jdbcDriverParams, "Properties"); ObjectName[] jdbcPropertyBeans = (ObjectName[]) getObjectName(jdbcProperties, "Properties"); for (int j = 0; j < jdbcPropertyBeans.length; j++) { ObjectName jdbcPropertyBean = null; jdbcPropertyBean = jdbcPropertyBeans[j]; String jdbcPropertyName = (String) getObjectName(jdbcPropertyBean, "Name"); String jdbcPropertyValue = (String) getObjectName(jdbcPropertyBean, "Value"); System.out.println("\n\tDataSource URL And "+jdbcPropertyName+"\t"+jdbcPropertyValue); } System.out.println(".............................................................................\n"); } } } }
相关推荐
通过预建的连接池,应用程序可以快速获取到已经存在的数据库连接,使用完毕后归还而不是关闭,提高了系统的响应速度和并发处理能力。 二、配置步骤 1. 登录WebLogic管理控制台:首先打开浏览器,输入WebLogic ...
6. **性能优化**:WebLogic提供了缓存机制、连接池、线程池等性能优化策略,以提高应用响应速度和资源利用效率。 7. **集成与互操作性**:WebLogic能够与Oracle数据库、其他中间件产品(如Oracle Coherence)以及...
数据源的连接池配置也是关键,如最大连接数、最小连接数、超时时间等。 三、WebLogic版本区别 WebLogic的不同版本主要体现在功能增强、性能提升、兼容性改进等方面。例如,从WebLogic 9到WebLogic 12c,Oracle引入...
这可能包括调整内存设置、JVM参数、线程池大小、数据库连接池配置等。 七、WebLogic监控与诊断 通过JMX(Java Management Extensions)和WLST(WebLogic Scripting Tool),可以对WebLogic进行监控和诊断。学习资料...
6. **数据源和连接池**:WebLogic 8.1支持多种数据库连接,包括Oracle、MySQL、SQL Server等,通过数据源和连接池优化数据库访问性能。 7. **事务处理**:支持JTA(Java Transaction API),提供了分布式事务处理...
- 调整线程池大小、连接池设置和JVM参数以优化性能。 - 使用WebLogic Server的性能监控工具进行性能测试和分析。 7. **安全管理** - 了解WebLogic Server的安全特性,如SSL/TLS配置、认证机制和角色权限分配。 ...
- **查看连接池运行状态**:使用JMX(Java Management Extensions)或WebLogic提供的监控工具,可以实时查看连接池的状态,包括当前连接数、等待队列长度等。 2. **常见配置问题** - **连接有效性测试选项**:这...
WebLogic的性能调优主要包括内存配置、线程池设置、JVM参数调整、连接池优化等。内存调优要考虑堆大小、新生代与老年代的比例、垃圾回收策略等;线程池调优则需要根据应用负载来设定最大线程数、最小线程数以及空闲...
【WebLogic服务器管理概述】 WebLogic服务器管理是BEA Systems提供的一个强大工具,...Web服务器插件的参数配置影响其与WebLogic Server的交互,包括连接池设置、重定向策略等,优化这些参数有助于提升性能和稳定性。
调优包括JVM内存设置、线程池调整、数据库连接池优化等。此外,WebLogic还支持Coherence,一个分布式缓存解决方案,用于提升数据访问速度。 WebLogic作为企业级应用服务器,其深入理解和熟练操作对于IT专业人员至关...
2. 数据源和连接池配置:调整连接池大小,避免过多的数据库连接开销。 3. 线程池设置:根据应用特性调整线程池大小,以平衡响应速度和资源消耗。 4. JVM内存设置:根据应用规模和性能监控结果,动态调整JVM内存参数...
9. **WebLogic与数据库集成**:WebLogic与Oracle数据库及其他主流数据库有紧密集成,支持JDBC连接池管理,事务处理,以及数据库驱动的自动加载。 10. **WebLogic与SOA集成**:作为Oracle SOA Suite的一部分,...
数据源的配置可以实现连接池管理,提高性能和资源利用率。 三、JNDI(Java Naming and Directory Interface) JNDI是Java应用程序查找和绑定对象的接口。在WebLogic中,JNDI用于查找和管理服务器资源,如数据源、...
同时,调优涉及JVM参数调整、连接池配置、缓存设置等,手册也会提供相关建议和最佳实践。 六、安全管理 WebLogic Server 9支持多种安全特性,如角色、权限、SSL加密、身份验证和授权等。手册会解释如何配置安全性,...
5. **WebLogic调优**:这部分内容可能涉及到服务器配置优化,如JVM内存设置、线程池调整、数据库连接池优化等,以及性能监控工具的使用,如JMX(Java Management Extensions)和WebLogic的管理控制台。 6. **安全性...
域的配置信息通过XML格式的`config.xml`文件定义,该文件位于安装目录`install_dir/config/domain_name`中。 - **管理服务器**:运行管理服务的WebLogic服务器。管理服务负责集中管理和监控域内所有资源。一个域...
3. **连接池调优**:设置合适的数据库连接池大小,避免过多连接占用资源或连接不足导致应用等待。 4. **缓存和预热**:启用缓存机制可以提高响应速度,而预热操作则可以帮助应用更快地达到稳定状态。 5. **日志和...
- 在配置完数据库连接池后,可以点击"测试Connection"来验证配置的正确性,如果显示成功,表明WebLogic能成功连接到数据库。 6. **设置JMS**: - JMS(Java Message Service)用于实现应用程序间的异步通信。 - ...
- **资源池**:集群内的资源(如线程池、数据库连接池)被集中管理,可根据需要动态调整。 6. **安全性**: - **SSL配置**:为了保护集群间的通信,可以启用SSL加密。 - **访问控制**:通过WebLogic的安全特性,...
1. 资源池:线程池、连接池等,用于优化性能和提高响应速度。 2. 监控和诊断:通过日志、JMX(Java Management Extensions)、性能仪表板等工具进行性能分析。 3. 批量更新:优化大批次数据操作,减少数据库压力。 ...