I want to link a SQL Server Expess 2005 Database to a simple Java application. The resulting error is:
Exception: Fehler bei der Anmeldung für den Benutzer 'terencewin'. Der Benutzer
ist keiner vertrauenswürdigen SQL Server-Verbindung zugeordnet. (means: The user is not associated with a trusted SQL Server connection)
Microsoft reccommends: Change the Authentication Mode of the SQL server from "Windows Authentication Mode (Windows Authentication)"
to "Mixed Mode (Windows Authentication and SQL Server Authentication)". But in the Express versions there is no Mixed Mode. Either can I find some security tab to change the secuity authentication mode to "SQL Server and Windows".
The database is called ppverwaltung and the table person. The database can be accessed by Microsoft SQL Server Management Studio Express.
I use sqlcjbc4.jar as driver in a correct classpath statement.
The user "terencewin" is a SQL-Server-Authentication user with the password "test".
I alternatively tried to get access by a Windows-Authentication, no luck.
I too tried to eshablish a DataSourceName, but this did not work too.
Things worth considering (or knowing) as you go forward:
You can use Windows Authentication only. Some drivers (jTDS and the latest MS one) support NTLM
Accessing fields by their index is risky, unless you also know for sure the query will always return the same fields in the same order
You should always close connections as soon as you are finished with them in a finally block
Joined: Dec 19, 2007
Still some remarks to SQL 2005 and 2008 Server Express:
I first tryed with SQL 2005 Server as the installation process is shorter. Now I see that the SQL of 2005 is very limited, so that it is not possible to import a SQL-Dump from MySQL.
Despite the more steps to install 2008 Server Express it is recommended, as (hopefully) the syntax is closer to the syntax of the actual MySQL version.
To install SQL 2008 Server you have to do the following:
SQL 2008 Express Server
Management Console 2008
sqljdbc4.jar (JDBC-Driver, put into classpath)
Configure Port (eg. 1433)
Change authentication to Windows and SQL-Server
Create user in management console
add sqljdbc4.jar to classpath
I did not check yet, but I hope transfer of data from MySQL to SQL2008 is easier.
Joined: Dec 19, 2007
Still a remark:
Sql Server Express 2008 works well on a XP 32 bit System.
I first installed Sql Server Express 2005 and then Sql Server Express 2008 without deinstalling the 2005 version on a XP 64. This gave a mess. I just recommend to deinstall an old Express version before installing a new one. I'm not sure, if the errors came because of the 64 bit XP.
The installation instructions for SQL Server itself (the server component anyway) state you need to uninstall previous versions first. I believe you can have multiple versions of the client tools. If you need multiple versions of the server, run them in a VM.