There are many problems with SQL Server connection. If you do not set it, you cannot connect it. Please note here! (Some materials are from the Internet)
Problems with JDBC connection to MySQL
(The example contains the JDBC2005 driver. In the lib folder, right-click Build Path ---> add to build path)
Run the connectionSqlServer2005 packageJavaConnectionSQLClass!
1. Driver Problems:
JDBC2005 and JDBC2008 must be seated on the right. Otherwise, an error will be reported! (I use 2008)
2. Service Startup Problems:
In fact, in many cases, the connection fails because your service is not started!
Run -----> enter services. msc ----- to find the SQL Server service and start it.
If you are not at ease, start all SQL Server services!
3. Logon account and password Problems
Root Cause: Many users do not set it during installation and only use Windows authentication to log on.
3.1 SET Password
After logging on, create a query connection and enter:Exec sp_password null, 'sa ', 'sa'-- Change the sa password to sa. The first one is the password and the last one is the user name.
3.2 set SQL Server Authentication Login(If this parameter is not setAn error occurred while logging on to SQL server user 'sa '.)
1. Open the database-log on to the database as a Windows User
2,Login Name -- double-click sa (Open attribute)
3,
General -- set password -- OK (as described above, here is the visual setting)
4,Status -- Logon: enabled -- OK
5,Right-click the server name -- Properties
6,Security -- select SQL Server and Windows Authentication mode -- OK
7. Right-click the server name -- restart -- close the database connection and exit the program -- log on to the database with sa
4. Everything is OK. The connection is successful under Eclipse.Execution result: