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.  [ 9 posts ] 
Author Message
 Post subject: Hibernate problem with Oracle 10g failover
PostPosted: Tue Jul 07, 2009 4:47 pm 
Newbie

Joined: Tue Jul 07, 2009 4:39 pm
Posts: 4
Hi,

I have an application using hibernate to connect to Oracle 10g.
The application gives the following error when the database is switched from Primary server to Failover or from Failover server to Primary.

org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2216)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
Caused by: java.sql.SQLException: No more data to read from socket
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
at oracle.jdbc.driver.DatabaseError.check_error(DatabaseError.java:885)
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:994)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:951)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:435)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:182)

The configuration xml used has the following properties:

<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="current_session_context_class">thread</property>
<property name="hibernate.connection.datasource">jndi\ebg\webclaimsdb</property>
<property name="hibernate.jndi.class">weblogic.jndi.WLInitialContextFactory</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.show_sql">true</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

I had hoped that disabling the second level cache would solve the problem, but didnt.
Any ideas?

Thanks,
PK


Top
 Profile  
 
 Post subject: Re: Hibernate problem with Oracle 10g failover
PostPosted: Tue Jul 07, 2009 8:37 pm 
Regular
Regular

Joined: Fri Jan 30, 2009 10:10 am
Posts: 74
Location: London
At what level does the failover take place?

How does the application know to establish the JDBC connection with a different server?


--
Stephen Souness


Top
 Profile  
 
 Post subject: Re: Hibernate problem with Oracle 10g failover
PostPosted: Wed Jul 08, 2009 11:25 am 
Newbie

Joined: Tue Jul 07, 2009 4:39 pm
Posts: 4
Hi,

The JDBC uses virtual IP to connect to the database. As the primary database server goes down, the virtual IP is assigned to the failover database server. The disksystem then disconnects from the primary and is mounted by the failover.

The application is running on Weblogic 8.1 SP5 server and the initial capacity of the connection pool as been set to '0' so that it does not hold any stale connections. There are other applications (which do not use hibernate) running on the same weblogic server and connecting to the same database and do not have any problems after the failover process. So I am assuming that hibernate is somewhere caching a stale connection due to which it is not able to connect to the failover database.

Regards,
PK


Top
 Profile  
 
 Post subject: Re: Hibernate problem with Oracle 10g failover
PostPosted: Wed Jul 08, 2009 11:33 am 
Regular
Regular

Joined: Fri Jan 30, 2009 10:10 am
Posts: 74
Location: London
Hi,

I don't see how the initial capacity of the pool would have the effect that you are expecting. Once the connection pool has set up connections it will retain them based on the other configuration options that you specify.


--
Stephen Souness



blog: http://elegant-solutions.blogspot.com/


Top
 Profile  
 
 Post subject: Re: Hibernate problem with Oracle 10g failover
PostPosted: Wed Jul 08, 2009 11:57 am 
Newbie

Joined: Tue Jul 07, 2009 4:39 pm
Posts: 4
The initial capacity by default is '1' for connection pools in weblogic. So at all times it will always have one open connection to the database. So if the database server is restarted, then the connection will become stale. The value is set to '0' to avoid any stale connections from weblogic in case of database restarts.

Since I am using the weblogic connection pooling, I assume that hibernate is not doing any connection pooling.

<property name="hibernate.connection.datasource">jndi\ebg\webclaimsdb</property>
<property name="hibernate.jndi.class">weblogic.jndi.WLInitialContextFactory</property>

Is there any other setting that I need to look at?
Thanks for the help.

Regards,
PK


Top
 Profile  
 
 Post subject: Re: Hibernate problem with Oracle 10g failover
PostPosted: Wed Jul 08, 2009 7:17 pm 
Regular
Regular

Joined: Fri Jan 30, 2009 10:10 am
Posts: 74
Location: London
Hi,

Maybe I am missing something, but my understanding of how JDBC connection pooling works is that the pool retains connections to the database server for the application to reuse, saving the overhead of creating a new connection each time that a database query needs to be run.

Assuming that at least one database query has gone through the pool that Weblogic is managing, the pool size will be greater than zero. If the database server is restarted then those connections in the pool become stale/broken - leading to the problems you have been observing.

The problem is not with Hibernate, but with your connection pooling configuration in Weblogic.


--
Stephen Souness


Top
 Profile  
 
 Post subject: Re: Hibernate problem with Oracle 10g failover
PostPosted: Thu Jul 09, 2009 11:17 am 
Newbie

Joined: Tue Jul 07, 2009 4:39 pm
Posts: 4
I checked the connection settings on the weblogic server and they seem correct according to me. The same setting applies for other apps which do not user hibernate. The other apps work with those setting but the one which uses hibernate doesnt. It might be that the app using hibernate might need a different connection setting on the weblogic server, but I didnt find anything on the net for the same.

Regards,
PK


Top
 Profile  
 
 Post subject: Re: Hibernate problem with Oracle 10g failover
PostPosted: Mon Jul 27, 2009 6:13 pm 
Newbie

Joined: Mon Jul 27, 2009 6:02 pm
Posts: 1
Hello

Did u find any solution for failover?

in our application we use jboss java jsp, hibernate ,if the primary database is down how do i connect to replicated database?

if you got any solutions please let em know

Thanks,
velama


Top
 Profile  
 
 Post subject: Re: Hibernate problem with Oracle 10g failover
PostPosted: Tue Jul 28, 2009 10:05 am 
Newbie

Joined: Tue Jul 21, 2009 10:27 am
Posts: 4
you need to keep the weblogic related jarfiles in the class both

and use below code and make sure your server is running and this jndi name is configured.

<property name="connection.datasource">jndi\ebg\webclaimsdb</property>
<property name="jndi.class">weblogic.jndi.WLInitialContextFactory</property>


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

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.