18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Error connecting to Sql-Server using NTLM mechanism of Jtds driver
Steps
1. Add jtds Driver to SAHI_EXT_CLASS_PATH.
2. Put ntlmauth.dll in %PATH%
3. Enable TCP/IP protocol for MSSQLSERVER
4. Run db.sah
db.sah given below is throwing an exception.
var db = _getDB("net.sourceforge.jtds.jdbc.Driver", "jdbc:jtds:sqlserver://localhost:1433/DB");
var $rs = db.select("select * from table");
However connecting using a Java program works fine.
Please check and appraise if more information is needed.
import java.sql.*;
public class DBTest{
public static void main(String []str)throws Exception{
Connection con = DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/DB");
Statement st = con.createStatement();
ResultSet res = st.executeQuery("SELECT * FROM table");
while(res.next()){
System.out.println(res.getString("ClientKey"));
}
}
}
Reference: http://sourceforge.net/p/jtds/code/HEAD/tree/branches/jTDS 1.3 (stable)/README.SSO
Stack Trace
logType=html logDir=D:\sahi_pro\userdata\logs\playback\db_ie__24Jun2013__11_28_0
1_212/html
Jun 24, 2013 11:29:06 AM net.sf.sahi.RemoteRequestProcessor processHttp
WARNING: Returning CannotConnectResponse for: https://images.edge.messenger.live
.com/Messenger_16x16.png
Jun 24, 2013 11:29:06 AM net.sf.sahi.RemoteRequestProcessor processHttp
WARNING: Returning CannotConnectResponse for: https://images.edge.messenger.live
.com/Messenger_16x16.png
Jun 24, 2013 11:42:03 AM net.sf.sahi.RemoteRequestProcessor processHttp
WARNING: Returning CannotConnectResponse for: https://images.edge.messenger.live
.com/Messenger_16x16.png
java.sql.SQLException: Login failed for user 'undefined'.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.j
ava:372)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2988)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2421)
at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:632)
at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:3
71)
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 net.sf.sahi.plugin.DBClient.getResult(DBClient.java:131)
at net.sf.sahi.plugin.DBClient.select(DBClient.java:105)
at net.sf.sahi.plugin.DBClient.select(DBClient.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:22
5)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:147
3)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:815)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.j
ava:109)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:3
94)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:309
1)
at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.j
ava:120)
at org.mozilla.javascript.Context.evaluateString(Context.java:1079)
at net.sf.sahi.rhino.RhinoScriptRunner.run(RhinoScriptRunner.java:172)
at java.lang.Thread.run(Unknown Source)
logsInfo=html
1. Add jtds Driver to SAHI_EXT_CLASS_PATH.
2. Put ntlmauth.dll in %PATH%
3. Enable TCP/IP protocol for MSSQLSERVER
4. Run db.sah
db.sah given below is throwing an exception.
var db = _getDB("net.sourceforge.jtds.jdbc.Driver", "jdbc:jtds:sqlserver://localhost:1433/DB");
var $rs = db.select("select * from table");
However connecting using a Java program works fine.
Please check and appraise if more information is needed.
import java.sql.*;
public class DBTest{
public static void main(String []str)throws Exception{
Connection con = DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/DB");
Statement st = con.createStatement();
ResultSet res = st.executeQuery("SELECT * FROM table");
while(res.next()){
System.out.println(res.getString("ClientKey"));
}
}
}
Reference: http://sourceforge.net/p/jtds/code/HEAD/tree/branches/jTDS 1.3 (stable)/README.SSO
Stack Trace
logType=html logDir=D:\sahi_pro\userdata\logs\playback\db_ie__24Jun2013__11_28_0
1_212/html
Jun 24, 2013 11:29:06 AM net.sf.sahi.RemoteRequestProcessor processHttp
WARNING: Returning CannotConnectResponse for: https://images.edge.messenger.live
.com/Messenger_16x16.png
Jun 24, 2013 11:29:06 AM net.sf.sahi.RemoteRequestProcessor processHttp
WARNING: Returning CannotConnectResponse for: https://images.edge.messenger.live
.com/Messenger_16x16.png
Jun 24, 2013 11:42:03 AM net.sf.sahi.RemoteRequestProcessor processHttp
WARNING: Returning CannotConnectResponse for: https://images.edge.messenger.live
.com/Messenger_16x16.png
java.sql.SQLException: Login failed for user 'undefined'.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.j
ava:372)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2988)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2421)
at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:632)
at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:3
71)
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 net.sf.sahi.plugin.DBClient.getResult(DBClient.java:131)
at net.sf.sahi.plugin.DBClient.select(DBClient.java:105)
at net.sf.sahi.plugin.DBClient.select(DBClient.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:22
5)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:147
3)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:815)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.j
ava:109)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:3
94)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:309
1)
at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.j
ava:120)
at org.mozilla.javascript.Context.evaluateString(Context.java:1079)
at net.sf.sahi.rhino.RhinoScriptRunner.run(RhinoScriptRunner.java:172)
at java.lang.Thread.run(Unknown Source)
logsInfo=html
Best Answer
-
The issue is resolved.
2 changes had to be made to get it to work.
1. Use the 64 bit version of ntlmauth.dll that comes with JTDS.
2. Change the connection string to
_getDB("net.sourceforge.jtds.jdbc.Driver", "jdbc:jtds:sqlserver://localhost:1433/DB","","");
Doing so triggers NTLM authentication.
This discussion has been closed.