File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes hibernate + oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate + oracle" Watch "hibernate + oracle" New topic
Author

hibernate + oracle

anuja Edathu
Ranch Hand

Joined: Sep 09, 2005
Posts: 84
Hi all,

I want to connect to the oracle database using hibernate.


but when im trying retrieve object from database im getting exception
org.hibernate.exception.GenericJDBCException


this is what i used in hibernate configuration file.

<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc racle:thin:@127.0.0.1:1521 RA920</property>
<property name="hibernate.connection.username">sys</property>
<property name="hibernate.connection.password">dba</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>

can any one help
regards
Anuja K.
Keith Pitty
Ranch Hand

Joined: Sep 22, 2005
Posts: 32
Have you tried posting this to the Hibernate forum (available via hibernate.org)?
anuja Edathu
Ranch Hand

Joined: Sep 09, 2005
Posts: 84
Hi keith,
i didn't thanks for ur advice i'll try.Do you have any suggestion?please reply
regards
Anuja
Keith Pitty
Ranch Hand

Joined: Sep 22, 2005
Posts: 32
Not with the information you have supplied. The whole stack trace as well as the code snippet may help shed more light on the problem.
anuja Edathu
Ranch Hand

Joined: Sep 09, 2005
Posts: 84
i have downloaded and installed oracle 9.2.04 for linux on one m/c
downloaded and put the ojdbc14.jar in the lib directory along with other jar files.Do i need to have any other jar files?


<?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>
<!-- <property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="hibernate.connection.url">jdbc:microsoft:sqlserver://192.168.3.7:1433; DATABASENAME = sample</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>-->
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc racle:thin:@192.168.3.16:1521 RA920</property>
<property name="hibernate.connection.username">sys</property>
<property name="hibernate.connection.password">dba</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>

<!-- Mapping files -->
<mapping resource="rolemaster.hbm.xml"/>
<mapping resource="usermaster.hbm.xml"/>

</session-factory>
</hibernate-configuration>

I've written two java classes with getter and setter method.created another java class for retrieving the values.and needed hibernate mapping file.

I tried my code with sql server it is working(with the block that is commented now).
i created TABLE for both sql and oracle.

Will this help?(I am new to Oracle and hibernate)


Thanks and Regards
Anuja K
Keith Pitty
Ranch Hand

Joined: Sep 22, 2005
Posts: 32
Have you tried a simple program using JDBC to test that you are using the correct database driver and URL for Oracle?
anuja Edathu
Ranch Hand

Joined: Sep 09, 2005
Posts: 84
Thank you,
I could solve it.I created and connected using the new user name and password,
any way i don't know why couldn't i get connected as sys dba.

Regards
Anuja K.
anuja Edathu
Ranch Hand

Joined: Sep 09, 2005
Posts: 84
Hi,
I do have another problem . I deployed my files to tomcat and its fine exxcept I have to put all the hibernate mapping files and hibernate configuration in the WEB-INF/classes along with the java class files.
When i m taking that out to lib its showing error like the hibernate.cfg.xml not found.

Is there any way to remove the xmls from the WEB-INF/classes


Regards
Anuja K.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

They need to be in the classpath, otherwise how can Hibernate find them?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
signor Rhena
Greenhorn

Joined: Jul 25, 2005
Posts: 6
Hay all,
I had similar problem all the code work for Mysql but not for Oracle 9. My JDBC test program for ORACLE I did test and it work!!!
I am thinking configuration or mapping issue!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hibernate + oracle