Search

Microsoft JDBC driver fails, but jTDS driver succeeds by matthewadams12

Active

1
0
Sign in
to vote
Type: Bug
ID: 776705
Opened: 1/16/2013 7:23:10 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
The Microsoft JDBC driver is failing to connect to a SQL Server 2012 Express database via TCP/IP, but the jTDS driver is succeeding against the exact same database.

See forum post http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/0d7b1129-7efc-427b-9115-303cab0315c1 for discussion. For your convenience, here's a copy as well:

This is weird. I'm on a Mac OS X 10.7.5 64-bit host running VirtualBox 4.2.6. I've got a Windows 7 SP1 guest (64-bit) with bridged networking running Microsoft SQL Server Express 2012. I configured SQL Server to use TCP/IP on port 1433, not dynamic ports (setting is blank, not 0). The Windows 7 guest has IPv4 address 192.168.99.132 and Windows Firewall is turned off.

I downloaded the Microsoft SQL Server 2012 JDBC driver (sqljdbc4.jar) along with Squirrel SQL client 3.4.0 for both Windows and Mac. When I run Squirrel on the Windows 7 guest OS itself, I can connect to SQL Server just fine via the Microsoft JDBC driver using the machine names of either "winny", "localhost", or "192.168.99.132" (JDBC URLs like jdbc:sqlserver://winny\SQLEXPRESS:1433;databaseName=vha). However, when I try to connect to SQL Server from Squirrel on the Mac via the IP address 192.168.9.132 (can't resolve "winny"), I get an exception (see stack trace below).

Here's the weird part. If, from the Mac host, I use the jTDS SQL Server driver (version 1.2.7 because I'm using JDK6, so can't use jTDS 1.3.0 -- that version is JDK7 only), I connect right away with both of the JDBC URLs jdbc:jtds:sqlserver://192.168.99.132:1433/vha;instance=SQLEXPRESS or jdbc:jtds:sqlserver://192.168.99.132:1433/vha.

Any ideas why the Microsoft driver fails but jTDS succeeds from a remote host? And yes, I've tried the Microsoft URL with and without the instance name.

Java version on the Mac host is:

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)
Java version on the Windows 7 guest is:

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)

Stack trace when connecting from Mac host to Windows 7 guest is in "Actual Results" of this bug report.
Details (expand)

Product Language

English

Version

SQL Server 2012 - Express Edition

Category

JDBC

Operating System

Windows 7 (all editions)

Operating System Language

US English

Steps to Reproduce

Install & configure software as specified in description.

Host OS software:
Mac OS X 10.7.5
VirtualBox 4.2.6
SquirrelSQL Client 3.4.0
Microsoft JDBC Driver 4.0 for SQL Server
jTDS SQL Server Driver 1.2.7

Guest VM setting:
Bridged networking

Guest OS software:
Windows 7 SP1
SQL Server 2012 Express
SquirrelSQL Client 3.4.0
Microsoft JDBC Driver 4.0 for SQL Server
jTDS SQL Server Driver 1.2.7

Guest OS configuration:
Windows Firewall: off
SQL Server:
Create new instance called "SQLEXPRESS"
TCP/IP enabled on port 1433
Dynamic ports turned off

On guest OS, use SquirrelSQL to connect to local SQL Server instance via Microsoft JDBC driver.

On host OS, confirm guest OS can be reached using ping via IP address. Then, use SquirrelSQL to connect to SQL Server instance via the Microsoft JDBC driver & observe error. Next, use SquirrelSQL to connect via jTDS driver & observe success.

Actual Results

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

Expected Results

Successful connection

Platform

X64

Virtualization

Other (e.g. VM Ware, specify in Description)
File Attachments
0 attachments
Sign in to post a comment.
Sign in to post a workaround.