MS SQL Server and JDBC: closed connection

前端 未结 3 1121
南笙
南笙 2021-01-17 23:25

Im getting

I/O Error: DB server closed connection.

while connecting to MS SQL server 2008 from java code .

3条回答
  •  无人共我
    2021-01-17 23:53

    You have an authentication error in on the MS SQL side.

    If you're not in control of how to adquire the connection (ie, you're using a Datasource or a Connection Pool), the connection URL must contain the login and password to be used, like:

    jdbc:sqlserver://machine:1433;instance=SQLEXPRESS;databaseName=db;user=USERNAME;password=PASSWORD";
    

    If the application is running on a Windows machine and you want to use the credentials of the logged user, then you can specify the domain parameter with or without useNTLMv2.

    Finally, if you are on a windows machine but you want to authenticate the user against a domain, then you must supply the username, password and domain parameters. You can read all about it in the jtds FAQ, specially the URL Format section.

提交回复
热议问题