Java uses JDBC to connect SQL Server database

Java uses JDBC to connect SQL Server database

1. Download Driver

1. Download the Microsoft SQL Server JDBC Driver
https://www.microsoft.com/zh-cn/download/details.aspx?id=11774

Unpack the archive and the sqljdbc42.jar (java8 version) or sqljdbc41.jar (java7 version) into jre / lib / ext java installation directory under the file folder.
The final path: one of your disk \ java \ jdk \ lib \ sqljdbc42.jar

2. Configure SQL Server

2. Open SQL Server Configuration tool, open TCP / IP, IP is set to be one of 127.0.0.1, TCP port is set to 1433, restart the SQL Server service

Such mounting step. The remaining is to write java code.

3. Write Code

Java class package is loaded wrote: Class.forName ( "com.microsoft.sqlserver.jdbc.SQLServerDriver");

Guess you like

Origin www.cnblogs.com/fisherss/p/11804659.html