Reputation: 13
I am running a web application with Tomcat - JDBC connection pooling with Informix database. How do I set lock mode to wait?
Upvotes: 1
Views: 1826
Reputation: 61
"How do I set this value via JDBC connection"
As per previous answers either pass it as a connection property or execute the SQL at the start of the connection.
Upvotes: 0
Reputation: 2013
You can also set the default lock time using the 'IFX_LOCK_MODE_WAIT' connection string property (for datasources use 'ds.setIfxIFX_LOCK_MODE_WAIT()')
More info here: https://www.ibm.com/support/knowledgecenter/en/SSGU8G_12.1.0/com.ibm.jdbc_pg.doc/ids_jdbc_034.htm
so, for tomcat, if your datasource looks something like:
<Context path="/jspdemo" docBase="jspdemo" debug="0" reloadable="true" crossContext="true">
<Resource name="jdbc/jspdemo" auth="Container" type="javax.sql.DataSource" maxActive="20"
maxIdle="10" maxWait="1000" username="informix" password="mypasswd"
driverClassName="com.informix.jdbc.IfxDriver"
url="jdbc:informix-sqli://mymachine:1526/stores_demo:INFORMIXSERVER=ol_myserver"/>
</Context>
just use:
<Context path="/jspdemo" docBase="jspdemo" debug="0" reloadable="true" crossContext="true">
<Resource name="jdbc/jspdemo" auth="Container" type="javax.sql.DataSource" maxActive="20"
maxIdle="10" maxWait="1000" username="informix" password="mypasswd"
driverClassName="com.informix.jdbc.IfxDriver"
url="jdbc:informix-sqli://mymachine:1526/stores_demo:INFORMIXSERVER=ol_myserver;IFX_LOCK_MODE_WAIT=60;/>
</Context>
Upvotes: 3
Reputation: 54302
In my environment the first SQL executed after obtaining db connection from pool is:
SET LOCK MODE TO WAIT 15
Upvotes: 0