Connect to SQL Server on a different domain via JDBC
<p>From Windows using SQL Server Management Studio (SSMS), I can only connect to a SQL Server on a different domain as follows:</p>

<p><code>C:\&gt; runas /netonly /user:differentDomainName\aUserName "C:\Program Files (x86
)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Ssms.exe -S anIpAddress"</code></p>

<p>How can I accomplish this connection via JDBC? I've tried using the following connection string with Microsoft's sqljdbc 4.2 driver:</p>

<p><code>jdbc:sqlserver://anIpAddress:1433;database=MAIN;user=differentDomainName\\aUserName;password=pass</code></p>

<p>I receive the following error:</p>

<p><code>com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'differentDomainName\aUserName'</code></p>

<p>This is the same error that I receive if I start SSMS without using runas and typed  differentDomainName\aUserName for Login name in the "Connect to Server" dialog box of SSMS 2012.</p>

<p>Additional Information: The JDBC connection will be established within a application running on Linux. So, running the application using <code>runas</code> is not an option unfortunately.</p>

<p>Another attempt:
I've also tried to use jTDS 1.3.1 with the following connection string:</p>

<p><code>jdbc:jtds:sqlserver://anIpAddress:1433;databaseName=MAIN;domain=differentDomainName;user=aUserName;password=pass</code></p>

<p>since aUserName is set up only for Windows authentication. Unfortunately, this produces the following exception:</p>

<p><code>o.a.tomcat.jdbc.pool.ConnectionPool      : Unable to create initial connections of pool.</code>
Followed by
<code>java.sql.SQLException: I/O Error: DB server closed connection.</code></p>

<p>Permission information: I'm unable to modify anything on the SQL Server machine including any configuration within SQL Server. The "aUserName" account maps to  a SQL Server read only Windows authentication only user.</p>