I'm trying to convert some of my common Ant database tasks to work with MS SQL Server.
I quickly ran into an issue with SQL Server integrated authentication.
My first stab was to simply provide a username and password:
<target name="test"> <sql driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://localhost:1433;databaseName=test" userid="myUsername" password="myPassword" print="TRUE"> SELECT CURRENT_TIMESTAMP </sql> </target>
That failed with a username, password error.
A quick Google later I discovered the 'integratedSecurity' attribute. Note you now leave the username/password blank:
<target name="test"> <sql driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://localhost:1433;databaseName=test;integratedSecurity=true" userid="" password="" print="TRUE"> SELECT CURRENT_TIMESTAMP </sql> </target>
But that still bombed out. I was getting this error:
SQL Exception: com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. WARNING: Failed to load the sqljdbc_auth.dll
Digging around I discovered this file is included in the JDBC driver download:
C:\Downloads\Microsoft SQL Server JDBC Driver 3.0\sqljdbc_3.0\enu\auth\x64\sqljdbc_auth.dll
There are several versions provided (IA64, x64, x86). Pick the one for your environment and copy it to your C:\Windows\system32 directory.
Your script should now work!
Buildfile: C:\build\db.build.xml test: [sql] Executing commands [sql] 2011-06-17 15:49:50.853 [sql] 0 rows affected [sql] 1 of 1 SQL statements executed successfully BUILD SUCCESSFUL Total time: 1 second