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.
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 ?
Joined: Mar 28, 2006
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 ?
Joined: Sep 16, 2007
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?