wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Hibernate newbie problem with connectivity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate newbie problem with connectivity" Watch "Hibernate newbie problem with connectivity" New topic
Author

Hibernate newbie problem with connectivity

Benjamin Weaver
Ranch Hand

Joined: Apr 08, 2003
Posts: 161
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

Joined: Apr 08, 2003
Posts: 161
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

Joined: Apr 08, 2003
Posts: 161
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.


 
 
subject: Hibernate newbie problem with connectivity
 
Similar Threads
Problem connecting to Oracle with Hibernate
org.hibernate.exception.GenericJDBCException: Cannot open connection
Hibernate Oracle problem
Hibernate Maping error
Could not instantiate cache implementation