使用JDBC连接SQL Server 2000 命名实例(Named Instance)
????????最近比較閑,就愛擺弄一些玩意,前時(shí)間對(duì)ruby on rails比較感興趣,就想繼續(xù)看看,但是系統(tǒng)壞了好幾次,前段時(shí)間配好的eclipse+rdt+sqlserver的環(huán)境也就得重新diy了;
????????按照 Setting up a Rails Development Environment on Windows Using Eclipse上的步驟,一步一步走的挺順利的,可是到Install the DBEdit Eclipse plugin的時(shí)候,想恢復(fù)以前的直接連接自己比較熟悉的SQL Server 2000,可是死活也無法連上,老是報(bào)[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.錯(cuò)誤,起初以為是沒有打sp3包,就干脆重新安裝了個(gè)msde sp4的命名實(shí)例,可是懵了,怎么連命名實(shí)例啊,想起總是用net start mssql$InstanceName 啟動(dòng)命名實(shí)例服務(wù),突發(fā)其想以為可用jdbc:microsoft:sqlserver://serverName$InstanceName:Port來連接還是報(bào)[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.錯(cuò)誤,說明猜想不對(duì),google了一下找了n多資料一直沒有解決,最后在msdn上發(fā)現(xiàn)有這么篇文章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這個(gè)主觀臆造的URL來連接,而是使用上面的串,其中yourServerName是服務(wù)器名,1433應(yīng)該替換成你命名實(shí)例的端口號(hào),在這個(gè)url中根本體現(xiàn)不出命名實(shí)例名,比如我的連接url:jdbc:microsoft:sqlserver://oy-m:2046(我新安裝的命名實(shí)例為ruby,端口號(hào)為2046),就這么簡(jiǎn)單……
轉(zhuǎn)載于:https://www.cnblogs.com/Hedonister/archive/2006/09/11/501387.html
總結(jié)
以上是生活随笔為你收集整理的使用JDBC连接SQL Server 2000 命名实例(Named Instance)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 网管日志-06.09.08
- 下一篇: 创建带有关联的 XML 架构的 XML