【问题标题】:Retrieving Datasource JDBC connection string via JMX from IBM Websphere通过 JMX 从 IBM Websphere 检索数据源 JDBC 连接字符串
【发布时间】:2015-10-02 09:49:08
【问题描述】:

我想知道是否可以从 IBM Websphere Application Server 检索数据源的 JDBC 连接字符串。我已经可以访问数据源的 JMX Bean,但似乎没有属性或操作(见下文)公开 JDBC 连接 URL 字符串。有人知道如何检索这些信息吗?

属性:

dbcDriver: WebSphere:name=...
connectionFactoryType: interface javax.sql.DataSource
dataSourceName: 
dataStoreHelperClass: description: New JDBC Datasource
loginTimeout: statementCacheSize: 10
jtaEnabled: true
testConnection: true
testConnectionInterval: 180
objectName: WebSphere:name=...
stateManageable: false
statisticsProvider: false
eventProvider: false
authMechanismPreference: 0
stuckTimerTime: 0
stuckTime: 0
stuckThreshold: 0
surgeThreshhold: -1
surgeCreationInterval: 0
connectionTimeout: 180
maxConnections: 10
minConnections: 1
purgePolicy: FailingConnectionOnly
reapTime: 180
unusedTimeout: 1800
agedTimeout: 0
freePoolDistributionTableSize: 5
freePoolPartitions: 1
sharedPoolPartitions: 200
holdTimeLimit: 10
diagnosticProviderName: ...
name: TaggingDatenquelle
Description: New JDBC Datasource
jndiName: jdbc/name
category: 

操作:

getJdbcDriver: 
getConnectionFactoryClass: 
getDataSourceName: 
getDataStoreHelperClass: 
getDescription: 
getLoginTimeout: 
getStatementCacheSize: 
isJTAEnabled: 
getProperty: 
getTestConnection: 
setTestConnection: 
getTestConnectionInterval: 
setTestConnectionInterval: 
getObjectNameStr: 
isStateManageable: 
isStatisticsProvider: 
isEventProvider: 
getAuthMechanismPreference: 
getStuckTimerTime: 
setStuckTimerTime: 
getStuckTime: 
setStuckTime: 
getStuckThreshold: 
setStuckThreshold: 
getSurgeThreshhold: 
setSurgeThreshhold: 
getSurgeCreationInterval: 
setSurgeCreationInterval: 
getConnectionTimeout: 
setConnectionTimeout: 
getMaxConnections: 
setMaxConnections: 
getMinConnections: 
setMinConnections: 
getPurgePolicy: 
setPurgePolicy: 
getReapTime: 
setReapTime: 
getUnusedTimeout: 
setUnusedTimeout: 
getAgedTimeout: 
setAgedTimeout: 
getFreePoolDistributionTableSize: 
getFreePoolPartitions: 
getSharedPoolPartitions: 
getHoldTimeLimit: 
setHoldTimeLimit: 
showPoolContents: 
showAllPoolContents: 
purgePoolContents: 
purgePoolContents: 
purgePoolContents: 
getPoolContents: 
getAllPoolContents: 
showAllocationHandleList: 
pause: 
resume: 
getStatus: 
getDiagnosticProviderName: 
getDiagnosticProviderId: 
getRegisteredDiagnostics: 
configDump: 
stateDump: 
selfDiagnostic: 
localize: 
getName: 
getDescription: 
getJndiName: 
getCategory: 

=====================================

【问题讨论】:

    标签: jdbc websphere jmx


    【解决方案1】:

    简而言之,不,您无法从任何当前提供的 JMX bean 中获取连接 URL。

    WebSphere Liberty 公开 JDBC 连接 URL 的唯一方式是通过 java.sql.DatabaseMetaData.getURL() API。如果您可以获得对DataSource 对象的引用(通过JNDI 查找或@Resource 注入),您可以从中获取连接,获取DatabaseMetaData,然后调用getURL()

    DataSource ds = (DataSource) new InitialContext().lookup("jdbc/name");
    String url = ds.getConnection().getMetaData().getURL();
    

    【讨论】:

    • 注意ds.getConnection()打开一个连接。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-08
    • 2019-12-16
    • 1970-01-01
    • 2011-12-14
    • 1970-01-01
    相关资源
    最近更新 更多