使用JDBC连接SQL Server 2000 命名实例(Named Instance)
????????最近比較閑,就愛擺弄一些玩意,前時間對ruby on rails比較感興趣,就想繼續看看,但是系統壞了好幾次,前段時間配好的eclipse+rdt+sqlserver的環境也就得重新diy了;
????????按照 Setting up a Rails Development Environment on Windows Using Eclipse上的步驟,一步一步走的挺順利的,可是到Install the DBEdit Eclipse plugin的時候,想恢復以前的直接連接自己比較熟悉的SQL Server 2000,可是死活也無法連上,老是報[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.錯誤,起初以為是沒有打sp3包,就干脆重新安裝了個msde sp4的命名實例,可是懵了,怎么連命名實例啊,想起總是用net start mssql$InstanceName 啟動命名實例服務,突發其想以為可用jdbc:microsoft:sqlserver://serverName$InstanceName:Port來連接還是報[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.錯誤,說明猜想不對,google了一下找了n多資料一直沒有解決,最后在msdn上發現有這么篇文章How To Connect to a SQL Server 2000 Named Instance with JDBC??找到解決方案了:
?To find the SQL Server instance port number, follow these steps:
| 1. | On the Microsoft SQL Server 2000 server, start the SQL Server Network Utility. |
| 2. | Click the General tab, and then click the instance you want from the Instances drop-down menu. |
| 3. | Click TCP/IP, and then click Properties. Note that the port number for this instance appears in the Properties dialog box. |
As soon as you have this value, you can use it in your connection URL when you connect to SQL Server through JDBC. The following is an example of a typical connection URL:
jdbc:microsoft:sqlserver://yourServerName:1433;user=yourUser;password=yourPwd
??????也就是說不是用jdbc:microsoft:sqlserver://serverName$InstanceName:Port這個主觀臆造的URL來連接,而是使用上面的串,其中yourServerName是服務器名,1433應該替換成你命名實例的端口號,在這個url中根本體現不出命名實例名,比如我的連接url:jdbc:microsoft:sqlserver://oy-m:2046(我新安裝的命名實例為ruby,端口號為2046),就這么簡單……
轉載于:https://www.cnblogs.com/Hedonister/archive/2006/09/11/501387.html
總結
以上是生活随笔為你收集整理的使用JDBC连接SQL Server 2000 命名实例(Named Instance)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 网管日志-06.09.08
- 下一篇: 创建带有关联的 XML 架构的 XML