通过JMX从IBM Websphere检索数据源JDBC连接字符串

通过JMX从IBM Websphere检索数据源JDBC连接字符串,jdbc,websphere,jmx,Jdbc,Websphere,Jmx,我想知道是否可以从IBMWebSphereApplicationServer检索数据源的JDBC连接字符串。我已经有权访问数据源的JMXbean,但似乎没有任何属性或操作(见下文)公开JDBC连接URL字符串。有人知道如何检索这些信息吗 属性: 操作: 简而言之,不,您无法从当前提供的任何JMX bean获取连接URL。 WebSphereLiberty公开JDBC连接URL的唯一方法是通过java.sql.DatabaseMetaData.getURL()API。如果您可以获取对数据源对象的引

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

属性: 操作:
简而言之,不,您无法从当前提供的任何JMX bean获取连接URL。 WebSphereLiberty公开JDBC连接URL的唯一方法是通过
java.sql.DatabaseMetaData.getURL()
API。如果您可以获取对
数据源
对象的引用(通过JNDI查找或@Resource injection),您可以从该对象获取连接,获取
数据库元数据
,然后调用
getURL()

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: 

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