Meaningless Drivel is fun!
The moose likes JDBC and Relational Databases 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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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
I agree. Here's the link:
subject: how to use datasource in a non-tomcat project?
It's not a secret anymore!