This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes how to use datasource in a non-tomcat project? 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 » JDBC
Bookmark "how to use datasource in a non-tomcat project?" Watch "how to use datasource in a non-tomcat project?" New topic

how to use datasource in a non-tomcat project?

rick collette
Ranch Hand

Joined: Mar 22, 2002
Posts: 208
Hi, guys:

I am stuck here with this problem. I created a Java project on
Eclipse, the reason is I have to use my own framework that won't
fit into a Tomcat project. But we are using Tomcat to run our application. Now I have to create datasource for Hibernate to use. If this is a tomcat project, I can set up DB2 datasource in Tomcat's server.xml. But it seems I cannot access this datasource set up in server.xml and web.xml using Hibernate code or JDBC code. I am wondering if there is a workaround for this?

[ February 02, 2006: Message edited by: rick collette ]
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

I think you'll have better luck with this question in the JDBC forum.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
You should be able to set up a non-JNDI data source. Check your driver/DB documentation on how to instantiate the data source class with the related data you need, eg database name, port number, etc. Once you have the data source, you can then get the Connection.

SCJP 1.4, SCWCD 1.3, SCBCD 1.3
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: how to use datasource in a non-tomcat project?
Similar Threads
how to connect to multiple databases dynamically using Hibernate
resource ref needs to be setup
How to get connected to 2 databases
server.xml problem
Adding DataSource for Hibernate when Tomcat already startup.