-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: What is the connection string used for hibernate in Oracle 9
PostPosted: Wed Oct 07, 2009 2:53 pm 
Newbie

Joined: Wed Oct 07, 2009 2:05 pm
Posts: 5
Dear All,

i have installed oracle 9i in my machine.While running the hibernet application i am getting Initial SessionFactory creation failed.org.hibernate.HibernateException: JDBC Driver class not found: org.hsqldb.jdbcDriver
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.vaannila.util.HibernateUtil.<clinit>(HibernateUtil.java:14)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
at com.vaannila.student.Main.main(Main.java:12)
Caused by: org.hibernate.HibernateException: JDBC Driver class not found: org.hsqldb.jdbcDriver
at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:89)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:79)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:448)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325)
at com.vaannila.util.HibernateUtil.<clinit>(HibernateUtil.java:11)
... 3 more
Caused by: java.lang.ClassNotFoundException: org.hsqldb.jdbcDriver
at java.lang.Class.forName(Class.java:127)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:123)
at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:84)
... 10 more
runtime exeception.


My doubt is for oracle 9i what is the peace of code i would replace hibernate.cfg.xml for connection driver so that it should work.
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.url">jdbc:hsqldb:hsql://localhost</property>
<property name="hibernate.connection.username">scott</property>
<property name="connection.password">tiger</property>


hibernate.cfg.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!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.connection.driver_class">org.hsqldb.jdbcDriver</property>
        <property name="hibernate.connection.url">jdbc:hsqldb:hsql://localhost</property>
        <property name="hibernate.connection.username">scott</property>
        <property name="connection.password">tiger</property>
        <property name="connection.pool_size">1</property>
        <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
        <property name="show_sql">true</property>
        <property name="hbm2ddl.auto">create-drop</property>
        <mapping resource="com/vaannila/student/Student.hbm.xml"/>
        <mapping resource="com/vaannila/student/Address.hbm.xml"/>
    </session-factory>
</hibernate-configuration>


Please suggest me for the needful.

Thanks,
Sumanta


Top
 Profile  
 
 Post subject: Re: What is the connection string used for hibernate in Oracle 9
PostPosted: Wed Oct 07, 2009 8:20 pm 
Senior
Senior

Joined: Mon Jul 07, 2008 4:35 pm
Posts: 141
Location: Berlin
Hi sumanta,

your Hibernate.cfg.xml indicates that you currently intend to use the HSQL JDBC Driver (actually fails). HSQL is the built-in database of Hibernate.

If you want to connect to your Oracle DB you'll require an Oracle JDBC Driver which, at first search, can probably be found here. You need to have the Driver package on your classpath and then you change the value for
Code:
<property name="hibernate.connection.driver_class">
accordingly.

CU Froestel

_________________
Have you tried turning it off and on again? [Roy]


Top
 Profile  
 
 Post subject: Re: What is the connection string used for hibernate in Oracle 9
PostPosted: Thu Oct 08, 2009 1:55 am 
Newbie

Joined: Wed Oct 07, 2009 2:05 pm
Posts: 5
Dear Froestel,
Thanks for your respose.
Sir i am beginner of Hibernate.So what the value i will put in the driver name for oracle 9i so that it should work.
<property name="hibernate.connection.driver_class">.

I have added classes12.jar for oracle 9i in the class path.

Please let me know incase i add any new jar file in the class path.

PS::I am not getting any compilation error.
Please suggest me for the needful.


Thanks,
Sumanta


Top
 Profile  
 
 Post subject: Re: What is the connection string used for hibernate in Oracle 9
PostPosted: Thu Oct 08, 2009 5:48 am 
Newbie

Joined: Wed Oct 07, 2009 2:05 pm
Posts: 5
Hi All,

It is working after changing the file.

Code:
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
  <property name="hibernate.connection.url">jdbc:oracle:thin:@//localhost:1521/sumanta</property>


Thanks
Sumanta


Top
 Profile  
 
 Post subject: Re: What is the connection string used for hibernate in Oracle 9
PostPosted: Thu Oct 08, 2009 6:01 am 
Newbie

Joined: Wed Sep 30, 2009 8:28 am
Posts: 10
Hi sumanta,

I want to use on both mysql and oracle db.
But we have to use different dialect,url,username,password and port properties in hibnernate files for different databases.

How to make it as a generic one?

Or is there any possibilty to transmit data from my java program to hibernate.cfg.xml files and use those values.

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.