This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
if i put mysql-connector-java-5.0.3-bin.jar in my "/WEB-INF/lib" directory, i'm getting ClassNotFoundError. If i put it in "$TOMCAT-DIR/common/lib" directory it's working fine.
the problem is, i don't want to depend on the tomcat's libraries......i want to include that file in my /WEB-INF/lib folder ( so that my application will be self-consistent).
Is there any other way to use connection pooling without <data-sources> mechanism in struts......i heard in this forum that it's not a recommended approach. If so what else to use to get my connections pooled.
i have seen in "D:\apache-tomcat-5.5.25\common\lib\naming-factory-dbcp.jar", that the "org.apache.tomcat.dbcp.dbcp.BasicDataSource" exists. Is that problem ( that i have to place mysql.jar in /common/lib) because of this??
do you think that problem disappears if i use commons-pooling??
why is data-source approach in struts is not recommended??
If you look closely at the documentation for Struts 1.2.9, you will see that the struts DataSource utility is listed as "deprecated". In version 1.3.5 and above, it's been removed entirely. So, one reason not to use it is that it limits your ability to upgrade to a later version.
The main reason it's not recommended, though, is that it violates the MVC pattern. Database access belongs in model classes, but the Struts Datasource utility requires you to get the DataSource in an Action class, which is a controller class, not a model class.
The recommended means of accessing a Datasource in any Java EE web application is to use the application server's utilities to create a JNDI DataSource and then use a JNDI lookup in your code to retrieve it. The Tomcat documentation has information on how to do this. It's also discussed in this thread.
Regarding your "Class not found" problem, I believe your assessment is correct: Both the DBCP jar file and the MYSQL driver jar file must be loaded by the same classloader. So, you must either have both jars in the application class path, or in the server class path, but you can't have one in one path and one in the other.