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?
Well, I suppose there can be infinite reasons for such an error. In my case, nonetheless, the solution was the following:
Enable the TCP/IP connection in SQL Configuration Manager.
Open the SQL Server Management Studio (if you do not have it installed, install it; it can have its own pitfalls, however).
Right-click on the database server (as in the picture below) and click in Properties
.
Security
option and mark SQL Server and Windows authentication mode
. Click in OK.
After this, I got my connections without problems. This article helped me a lot.