0

I am trying to connect to SQL Server using jaydebeapi in python but every time I am getting same error:

java.sql.SQLException: java.sql.SQLException: I/O Error: DB server closed connection.

I know this is an old question but with the same code I am able to connect to other SQL Server databases but now when I try to connect one other SQL Server then T am getting mentioned error. Can anyone tell me what could be the reason. Here is my code:

import jaydebeapi

jarName = "jtds-1.3.1-dist/jtds-1.3.1.jar"

driver = "net.sourceforge.jtds.jdbc.Driver"

server = "server"

db_name = "dbname"

host = "host"

jdbcString = """jdbc:jtds:sqlserver://{0};databaseName={1};integratedSecurity=true;useNTLMv2=true;domain={2}""".format(server,db_name,host)

print(jdbcString)

sql_db_conn = jaydebeapi.connect(driver, jdbcString, ['username', 'password'], jarName)

if sql_db_conn:
  print(sql_db_conn)
else:
  print("not connected")
  • Are you sure you can connect to other servers with this exact same code? Normally you can connect using integrated security (Windows authentication), or you can connect with an username+password (SQL Login), but you can't mix the two together. – AlwaysLearning Oct 20 '20 at 09:53
  • yes @AlwaysLearning i have another ms sql db as well and with this windows auth i am able to connect to the db. – Sachin Parashar Oct 20 '20 at 09:57

0 Answers0