November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Setting the JDBC Connection timeout properties through WLST

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.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.

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’)

#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.

weblogicssrrerew-7 weblogicssrrerew-8

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>