• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate newbie problem with connectivity

 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am new to Hibernate, but not to JDBC.

When attempting to run an elaborate Hibernate-enabled app in eclipse, I get the error copied below.

Below, I include copies of the error stack trace, a successful Hello World hibernate configuration, and my unsuccessful hibernate configuration.

--A test program using the same connection information (triple checked) hits the database successfully.

--The hello world Hibernate application with a simple hibernate.cfg.xml file also hits the database successfully.

--but my larger hibernate application fails to connect to the database.

THANKS IN ADVANCE FOR ANY AND ALL SUGGESTIONS!


The error produced by the large hibernate application is:

java.sql.SQLException: The Network Adapter could not establish the connection
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:412)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:531)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:221)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at ocao.adss.reallocator.OCAODataSource.getConnection(OCAODataSource.java:38)


The successful helloworld hibernate configuration is:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
..CONNECTION INFO (USERNAME, PASSWORD, URL)..
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Mapping files -->
<mapping resource="contact.hbm.xml"/>
</session-factory>
</hibernate-configuration>


Now, here is my behemouth hibernate config that is yielding the connection timeout error above. (of course I suppose the problem could be in code):


<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>

<property name="hibernate.show_sql">true</property>
<property name="hibernate.query.factory_class">
org.hibernate.hql.ast.ASTQueryTranslatorFactory
</property>
<property name="hibernate.jdbc.batch_size">30</property>
<property name="hibernate.jdbc.use_streams_for_binary">
true
</property>
<!-- <property name="hibernate.default_schema">adss_prod</property> -->
<property name="hibernate.use_outer_join">true</property>
<property name="hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider
</property>
<property name="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</property>
<property name="hibernate.connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>


...CONNECTION INFO (URL, USERNAME, PASSWORD)


<property name="hibernate.cglib.use_reflection_optimizer">
false
</property>
...MANY HBM MAPPING FILES LIKE THE ONE JUST BELOW

<mapping resource="wrtt/adkt/model/core/College.hbm.xml" />

</session-factory>
</hibernate-configuration>
 
Benjamin Weaver
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To refine my question:


Is it possible that hibernate configuration or code could be ultimately responsible for the connection error?

I copy the first 2 lines error again here:

java.sql.SQLException: The Network Adapter could not establish the connection
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:412)
...

This to me does look like a physical connection problem. But as I mentioned I am able to connect successfully using JDBC or a Hello World hibernate program.


I did notice this line a few lines down in the stack trace:
..
at ocao.adss.reallocator.OCAODataSource.getConnection(OCAODataSource.java:38)
..

I have assumed that this class is using the hibernate config. But if it is not, then perhaps that class is causing the problem.

 
Benjamin Weaver
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My apologies:

In this rather badly designed code to which I am new, it turns out that someone had completely by-passed the hibernate config in the class I mentioned in my last reply.

Once I changed that configuration. Everything ran.


 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic