package test;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * 测试连接操作sqlserver
 * 
 * @author huangzhengjun
 *
 */
public class SqlServerTest {

	public static void main(String[] args) {
		// com.microsoft.sqlserver.jdbc.SQLServerDriver.class
		String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
		String dbURL = "jdbc:sqlserver://10.10.167.23:1433;DatabaseName=Rts";
		String userName = "lfuser";
		String userPwd = "LF123SPoss";
		Connection sqlServerConnection;
		try {
			Class.forName(driverName);
			sqlServerConnection = DriverManager.getConnection(dbURL, userName, userPwd);
			System.out.println("连接数据库成功:" + sqlServerConnection.toString());

		} catch (Exception e) {
			e.printStackTrace();
			System.out.print("连接失败");
		}
	}

}
