Specify IBatis query timeout

2019-05-18 04:14发布

问题:

There is a way to specify IBatis query timeout using oracle jdbc and Java?

Thanks

回答1:

From the iBatis manual :

in the <settings> element :

defaultStatementTimeout

(iBATIS versions 2.2.0 and later) This setting is an integer value that will be applied as the JDBC query timeout for all statements. This value can be overridden with the “statement” attribute of any mapped statement. If not specified, no query timeout will be set unless specified on the “statement” attribute of a mapped statement. The specified value is the number of seconds the driver will wait for a statement to finish. Note that not all drivers support this setting.

on the statement paremeters :

timeout

(iBATIS versions 2.2.0 and later only)

Sets the JDBC query timeout for this statement. Any value specified here will override the value specified in the “defaultStatementTimeout” setting in the SQLMapConfig.xml file. If you specify a default timeout and decide that you don't want a timeout for a particular statement, set the timeout value to 0. The specified value is the number of seconds the driver will wait for a statement to finish. Note that not all drivers support this setting.

The oracle drivers support this functionality, so this should work.