The class not found problem occurs when connecting Java Web to the SQL server database

Source: Internet
Author: User

Connecting to the database... classNotFound... exception: I found that the jar package has not been imported. (I forgot to import the jar package.) Then I downloaded the jar package from the Microsoft official website (click to go To the download page to download it ). First, import sqljdbc. jar and sqljdbc4.jar. (After decompression, all these two packages are put into tomcat.
In the lib directory.

Bytes ---------------------------------------------------------------------------------------------------------

Why?

The server needs to be restarted!

Because the tomcat server only reads and loads the jar package at startup (there are some configuration files, such as server. xml and web. xml)

Bytes ---------------------------------------------------------------------------------------------------------

In my heart, I am happy, and finally have to deal with it!

However, the same error occurs during a test run...

Bytes ---------------------------------------------------------------------------------------------------------

Tragedy! Then I went to google and Baidu for a while and found that it was caused by the following reasons. I wrote a mistake (my website is 2008)

This is caused by different versions of SqlServer2000 and 2005. The following are the differences between sqlserver2000 and sqlserver2005/2008 drivers and URLs:

1. Connect to SqlServer2000
DriverClassName = com. microsoft. jdbc. sqlserver. SQLServerDriver url = jdbc: microsoft: sqlserver: // localhost: 1433; ...... 2. Connect to SqlServer2005
DriverClassName = com. microsoft. sqlserver. jdbc. SQLServerDriver url = jdbc: sqlserver: // 127.0.0.1: 1433; DatabaseName = Demo
Bytes ---------------------------------------------------------------------------------------------------------
Then restart the server, and re-test the operation or make an error! What's going on ???
Later I found that (I did not know whether it was correct ):
If we import both jar (mentioned above), the former will be given priority when the system is running, and because I am in version 2008, all will still be CLASS NOT FOUND!
After you delete sqljdbc. jar, restart the server and test it again...

Conclusion: Do and you
Know how it works!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.