日期:2014-05-20  浏览次数:20780 次

java中在数据库中插入数据出现得异常
java.sql.SQLException: I/O Error: Connection reset
at net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:1052)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:465)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeQuery(JtdsStatement.java:1301)
at com.demo.test.Sqlserver_To_Mysql.getTableData(Sqlserver_To_Mysql.java:364)
at com.demo.test.Sqlserver_To_Mysql.main(Sqlserver_To_Mysql.java:113)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.io.DataInputStream.readFully(Unknown Source)
at java.io.DataInputStream.readFully(Unknown Source)
at net.sourceforge.jtds.jdbc.SharedSocket.readPacket(SharedSocket.java:841)
at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:722)
at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:466)
at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:103)
at net.sourceforge.jtds.jdbc.ResponseStream.peek(ResponseStream.java:88)
at net.sourceforge.jtds.jdbc.TdsCore.wait(TdsCore.java:3928)
at net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:1045)
... 4 more

------解决方案--------------------
连接被关闭了

就是你的connection close方法放的地方不对,导致执行当前SQL时,连接已关闭。

或者根本没有连接
------解决方案--------------------
你是不是刚刚建立连接就给关闭了
------解决方案--------------------
Caused by: java.net.SocketException: Connection reset
没有连接上
------解决方案--------------------
连接断开了 原因很多, 服务器关了,IP改了, 程序中人为关闭了连接 。。