• 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

java.sql.SQLException: Io exception: The Network Adapter could not establish the connection

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am writing code to connect Java to Oracle 10g datbase using hibernate.
Iam using Oracle 10g express edition.

<hibernate-configuration>

<session-factory>

<!-- Database connection settings -->
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbcracle:thin:@localhost:1525:xe</property>
<property name="connection.username">user</property>
<property name="connection.password">password</property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>

<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.OracleDialect</property>

<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>

<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>

<mapping class="org.hibernate.example.dto.EmployeeDetails"/>

</session-factory>

</hibernate-configuration>


I can able to connect to database separately.while connecting using hiberate,iam getting " java.sql.SQLException: Io exception: The Network Adapter could not establish the connection" error.Please help.
 
Ranch Hand
Posts: 37
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you check you are using the correct version of jar files / JDK, also may be you can try connect to the DB using any other tool to make sure the DB is up and running fine. If you use Eclipse then you can use Data Source Explorer to test this.

Few notes available in oracle site about the dependency of the jar/java etc.. "•Oracle Database XE does not support JDK 1.2 and JDK 1.3, including all classes12*.* files. You need to use the ojdbc14.jar file with JDK 1.4.x instead."

Refer to the URL http://download.oracle.com/docs/cd/B25329_01/doc/appdev.102/b25320/getstart.htm
 
Shinil Mohan
Ranch Hand
Posts: 37
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also if you find all the configuration seems to be correct, may be you can create a standalone java program to test the connectivity to the DB and make sure you have all the Java/Jar versions correct and the DB is up and running correctly. May be some thing like this http://www.javadb.com/connect-to-a-database-and-read-from-table
 
Shinil Mohan
Ranch Hand
Posts: 37
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A sample hibernate cnfg file i used in my application to connect to mysql, which is working fine... May be you can refer to this too..

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/dbhibernate</property>
<property name="hibernate.connection.username">root</property>
<property name="connection.password">****</property>
<property name="connection.pool_size">1</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="show_sql">true</property>
<mapping class="com.keane.tjxCollaboration.Entity.Employee" />
<mapping class="com.keane.tjxCollaboration.Entity.Department" />
</session-factory>
</hibernate-configuration>
 
You may have just won ten million dollars! Or, maybe a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic