Class NotFoundException: net.sourceforge.jtds.jdbc.Driver

I have Java code that connects to an MS-SQL database and purchases some data.

Before running the code, I set the class path to Unix Server and it worked fine.

But for some reason, the same jar file that worked a few days ago throws a class exception not found by java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver

I have an un-jared jar file and found that the driver class I am loading is:

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

present in the specified package structure.

I do not understand how this happens.

Can anyone offer any suggestions on how to fix it.

+5
source share
3 answers

The java.lang.ClassNotFoundException problem can be the result of several reasons:

  • Jar file is not available in class path. (This is none of your business. You mentioned).

  • Your jar file is corrupt.

  • The value of the environment variable is not available to the current user. (Permission revoked by administrator).

  • The current user does not have permission to read the jar file.

Please check the last three options.

+3
source

The right button in the project-> Properties → Java built Path → Order and export → And check the checkBox with you jar.

If you are connecting to an Android project to use version 1.2.7.

+2
source

I know this 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 user-defined banks.

Hope this helps .. :)

+1
source

Source: https://habr.com/ru/post/1500933/


All Articles