wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes hibernate code and data source Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate code and data source" Watch "hibernate code and data source" New topic
Author

hibernate code and data source

ben oliver
Ranch Hand

Joined: Mar 28, 2006
Posts: 374
I created a data source in a pplication server. My hibernate code is stand alone java code. can I use that data source to access database without deploying my hibernate code to the server ? How ?

Thanks.
Jason Ferguson
Ranch Hand

Joined: Sep 16, 2007
Posts: 47
Hi Ben,

I assume you mean that you configured a JNDI datasource on your application server. I'm assuming that you are asking if you can access the datasource with non-hibernate code.

JNDI is not a hibernate-only technology: I've used it with vanilla JDBC plenty of times. This is a bit Off-Topic for the ORM forum, but the code would look something like this (without exception checking):



If this isn't what you were asking, my apologies.

Jason



Originally posted by ben oliver:
I created a data source in a pplication server. My hibernate code is stand alone java code. can I use that data source to access database without deploying my hibernate code to the server ? How ?

Thanks.
ben oliver
Ranch Hand

Joined: Mar 28, 2006
Posts: 374
Hi Jason, you got me right partially. yes I created a datasource inside an application server. Meanwhile I have a standalone java code (it IS hibernate) that I do NOT want to deploy to the server. For example, I can write a simple table query and print-out code using hibernate but I do NOT deploy this code to the application server. The code is not a j2ee code, it is just a print out type code. Ok ?

Now for the code it has the hibernate configuration file. In the file I intend to specify a datasource that is configured on the application server so that the code can use. can I do that and how ? I am sure I can do it if the code is deployed as a j2ee app to the server. but i am not sure if it is ok if the hibernate code is not deployed to the server ?

Got it ?

Thanks !
Jason Ferguson
Ranch Hand

Joined: Sep 16, 2007
Posts: 47
Okay, I understand now... you want to use the JNDI Datasource that you configured on the application server with a local application (with a remote database).

I've never tried this before... can anyone else shed some light on this?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: hibernate code and data source
 
Similar Threads
Servlet action is not available
Using Hibernate with DataSource or connection pool
Application Perfomance issue
Hibernate in a non-managed environment
Hibernate with WebSphere/WebLogic.