• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Viji Jan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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.
 
Shinil Mohan
Ranch Hand
Posts: 37
Hibernate Java Oracle
  • Mark post as helpful
  • send pies
  • 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 Java Oracle
  • Mark post as helpful
  • send pies
  • 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 Java Oracle
  • Mark post as helpful
  • send pies
  • 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>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic