- This topic has 3 replies, 2 voices, and was last updated 17 years, 4 months ago by Loyal Water.
-
AuthorPosts
-
yyang5823MemberI am new to MyEclipse and Java programming. I am trying to connect to a Microsoft SQL database in MyEclipse. I downloaded the JTDS driver and configured the connection in Database Explorer. I was able to connect to the database and view tables.
After that, I created a Dynamic web project and a simple servlet. In the “DoGet” method, following statement generates the “ClassNotFoundException”:
Class.forName(“net.sourceforge.jtds.jdbc.Driver”);To fix the problem, I tried following:
– Re-configured the build path to add the jtds jar file
– Remove the App Server (Tomcat) associated with the project and added it back again. I hoped this would get my project republished.None of those fix the problem. Please help.
My test machine configurations include:
OS: Windows XP Pro
JDK 1.5
Elipse 3.2.2
MyEcipse 5.5
Tomcat 5.5
JTDS 1.2
Loyal WaterMemberThe problem is you need to copy your driver to the /lib dir of the application server you are deploying to (common/lib for Tomcat). After that the app server will be able to find the driver and fire it up in your app for you.
yyang5823MemberThanks for the help. copying the dirver jar file to common\lib directory fixed the jdbc driver problem.
This brings up another question about servlet.jar file. Right now, I don’t have to add jtds.jar as external jar in build path configuration. The JDBC driver is loaded successfully. But, to build a servlet, I have to add servlet.jar file as an external jar in build path config. Otherwise, the compiler complains about “unable to find javax.servlet….
The servlet.jar file is in the common\bin directory, why I have to add this jar file for each web project I create? Am I missing any configuration step setting up Tomcat 5.5?
Loyal WaterMemberThe servlet.jar is necessary in your *build path* so you can compile classes that rely on servlet spec. This library doesn’t get deployed.
More specifically… there are libraries you need at development time that are already provided by the app server at run time.
So we add those to the build path so you can compile your classes and get things like autocomplete and debugging. But when you deploy your project, those JARs aren’t deployed.
-
AuthorPosts