Trying to connect to SQL Server 2008 Express database with SQL Server authentication always result in “Login failed for user '…'.”

I am using jTDS to connect a Liferay instance to an SQL Server 2008 Express server using the SQL Server authentication (instead of the Windows' auth method). I have something like this in my portal-ext.properties:

jdbc.default.driverClassName=net.sourceforge.jtds.jdbc.Driver
jdbc.default.url=jdbc:jtds:sqlserver://127.0.0.1:1433/somedb
jdbc.default.username=someuser
jdbc.default.password=somepassword

(For those that do not know Liferay, it is somewhat alike to call

Class.forName("net.sourceforge.jtds.jdbc.Driver");
con = DriverManager.getConnection("jdbc:jtds:sqlserver://127.0.0.1:1433/somedb",
                                  "someuser", "somepassword");

However, although I pass the correct username and password, it keeps going wrong with the message Login failed for user 'someuser'. I am dead sure the server login, the database user and the database exists and are well configured.

What can be wrong?

Answers


Well, I suppose there can be infinite reasons for such an error. In my case, nonetheless, the solution was the following:

  1. Enable the TCP/IP connection in SQL Configuration Manager.

  2. Open the SQL Server Management Studio (if you do not have it installed, install it; it can have its own pitfalls, however).

  3. Right-click on the database server (as in the picture below) and click in Properties.

  4. Select the Security option and mark SQL Server and Windows authentication mode. Click in OK.
  5. Open the SQL Server Configuration Manager and restart the SQL Server service.

After this, I got my connections without problems. This article helped me a lot.


Need Your Help

How to display youtube video on website using GAE

python google-app-engine iframe youtube

I am trying to include a youtube video on website that I'm developing using GAE and python.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.