Java connects SQL server2012 detailed process via JDBC

Source: Internet
Author: User

before you connect to a database, you must ensure that SQL Server 2012 is in SQL Server authentication mode, not Windows authentication. If the latter is selected at the time of installation, reset the following:to set the authentication method for SQL Server 2012:1. Right-click on the connected server and select Properties2. Click Security on the left, select SQL Server and Windows authentication in the section3. Set the password and SA login for the SAin the root directory, click Security, Login, select the sa login, right-click to select PropertiesClick General on the left to set the login SA and password on the right4. After setting the account password, click on the left side of the properties of the sa login and select Enable on the right side of the login5. Restart the SQL Server serverwith SQL Server Authentication in place, open SQL Server Configuration Manager in all programs, locate the SQL Server network configuration on the left side of the Configuration Manager window, and then expand the "Protocol for database name" to turn on the protocol in the right. Next, double-click the TCP/IP protocol, select the address in the following column to select an IP address, TCP port number, active selection Yes, enabled Select Yes. Last SQL Server servicefirst turn on the Telnet service: Open "control Panel" → "Programs", "in programs and features" to find and click "Turn Windows features on or off" into the Windows Feature Settings dialog box. Locate and tick the "Telnet client," and finally "OK" to complete the installation in a few moments. In addition to this, we can also install the "TFTP client", "Internet information Service" and so on through the wizard. After the installation is complete, the Telnet service is disabled by default. You also need to perform start → run and enter services.msc to open the service Manager. Locate and double-click the Telnet service entry, set it to start manually (more secure, only when needed), and finally start the service OK to exit. Open a Command Prompt window, type: Telnet 127.0.0.1 1433successful connection will enter a completely black interface, connection failure will prompt connection failureNext, configure the environment variable CLASSPATH:download Microsoft JDBC Driver 4.0 for SQL Server, extract the files, get Sqljdbc.jar and Sqljdbc4.jar. If you are using the jre1.7 version, ignore the Sqljdbc.jar (because you cannot use it, and if it is used with Sqljdbc4.jar, it will be an error). the following settings are for the jre1.7 version (1.7 should also apply):Create a new folder on the D disk, named Sqljdbc4, and copy the Sqljdbc4.jar into one. Right-click My computer → properties → advanced system settings (advanced) → environment variable, double-click the CLASSPATH variable in the system variable (or select Classpath → edit), append ";D: \sqljdbc4 \sqljdbc4.jar" In the last face (note that there is a ; If there is no classpath, create a new CLASSPATH variable and set its value to "D:\sqljdbc4 \sqljdbc4.jar". after you have configured the environment variables, copy the Sqljdbc4.jar class library files to the D:\Program Files\java\jdk1.7.0\jre\lib\ext directory. (Copy to the Jdk\jre\lib\ext directory of the installed JDK) and copy the Sqljdbc4.jar class library file to the D:\Program files\java\jre7\lib\ext directory (copy to the installed JDK jdk\jre\ Lib\ext in the directory below)If you are using Tomcat as your server, you will need to copy the Sqljdbc4.jar class library files to the C:\apache-tomcat-7.0.11\lib directory (the Tomcat installation directory). Copy the Sqljdbc4.jar class library file to the D:\apache-tomcat-7.0.11\webapps\test\WEB-INF\lib directory (test directory is a personal app) Add a Sqljdbc4.jar package to a project in Eclipseuse Java to connect to SQL Server through JDBC with the above configuration

Java connects SQL server2012 detailed process via JDBC

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.