jsp connects sql server 2008 cannot connect

  • 2020-06-07 05:09:30
  • OfStack

1, the first is if you meet javax servlet. ServletException: java. lang. ClassNotFoundException: com. microsoft. jdbc. sqlserver. SQLServerDriver this mistake,

Then estimate. You should put Class forName (" com. microsoft. jdbc. sqlserver. SQLServerDriver ");

To Class. forName (" com. microsoft. sqlserver. jdbc. SQLServerDriver ");

2, when the error is javax. servlet. ServletException: java. sql. SQLException: No suitable driver found for jdbc: microsoft: sqlserver: / / localhost: 1034; DatabaseName = test2,

Should put String url = "jdbc: microsoft: sqlserver: / / localhost: 1034; DatabaseName = test2 ";

To String url = "jdbc: sqlserver: / / localhost: 1034; DatabaseName = test2 ";

3, error for javax. servlet. ServletException: com. microsoft. sqlserver. jdbc. SQLServerException: unable to open the login the requested database "test2". Login failed.

There e are a lot of ways to solve this problem online, such as check the driver, user permission what, I repeatedly to create users, set permissions, 1 straight failed. Finally, I went to the configuration manager, checked the dynamic port of TCP/IP's IPALL in the network configuration, found it was not the usual 1433, but 1034, and then changed 1 in the code, it was ok... In addition, sql server user permissions or pay attention to, otherwise easy to go wrong


Related articles: