8

I have java code which connects to a MS-SQL database and procures some data.

Before running the code I set the class path in the Unix Server and it used to work fine.

But for some reason the same jar file which was working a few days back is throwing a Class not found exception java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver

I have un-jared the jar file and found that the driver class which I'm loading :

Class.forName("net.sourceforge.jtds.jdbc.Driver");

is present in the specified package structure.

I don't understand how this is happening.

Can anyone suggest any tips to resolve this.

4
  • Is it possible that you have another version of that jar? Commented Sep 6, 2013 at 13:23
  • 4
    This is happening because you don't have the driver's JAR on the classpath. Perhaps the people who administer the server moved it. We can't answer that for you. Commented Sep 6, 2013 at 13:23
  • No is the same jar file that I used before and prior to running the java code I add the jar to the classpath "setenv CLASSPATH ${CLASSPATH}:/app/config/usr/admin//jar_test/test2/jtds_conn/jtds-1.2.7.jar" Commented Sep 6, 2013 at 13:29
  • And the jar file is at the same location as it was before. I have never faced such an issue before. Commented Sep 6, 2013 at 13:34

3 Answers 3

4

The issue of java.lang.ClassNotFoundException might be the outcome of several reasons:

  • Jar file is not available in class path. (This is not your case. as you have mentioned).

  • Your jar file is corrupted.

  • Your environment variable value is not accessible by current user. (Permission revoked by administrator).

  • Current user don't have permission to read jar file.

Please verify the last three options.

Sign up to request clarification or add additional context in comments.

Comments

2

Right button on project-> Properties - > Java built Path -> Order and Export -> And check checkBox with you jar.

If you connect on Android project to Use 1.2.7 version.

Comments

1

I know it's late, but for others facing the same problem..

If you are using eclipse:
1. Go to Project -> Properties -> Java Build Path -> Order and export.. and check the jar file for jtds.version.jar
2. Go to Run Configurations and add this jar file to the user defined jars.

Hope this helps..:)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.