これは奇妙です。VirtualBox 4.2.6 を実行している Mac OS X 10.7.5 64 ビット ホストを使用しています。Microsoft SQL Server Express 2012 を実行するブリッジ ネットワークを備えた Windows 7 SP1 ゲスト (64 ビット) を使用しています。動的ポートではなくポート 1433 で TCP/IP を使用するように SQL Server を構成しました (設定は 0 ではなく空白です)。Windows 7 ゲストの IPv4 アドレスは 192.168.99.132 で、Windows ファイアウォールはオフになっています。
Windows と Mac の両方に、Microsoft SQL Server 2012 JDBC ドライバーと Squirrel SQL クライアント 3.4.0 をダウンロードしました。Windows 7 ゲスト OS 自体で Squirrel を実行すると、"winny"、"localhost"、または "192.168.99.132" のようなゲスト マシン名を使用して、Microsoft JDBC ドライバー経由で SQL Server に問題なく接続できます (JDBC URL jdbc:sqlserver://winny\SQLEXPRESS:1433;databaseName=vha)。ただし、Mac ホストで実行されている Squirrel から SQL Server に接続しようとすると、例外が発生します (以下のスタック トレースを参照)。
ここが奇妙な部分です。Mac ホストからjTDS SQL Server ドライバー (バージョン 1.2.7 は JDK6 を使用しているため、jTDS 1.3.0 は使用できません。そのバージョンは JDK7 のみです) を使用すると、すぐにJDBC URL jdbc:jtds:sqlserver://192.168.99.132:1433/vha。
Microsoft ドライバーは失敗するが、jTDS はリモート ホストから成功する理由はありますか? Microsoft にある jTDS URL から欠落している唯一の情報は、インスタンス名 ("SQLEXPRESS") です。はい、インスタンス名の有無にかかわらず Microsoft URL を試しました。
Mac ホストの Java バージョンは次のとおりです。
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)
Windows 7 ゲストの Java バージョンは次のとおりです。
java version "1.6.0_35"
Java(TM) SE Runtime Environment (build 1.6.0_35-b10)
Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01, mixed mode)
Mac ホストから Windows 7 ゲストに接続するときのスタック トレース:
java.util.concurrent.ExecutionException: java.lang.RuntimeException: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 192.168.99.132, port 1433 has failed. Error: "null. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:232)
at java.util.concurrent.FutureTask.get(FutureTask.java:91)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.awaitConnection(OpenConnectionCommand.java:132)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.access$100(OpenConnectionCommand.java:45)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand$2.run(OpenConnectionCommand.java:115)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.RuntimeException: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 192.168.99.132, port 1433 has failed. Error: "null. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.executeConnect(OpenConnectionCommand.java:171)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.access$000(OpenConnectionCommand.java:45)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand$1.run(OpenConnectionCommand.java:104)
... 6 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 192.168.99.132, port 1433 has failed. Error: "null. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)
at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:241)
at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2243)
at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:491)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1309)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
at net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager.getConnection(SQLDriverManager.java:133)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.executeConnect(OpenConnectionCommand.java:167)
... 8 more