Take the 2-minute tour ×
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. It's 100% free, no registration required.

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(SQLDiagnostic.java:368) at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820) at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258) at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:603) at net.sourceforge.jtds.jdbc.ConnectionJDBC2.(ConnectionJDBC2.java:345) at net.sourceforge.jtds.jdbc.ConnectionJDBC3.(ConnectionJDBC3.java:50) at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at DB.dbConnect(testConnection.java:17) at testConnection.main(testConnection.java:7)

share|improve this question
    
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
add comment

migrated from stackoverflow.com Aug 16 '12 at 18:29

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

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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