-->
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.  [ 1 post ] 
Author Message
 Post subject: Could not find datasource
PostPosted: Fri May 25, 2012 2:14 pm 
Newbie

Joined: Fri May 25, 2012 1:58 pm
Posts: 3
Hi,

I would like some help in understanding how to use glassfish JDBC datasource in Hibernate.
I want to understand the basics of where things are and how Hibernate knows about the JDBC datasource (created using Glassfish admin console).

Here's what I have:
Created a connection pool (Name oraclepool. pinged it and it works fine)
Created a JDBC datasource (Name jdbc/hibresource) and set connection pool to oraclepool.

I created a small application using Eclipse and I created a mapping file and I created a hibernate.cfg.xml file and included mapping file in it. In hibernate.cfg.xml if I use straight jdbc like:

<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password">hr</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@anuramesh-vaio:1521:orcl</property>
<property name="hibernate.connection.username">hr</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="show_sql">true</property>
<mapping resource="com/jsfhibernate/module/Employees.hbm.xml"/>
<mapping resource="com/jsfhibernate/module/Department.hbm.xml"/>
</session-factory>
</hibernate-configuration>

it works fine. I am able to use this small application to connect and look at data in the oracle database. All fine.

But how do I use the JDBC datasource that I created in glassfish? How do I tell hibernate about it?
I looked at this and found several posts that suggested the following:

<session-factory>
<property name="connection.datasource">jdbc/hibresource</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<mapping resource="tn_entities/com/practice/hib/Film.hbm.xml"/>
..

I tried this so many times and it didn't work. When I build the Hibernate configuration I keep getting the error "Could not find datasource"

I am confused, how does my application (I am using Eclipse and I did New -> Hibernate Console Configuration and generated a hibernate console configuration) know about the JDBC datasource that I created in glassfish?

Where do I add this information in my application? Is there a place where you tell it (other than hibernate.cfg.xml where I just give connection.datasource)

Can some one please help me understand this?

Many many thanks in advance.

Regards
Anu


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

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.