java采用集成身份验证连接sqlserver2005

import java.sql.*;
public class jdbcTest {
 
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
 
		   String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";   //加载JDBC驱动
		   String dbURL = "jdbc:sqlserver://localhost:1433;integratedSecurity=true;DatabaseName=msdb";   //连接服务器和数据库msdb
		   Connection dbConn=null;
 
		   try {
		   Class.forName(driverName);
		   dbConn = DriverManager.getConnection(dbURL);
		   System.out.println("Connection Successful!");   //如果连接成功 控制台输出Connection Successful!
		   } catch (Exception e) {
		   e.printStackTrace();
		   }
	}
 
}
 

你可能感兴趣的:(java,sql,jdbc,Microsoft)