facebook

[Closed] Unable to load JDBC dirver

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #271459 Reply

    yyang5823
    Member

    I 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

    #271476 Reply

    Loyal Water
    Member

    The 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.

    #271489 Reply

    yyang5823
    Member

    Thanks 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?

    #271531 Reply

    Loyal Water
    Member

    The 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.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: [Closed] Unable to load JDBC dirver

You must be logged in to post in the forum log in