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>;

猜你喜欢

转载自weitao1026.iteye.com/blog/2336821