Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am having trouble connecting to my SQL Server database through a jtds connection:

Connection conn = DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/MnA;instance=SQLEXPRESS", "sa","");

SQL Server is enabled, TCP/IP is enabled, Mixed server authentication is enabled

Any ideas?

SQL Server is running

TCP/IP is enabled

enter image description here

enter image description here

java.sql.SQLException: Login failed for user 'sa'. at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic( at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken( at net.sourceforge.jtds.jdbc.TdsCore.nextToken( at net.sourceforge.jtds.jdbc.TdsCore.login( at net.sourceforge.jtds.jdbc.ConnectionJDBC2.( at net.sourceforge.jtds.jdbc.ConnectionJDBC3.( at net.sourceforge.jtds.jdbc.Driver.connect( at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at DB.dbConnect( at testConnection.main(

share|improve this question

migrated from Aug 16 '12 at 18:29

This question came from our site for professional and enthusiast programmers.

Do you have a full stacktrace? – km1 Aug 15 '12 at 0:24
This is off topic for SO; belongs on Database Administrators – Jim Garrison Aug 15 '12 at 0:25
What happens when you try to log in using those credentials in SSMS? – Mr.Brownstone Aug 16 '12 at 18:33

Make sure your jdts jar version is 1.2x. If it is not ,download correct version. And the second option is using JDBC jar for connecting MSSQL database.

share|improve this answer

You are logging in with SQL Authentication, passing in SA as the login and (blank) as the password. Do you know the actual password for SA? If it is truly blank, I strongly suggest you change it to something else and try that in your connection string.

I also suggest you use a login other that SA, unless you truly want your users to have the ability to drop databases, add users, and perform other adminstrator level tasks.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.