openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Prud'hommeaux <>
Subject Re: Cannot get QueryTimeout to work
Date Fri, 23 Mar 2007 00:09:15 GMT

FYI, setQueryTimeout() will meter call Statement.setQueryTimeout() on  
the underlying driver. JDBC drivers frequently either don't implement  
this, or their implementation is very flawed. Unfortunately, we  
haven't done detailed analyses of which drivers properly implement it  
or not, so I don't know if DB2 has a proper implementation of it.

One way to test our whether it is supported is to write a small stand- 
alone test case that directly creates a JDBC Connection and tries to  
execute a slow or blocking SQL statement on a Statement after you  
call setQueryTimeout() and see if it correctly times out. If it  
doesn't, then the problem is with the driver. If it does, then  
there's something wrong with OpenJPA and we can investigate further.

On Mar 22, 2007, at 4:47 PM, Don Brady wrote:

> Hi,
>  I hope this is not off-topic on this list, but I cannot seem to  
> get QueryTimeout to work, using the persistence.xml below under  
> WebSphere 6.1 with a DB2 connection pool defined in WebSphere,  
> under OpenJPA 0.9.6.
>  It seems to just ignore the timeout specified and run to  
> completion no longer how long it takes.
>  I was wondering if the below should work or if there is another  
> way of setting a query timeout.  I cannot find one.
>  Actually if I wrap it in a transaction, then I can set a timeout  
> on the transaction and that does work.   But I was avoiding using a  
> transaction on the basis of advice in the book "Pro EJB" to omit  
> transactions if they are not needed, in the case of a read-only  
> query, because they may incur a performance penalty.  Would that be  
> true in OpenJPA for a large read-only query or should I just use a  
> transaction and set the timeout on that?
>  Thank you for any comments!
>  Don
> persistence.xml contents:
>  <?xml version="1.0" encoding="UTF-8"?>
> <persistence version="1.0"
> 	xmlns=""
> 	xmlns:xsi=""
> 	xsi:schemaLocation=" http:// 
> 	<persistence-unit name="mpu-prod" transaction-type="JTA">
> 		<provider>
> 			org.apache.openjpa.persistence.PersistenceProviderImpl
> 		</provider>
> 		<jta-data-source>jdbc/mship-prod</jta-data-source>
> 		<non-jta-data-source>jdbc/mship-prod</non-jta-data-source>		
> 		<mapping-file>META-INF/orm-prod.xml</mapping-file>		
> 		<exclude-unlisted-classes>false</exclude-unlisted-classes>
> 		<properties>
> 		      <property name="openjpa.jdbc.Schema" value="PROD" />
> 			<property name="openjpa.DataCache" value="false" />
> 			<property name="openjpa.RemoteCommitProvider" value="sjvm" />
> 			<property name="openjpa.Log"
> 				value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE" />
> 			<property name="openjpa.jdbc.DBDictionary"
> 				value="db2(StoreCharsAsNumbers=false)" />
> 			<property name="openjpa.TransactionMode" value="managed" />
> 			<property name="openjpa.jdbc.TransactionIsolation"
> 				value="read-committed" />
> 			<property name="openjpa.ConnectionFactoryMode"
> 				value="managed" />
> 			<property name="openjpa.ConnectionFactoryProperties"  
> value="QueryTimeout=30"/>
> 		</properties>
> 	</persistence-unit>
> 	</persistence>

View raw message