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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM