Cannot access SQL Server database using jtds

南笙酒味 提交于 2019-12-25 09:45:23

问题


I am trying to access a SQL Server database using Java and jtds. This is my (very) simple code:

String url = "jdbc:jtds:sqlserver://dev.company.com:1433/master;domain=COMP;USENTLMV2=true;SSL=request";
String driver = "net.sourceforge.jtds.jdbc.Driver";
String userName = "COMP\\username";
String password = "s3cr3t";
Connection conn = null;

try {
    Class.forName(driver);
    conn = DriverManager.getConnection(url, userName, password);
} catch (Exception e) {
    e.printStackTrace();
} finally {
    conn.close();
}

pom.xml

<dependency>
    <groupId>net.sourceforge.jtds</groupId>
    <artifactId>jtds</artifactId>
    <version>1.2.8</version>
</dependency>

After a few minutes of no activity, I get this error:

java.sql.SQLException: Network error IOException: Connection reset
    ....
Caused by: java.net.SocketException: Connection reset
    ....

I can ping dev.company.com, and I can access the database using a GUI (SQLPro for my Mac) so it's a valid connection, but I don't know what else to do.


回答1:


Please move away from JTDS. Their last release was ion 2012. As per one of the developers of JTDS (Nida ), the project has ceased all active development activities.

Please use SQLJdbc42 driver from Microsoft which is quite stable.

I am suffering from a JTDS issue with SQL Server on SSL and got the confirmation that this project is DEAD.



来源:https://stackoverflow.com/questions/43792672/cannot-access-sql-server-database-using-jtds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!