JDBC Connectivity for SQL Server

Duke, the Java Mascot, in the waving pose. Duk...

Duke, the Java Mascot (Photo credit: Wikipedia)

Java programs need connectivity to Microsoft SQL Server, and a popular open source JDBC driver is available to get the job done. I recommend the JTDS driver, find the download and documentation online at http://jtds.sourceforge.net/. What does TDS stand for? Tabular Data Stream, it’s the protocol used by the driver to talk to SQL Server.

If you’re using JTDS on Windows and you want to use automatic (Trusted, Single-Sign-On/SSO) Windows Authentication, you’ll need to manually install the DLLs provided for Windows Auth. The DLL files and required install locations should be something like (for 64-bit systems only):

  • Copy “x86\SSO\ntlmauth.dll” from zip to “C:\Windows\SysWOW64\ntlmauth.dll” – 32-bit DLL (WOW64 = Compatibility Windows-32 on-top-of Windows-64)
  • Copy “x64\SSO\ntlmauth.dll” from zip to “C:\Windows\System32\ntlmauth.dll” – 64-bit DLL
  • Installation and usage notes are in the zip file under “README.SSO”
  • Make sure the JTDS jar is in the classpath for the Java program that you’re running
  • Review to Official JTDS URL Format FAQ for details to build your connection string: “If the domain parameter is present but no user name and password are provided, jTDS uses its native Single-Sign-On library and logs in with the logged Windows user’s credentials (for this to work one would obviously need to be on Windows, logged into a domain, and also have the SSO library installed.
  • Example SQL SSO Connect String: jdbc:jtds:sqlserver://SERVER-NAME/DATABASE-NAME;domain=DOMAIN-NAME (substitute your server-name, database-name, and domain-name)
  • For named instance connections, insert “;instance=INSTANCE-NAME” into your connect string. You *cannot* use the Microsoft style of Server\Instance, JTDS does not support that.

Good luck! 🙂


About notesbytom

Keeping technology notes on WordPress.com to free up my mind to solve new problems rather than figuring out the same ones repeatedly :-).
This entry was posted in System Administration and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s