-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: query timeout dosn't work in J2se environment!
PostPosted: Tue Apr 17, 2012 11:08 am 
Newbie

Joined: Tue Apr 17, 2012 5:58 am
Posts: 5
hi all,

i have a query in my application. it runs well, but if i disable the network access in my laptop, the application blocks and tries to run the query and take a long time and never throws timeout exception or any other exception. I know that the application blocks in the query implementation from the log files and from the eclipse debugger. I want to set my own timeout period for the query or any other way to detect that something bad has happened to the connection.I have tried set timeouts in the query hint and in the persistence.xml but no vain.
note : when i re enable the network access in my laptop the query runs successfully and the application execution continues normally,otherwise the application will block trying to run the query till the network is enabled.

is this possible in j2se or just for jee environments?
i am using
1-hibernate 4.1
2-ojdbc6.jar
3-oracle 10g remote db server
4-c3p0 connection pool

this getResultList() documentation
http://docs.oracle.com/javaee/6/api/javax/persistence/Query.html#getResultList%28%29

this is how i create my entity manager
Code:
emf = Persistence.createEntityManagerFactory("EntitiesGenerator_2");
em = emf.createEntityManager();


and this is my query
Code:
try{   
      results=em.createNamedQuery("findActiveCyclesInThisMoment"). setHint("javax.persistence.query.timeout", "3"). getResultList();
      }
      catch(Exception ex){
         ex.printStackTrace();
      }
   


and this my persistence.xml properties
Code:

          <property name="javax.persistence.query.timeout" value="3" />
          <property name="hibernate.timeout" value="3" />
          <property name="hibernate.connection.timeout" value="3" />
         
          <property name="hibernate.connection.driver_class " value="oracle.jdbc.driver.OracleDriver" />
          <property name="hibernate.connection.driver" value="oracle.jdbc.driver.OracleDriver" />
         <property name="hibernate.connection.user" value="lba" />
         <property name="hibernate.connection.password" value="lba" />
         <property name="hibernate.connection.url" value="jdbc:oracle:thin:@192.168.1.2:1521:edafadb1" />
         <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
         <property name="hibernate.show_sql" value="false"/>
                                 
        <property name="connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider"/>       
       <property name="hibernate.c3p0.acquire_increment" value="1"/>
        <property name="hibernate.c3p0.idle_test_period" value="3000"/>
        <property name="hibernate.c3p0.min_size" value = "1"/>
        <property name="hibernate.c3p0.max_size" value = "4"/>
        <property name="hibernate.c3p0.max_statements" value = "50"/>
        <property name="hibernate.c3p0.timeout" value = "3"/> 


thanks in advance :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.