通过 JMX 从 IBM Websphere 检索数据源 JDBC 连接字符串
Retrieving Datasource JDBC connection string via JMX from IBM Websphere
我想知道是否可以从 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:
=====================================
简而言之,不,您无法从任何当前提供的 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();
我想知道是否可以从 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:
=====================================
简而言之,不,您无法从任何当前提供的 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();