wood burning stoves 2.0*
The moose likes JDBC and the fly likes DataSource class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "DataSource class" Watch "DataSource class" New topic
Author

DataSource class

Nelson Nadal
Ranch Hand

Joined: Jun 06, 2002
Posts: 169
Hi fellows,

Just a question, is DataSource class used only for WAR applications? I mean will it not work unless I make my files inside WAR? I can't run my web database program using DataSources/JNDI... but I can run using DriverManager class only.... Thanks.

Nelson
karthikeyan Chockalingam
Ranch Hand

Joined: Sep 06, 2003
Posts: 259
It may work. Please read Obtaining a Client Connection Using a DataSource in the link below

http://e-docs.bea.com/wls/docs81/jdbc/programming.html
[ September 21, 2006: Message edited by: karthi keyan ]

http://www.skillassert.com


Nelson Nadal
Ranch Hand

Joined: Jun 06, 2002
Posts: 169
Hi karthi,

Im using Jakarta 5x, but I will try to look to your referred link, maybe I missed something in xml configurations...

Many Thanks,
Nelson
Masoud Kalali
Author
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

do you add the JDBC driver to tomcat shared library folder ?
you know that a datasource and a connection pool is managed by application server and application server create and take care of them for you.
so you need to add the JDBC driver to tomcat shared lib folder.

in case that this does not helps , can you past your datasource XML content (if you are using context.xml file) or tell give us more details about exception or error message that you get.


hth


Masoud Kalali
Software Engineer - My Weblog - GlassFish Security
Nelson Nadal
Ranch Hand

Joined: Jun 06, 2002
Posts: 169
Hello Masoud Kalali,
I've got naming exception error... Im using MS ACCESS as the database... Ive downloaded the driver (type 4) for it, coz I assumed this is different.(is it different from JDBC ODBC we created in Control Panel?)

Below are the xml and codes for your reference. I've been stuck w/this for a week inspite of having book references...]

*********
web.xml
**********






**********
server.xml
***********




***************************
JNDIDataSource.xml I put this in C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\Catalina\localhost
**************************






***************
myJsp.jsp
**************




I put the needed jar files under this directory
C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib
commons-pool-1.2.jar
commons-dbcp-1.2.1.jar
commons-collections-2.1.1.jar
Access_JDBC30.jar <---- Driver of MS Access
jndi.jar



If I run from stand alone java like the one below... the database can access

String url = "jdbcdbc:student1";
String username = "anonymous";
String password = "guest";

// Load the driver to allow connection to the database
try {
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: DataSource class
 
Similar Threads
Petclinic of Spring2.5.6 with MYSQL and GLASSFISH
How to deploy WAR file in WebSphere Applcation Server 7
Getting data which doesn't belong to DataBase
DWR and JdbcTemplate
Creating a Datasource