Java connection to various pitfalls of sqlserver (test by cainiao) and javasqlserver
As a cainiao, when I first started to use java to connect to sqlserver, it took a short time,
I think it is necessary to share my experience with you.
(Because I step on most pitfalls)
First pitfall: load the driver. Java requires a driver to connect to the database. We will download
Sqljdbc. jar is enough. What should I do after the download.
At this time, we add a file in the project, paste the package, and right-click the package.
Add the build path. At this time, you thought it was done, but there are still many pitfalls.
The second pitfall: "Failed to load the sqljdbc_auth.dll". For this, we only need to download
Sqljdbc_auth.dll is enough, but I went down and found various hooligans in it,
So I went to csdn to get another one, which is quite easy to use. After downloading the file, assign it to drive C for windows.
Directory.
You thought it was done, but it didn't.
Third pitfall: Database verification method. As a rookie, it may be the first time SQL Server was installed.
Do not pay attention to the authentication method. However, this affects java connection.
I am the cainiao. I chose Windows verification at the beginning, but it is displayed during connection.
"This login name is from an untrusted domain and cannot be used together with Windows Authentication"
I tried Baidu for a moment and found a lot. I asked the same questions online. Someone replied, "The verification methods are mixed"
After reading this, I understand how to solve the problem by mixing the verification methods. There are not many answers online.
I have summarized the following methods: Step 1: after entering the authentication with windows,
Right-click Properties
Switch the Authentication mode to the following one.
Then
Select the sa user name in the login name and change the password.
The next step is the fourth pitfall. Change the password and log on again. The password is correct but cannot be logged on.
I tried it again and finally solved it.
Right-click and Select Restart to start the instance.
I am a beginner in the freshman year. Sorry.