Changing connection pool settings with the wsadmin tool
You can use the wsadmin scripting tool to change connection pool settings.
About this task
The wsadmin tool runs scripts. You can use the wsadmin tool to manage a WebSphere® Application Server installation and configuration, application deployment, and server runtime operations. The product supports the Jacl and Jython scripting languages. To learn more about the wsadmin tool see the topic Starting the wsadmin scripting client.
To use the wsadmin tool to change connection pool settings:
Procedure
Example: Changing connection pool settings with the wsadmin tool
Using the wsadmin AdminControl object, you can script changes to connection pool settings.
The wsadmin tool runs scripts in the Jacl and Jython languages only. You must start the wsadmin scripting client to perform any scripting task. For more information, see the topic Starting the wsadmin scripting client.
Example: Accessing MBean connection factory and data sources using wsadmin
Wsadmin commands are used to access connection factory and data source MBeans. MBeans can retrieve or update properties for a connection factory or data source.
To get a list of J2C connection factory or data source Mbean object names, from the wsadmin command-line use one of the following administrative control commands:
$AdminControl queryNames *:type=J2CConnectionFactory,*
$AdminControl queryNames *:type=DataSource,*
Example output from DataSource query:
wsadmin>$AdminControl queryNames *:type=DataSource,*
"WebSphere:name=Default Datasource,process=server1,platform=dynamicproxy,node=
system1Node01,JDBCProvider=Derby JDBC Provider,j2eeType=JDBCDataSource,J2EESe
rver=server1,Server=server1,version=6.0.0.0,type=DataSource,mbeanIdentifier=cell
s/system1Node01Cell/nodes/system1Node01/servers/server1/resources.xml#DataSource
_1094760149902,JDBCResource=Derby JDBC Provider,cell=system1Node01Cell"
By using the J2C connection factory or data source MBean object name, you can access the MBean.
The name follows the webSphere:name=
expression. In the following example, for the
first set, the default data source name is set on variable name. For the second set, the object name
is set on variable objectName
.
Example using the Default DataSource:
wsadmin>set name [list Default Datasource]
Default Datasource
wsadmin>set objectName [$AdminControl queryNames *:name=$name,*]
"WebSphere:name=Default Datasource,process=server1,platform=dynamicproxy,node=
system1Node01,JDBCProvider=Derby JDBC Provider,j2eeType=JDBCDataSource,J2EESe
rver=server1,Server=server1,version=6.0.0.0,type=DataSource,mbeanIdentifier=cell
s/system1Node01Cell/nodes/system1Node01/servers/server1/resources.xml#DataSource
_1094760149902,JDBCResource=Derby JDBC Provider,cell=system1Node01Cell"
Now you can use the objectName for getting help on attributes and operations available for this Mbean.
$Help attributes $objectName
$Help operations $objectName
To get or set an attribute or to use an operation, use one of the following commands:
$AdminControl getAttribute $objectName "attribute name"
$AdminControl setAttribute $objectName "attribute name" value
$AdminControl invoke $objectName "operation"
Attribute, operation examples:
Get and set an attribute maxConnections. If you get no value, a null value, or
a java.lang.IllegalStateException, the connection factory or data source for this
MBean has not been created. The connection factory or data source is created at first
JNDI lookup. For this example, the Default DataSource must be used before get,
set and invoke will work.
wsadmin>$AdminControl getAttribute $objectName maxConnections
10
wsadmin>$AdminControl setAttribute $objectName maxConnections 20
wsadmin>$AdminControl getAttribute $objectName maxConnections
20
Using invoke
wsadmin>$AdminControl invoke $objectName showPoolContents
PoolManager name:DefaultDatasource
PoolManager object:746354514
Total number of connections: 3 (max/min 20/1, reap/unused/aged 180/1800/0,
connectiontimeout/purge 1800/EntirePool)
(testConnection/inteval false/0, stuck timer/time
/threshold 0/0/0, surge time/connections 0/-1)
Shared Connection information (shared partitions 200)
No shared connections
Free Connection information (free distribution table/partitions 5/1)
(2)(0)MCWrapper id 5c6af75b Managed connection WSRdbManagedConnectionImpl@4b5
a775b State:STATE_ACTIVE_FREE
(2)(0)MCWrapper id 3394375a Managed connection WSRdbManagedConnectionImpl@328
5f75a State:STATE_ACTIVE_FREE
(2)(0)MCWrapper id 4795b75a Managed connection WSRdbManagedConnectionImpl@46a
4b75a State:STATE_ACTIVE_FREE
Total number of connections in free pool: 3
UnShared Connection information
No unshared connections