批量加载数据时,对等体重置连接

时间:2016-02-13 16:24:24

标签: java mysql database jdbc database-connection

我正在运行以下方法:

private static void bulkLoad() throws SQLException{
    final Connection connection = DriverManager.getConnection(connectionURL);
    final Statement s = connection.createStatement();
    s.execute("LOAD DATA LOCAL INFILE 'LoadData.txt' INTO TABLE emails FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n'");
}

但是不一致(有时我得到它,有时我没有)得到这个错误:

Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 114,558 milliseconds ago.  The last packet sent successfully to the server was 104,210 milliseconds ago.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:983)
    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3644)
    at com.mysql.jdbc.MysqlIO.sendFileToServer(MysqlIO.java:3730)
    at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:3030)
    at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:2280)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2673)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2546)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2504)
    at com.mysql.jdbc.StatementImpl.executeInternal(StatementImpl.java:840)
    at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:740)
    at SendEmailTools.bulkLoad(SendEmailTools.java:18)
    at SendEmailTools.main(SendEmailTools.java:110)
Caused by: java.net.SocketException: Connection reset by peer: socket write error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(Unknown Source)
    at java.net.SocketOutputStream.write(Unknown Source)
    at java.io.BufferedOutputStream.write(Unknown Source)
    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3625)
    ... 10 more

首先,我认为它可能是超时问题,但我检查了我的wait_timeout并看到它设置为28800,这应该是足够的时间。有谁知道什么是错的?

0 个答案:

没有答案