JDBC 连接 带实例名的SQL Server

1、直接指定实例名

jdbcDriverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbcUrl=jdbc:sqlserver://192.168.xxx.xxx;instanceName=sql_03;DatabaseName=edu;integratedSecurity=false
hibernate.dialect=org.hibernate.dialect.SQLServerDialect
jdbcUsername=sa
jdbcPassword=xxxxx

DBCP Pool settings
jdbcInitialSize=5
jdbcMaxActive=10
jdbcMaxIdle=5
jdbcMaxWait=30000
jdbcValidationQuery=select 1


2、指定端口

jdbcDriverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbcUrl=jdbc:sqlserver://192.168.xxx.xxx:64150;DatabaseName=edu;integratedSecurity=false
hibernate.dialect=org.hibernate.dialect.SQLServerDialect
jdbcUsername=sa
jdbcPassword=xxx
# DBCP Pool settings
jdbcInitialSize=5
jdbcMaxActive=10
jdbcMaxIdle=5
jdbcMaxWait=30000
jdbcValidationQuery=select 1

指定的多个 SQL Server 实例SQL Server 2000 和 SQL Server 2005 允许在每台服务器上安装多个数据库实例。每个实例都由一个专用名称所标识。若要连接到指定的 SQL Server 实例,可以使用指定实例的端口号(首选),也可将实例名指定为 JDBC URL 属性或 datasource 属性。如果未指定实例名属性或端口号属性,则会创建与默认实例的连接。如以下实例所示:
若要使用端口号,请执行下列操作:
jdbc:sqlserver://localhost:1433;integratedSecurity=true;<more properties as required>;
若要使用 JDBC URL 属性,请执行下列操作:
jdbc:sqlserver://localhost;instanceName=instance1;integratedSecurity=true;<more properties as required>;

参考资料:http://blog.csdn.net/cfhacker007/article/details/4356044

作者:深潭
出处:http://www.cnblogs.com/dbasys/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/dbasys/p/2853567.html