Pages

Monday, April 28, 2014

WLST script to set the JDBC Connection timeout properties in weblogic server

WLST script to set the JDBC Connection timeout properties in weblogic server


There are different timeout properties in JDBC connection, this tutorial explains the approach to set some of the important JDBC Connection timeout properties in weblogic server through WLST script.

Inactive Connection Timeout


The number of inactive seconds on a reserved connection before WebLogic Server reclaims the connection and releases it back into the connection pool.
You can use the Inactive Connection Timeout feature to reclaim leaked connections — connections that were not explicitly closed by the application.


Connection Reserve Timeout


The number of seconds after which a call to reserve a connection from the connection pool will timeout.
When set to 0, a call will never timeout.
When set to -1, a call will timeout immediately.


Statement Timeout


The time after which a statement currently being executed will time out.
A value of -1 disables this feature.
A value of 0 means that statements will not time out.


oracle.jdbc.ReadTimeout


The property oracle.jdbc.ReadTimeout helps to set read timeout while reading from the socket.

oracle.net.READ_TIMEOUT for jdbc versions < 10.1.0.5 oracle.jdbc.ReadTimeout for jdbc versions >=10.1.0.5


oracle.net.CONNECT_TIMEOUT


The property oracle.net.CONNECT_TIMEOUT helps to set the login time out in Oracle.
WLST Script

The below WLST script will help us to set the JDBC connection timeout properties

SetJDBCTimeoutProperties.py
def setJDBCTimeoutProperties():
   dsName='CRM6EAIReference'
   edit()
   startEdit()
       
   server='AdminServer'
   cd("Servers/"+server)
   target=cmo
 
   print '========================================='
   print 'Setting the timeout properties for DataSource....'
   print '========================================='  
           
   cd('/JDBCSystemResources/'+dsName+'/JDBCResource/'+dsName+'/JDBCDriverParams/'+dsName+'/Properties/'+dsName)
   #cmo.destroyProperty(getMBean('/JDBCSystemResources/'+dsName+'/JDBCResource/'+dsName+'/JDBCDriverParams/'+dsName+'/Properties/'+dsName+'/Properties/oracle.net.CONNECT_TIMEOUT'))
   cmo.createProperty('oracle.net.CONNECT_TIMEOUT')


Script

https://github.com/techforum-repo/youttubedata/blob/master/scripts/wlst/SetJDBCTimeoutProperties.py

Before executing the script, change the configurations as required.

Execute the script — <<Oracle_Home>>\oracle_common\common\bin\wlst.cmd SetJDBCTimeoutProperties.py



Restart the server after successful execution. Now the JDBC connection timeout properties are set to the datasource.



Under advanced section







No comments:

Post a Comment