Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DataSource class

 
Nelson Nadal
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Nelson Nadal
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 531
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Nelson Nadal
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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" );
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic