-->
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.  [ 8 posts ] 
Author Message
 Post subject: Datasource but no JNDI
PostPosted: Wed Dec 15, 2004 5:32 pm 
Beginner
Beginner

Joined: Thu Oct 14, 2004 9:50 am
Posts: 43
Hibernate version:
216

Hello all, i have a datasource, but no jndi provider running, how do i make this datasource available to hibernate?

tnx


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2004 1:04 pm 
Beginner
Beginner

Joined: Thu Oct 14, 2004 9:50 am
Posts: 43
no takers?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2004 1:13 pm 
Beginner
Beginner

Joined: Tue Oct 26, 2004 12:45 pm
Posts: 43
Location: Israel
You just don't use the session-factory "name" attribute, and use the datasource as usual:

Code:
<session-factory>
     <property name="connection.datasource">java:/MyDS</property>
      ...
      ...

</session-factory>


jus.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2004 1:47 pm 
Beginner
Beginner

Joined: Thu Oct 14, 2004 9:50 am
Posts: 43
except unless i'm mistaken,
Code:
java:/MyDS
is a jndi url, and i don't have a jndi provider running.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2004 1:59 pm 
Beginner
Beginner

Joined: Sun Oct 03, 2004 8:50 am
Posts: 32
Location: McLean, VA
You could use a custom connection provider to get/create the DataSource. Just set the following Hibernate property to whatever custom class you write:

hibernate.connection.provider_class

_________________
- Chad


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2004 2:16 pm 
Beginner
Beginner

Joined: Thu Oct 14, 2004 9:50 am
Posts: 43
Excellent idea, very very very close.
But i also need to either (1) be able to obtain the actual instance of the connectionprovider/datastore taht hibernate uses, or (2) explicitly set an instnace of either, not the class. With JNDI, a specific instance placed into jndi would've been used.
Any ideas on how i can do either 1 or 2?

tnx.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2004 2:28 pm 
Beginner
Beginner

Joined: Sun Oct 03, 2004 8:50 am
Posts: 32
Location: McLean, VA
Just write your connection provider in such a way as to provide this functionality. Not knowing anything about the rest of your app one option would be to provide some static method on the connection provider class that gets/sets the DataSource. Or another option would be to have the connection provider, in it's default constructor, pull the DataSource from some place that you have access to it. Maybe a DataSourceManager class?

_________________
- Chad


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2004 2:32 pm 
Beginner
Beginner

Joined: Thu Oct 14, 2004 9:50 am
Posts: 43
excellent suggestions both!

i'll try them out and let everyone know, whether or not they want to know.

tnx a lot.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.