下载官方jdbc,解压后里面有例子。有jre7和jre8的driver的jar。
跑连接例子的时候报错
- com.microsoft.sqlserver.jdbc.SQLServerException: 通过端口 1433 连接到主机 localhost 的 TCP/IP 连接失败。错误:“connect timed out。请验证连接属性。确保 SQL Server 的实例正在主机上运行,且在此端口接受 TCP/IP 连接,还要确保防火墙没有阻止到此端口的 TCP 连接。”。
https://blog.csdn.net/niaonao/article/details/53897486 可以 - 警告: Failed to load the sqljdbc_auth.dll cause : no sqljdbc_auth in java.library.path
解决办法:将sqljdbc_auth.dll拷贝到C:\Windows\System32目录下即可解决
https://blog.csdn.net/tingzhiyi/article/details/52086662
//=====================================================================
//
// File: connectURL.java
// Summary: This Microsoft JDBC Driver for SQL Server sample application
// demonstrates how to connect to a SQL Server database by using
// a connection URL. It also demonstrates how to retrieve data
// from a SQL Server database by using an SQL statement.
//
//---------------------------------------------------------------------
//
// This file is part of the Microsoft JDBC Driver for SQL Server Code Samples.
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// This source code is intended only as a supplement to Microsoft
// Development Tools and/or