There are different timeout properties in JDBC connection, this post explain the approach to set some of the important timeout properties 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.net.CONNECT_TIMEOUT:
The property oracle.net.CONNECT_TIMEOUT helps to set the login time out in Oracle.
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’)
#cmo.destroyProperty(getMBean(‘/JDBCSystemResources/’+dsName+’/JDBCResource/’+dsName+’/JDBCDriverParams/’+dsName+’/Properties/’+dsName+’/Properties/oracle.jdbc.ReadTimeout’))
cmo.createProperty(‘oracle.jdbc.ReadTimeout’)
cd(‘/JDBCSystemResources/’+dsName+’/JDBCResource/’+dsName+’/JDBCDriverParams/’+dsName+’/Properties/’+dsName+’/Properties/oracle.net.CONNECT_TIMEOUT’)
cmo.setValue(‘10000’)
cd(‘/JDBCSystemResources/’+dsName+’/JDBCResource/’+dsName+’/JDBCDriverParams/’+dsName+’/Properties/’+dsName+’/Properties/oracle.jdbc.ReadTimeout’)
cmo.setValue(‘20000’)
cd(‘/JDBCSystemResources/’+dsName+’/JDBCResource/’+dsName+’/JDBCConnectionPoolParams/’+dsName)
cmo.setInactiveConnectionTimeoutSeconds(120)
cd(‘/JDBCSystemResources/’+dsName+’/JDBCResource/’+dsName+’/JDBCConnectionPoolParams/’+dsName)
cmo.setConnectionReserveTimeoutSeconds(30)
cd(‘/JDBCSystemResources/’+dsName+’/JDBCResource/’+dsName+’/JDBCConnectionPoolParams/’+dsName)
cmo.setStatementTimeout(120)
save()
activate()
print ‘Timeout settings for the datasource ‘+dsName+’ has been completed’
def main():
adminURL=’t3://localhost:8000′
adminUserName=’weblogic’
adminPassword=’welcome1′
connect(adminUserName, adminPassword, adminURL)
setJDBCTimeoutProperties()
disconnect()
main()
Execute the script:
cd %WLS_HOME%\common\bin
wlst.sh SetJDBCTimeoutProperties.py
Restart the server after successful execution.
Recent Comments