Hello everyone, good morning, I'm having problems with an update routine in the mysql database, I'm reading a BufferedReader containing more than 3,000,000 records and doing the update in mysql, but when I'm near the first 1,200 records the system has the following error:
2015-08-21 20:27:12,512 ERROR Erro de IO: Connection reset
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.security.ssl.InputRecord.readFully(Unknown Source)
at sun.security.ssl.InputRecord.read(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readDataRecord(Unknown Source)
at sun.security.ssl.AppInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at sun.net.www.http.ChunkedInputStream.fastRead(Unknown Source)
at sun.net.www.http.ChunkedInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Unknown Source)
at java.util.zip.InflaterInputStream.fill(Unknown Source)
at java.util.zip.InflaterInputStream.read(Unknown Source)
at java.util.zip.GZIPInputStream.read(Unknown Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.io.InputStreamReader.read(Unknown Source)
at java.io.BufferedReader.fill(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at ar.com.qualaconsulting.AccountDataLoader.loadCF_Ids(AccountDataLoader.java:1387)
at ar.com.qualaconsulting.AccountDataLoader.preprocess(AccountDataLoader.java:1717)
at ar.com.qualaconsulting.TestDataLoader.main(TestDataLoader.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
The referenced code is this:
InputStreamReader csv = new InputStreamReader(results, "UTF-8");
BufferedReader csvReader = new BufferedReader(csv);
//Busca a primeira linha que é o cabeçalho
csvReader.readLine();
String curLine = null;
logger.info("Vai Percorrer arquivo CSV");
int totalArquivosAtualizados = 0;
while((curLine = csvReader.readLine()) != null){//loop vai começar na 2nd linha
try{
logger.info("SfID atualizado = "+totalArquivosAtualizados);
curLine = curLine.replace("\"", "");
String[] line = curLine.split(",");
String numCF = line[1];
String sfId = line[0];
logger.info("Update no MySql com ID da cadeia forçada. numCF:" +numCF +" sfId:"+sfId);
cadeiaForcadaDao.updateSfID(Long.valueOf(numCF), sfId);
totalArquivosAtualizados++;
logger.info("Update no MySql FINALIZADO.");
}catch(NumberFormatException e){
this.logger.error("Ocorreu um erro ao atualizar a cadeia: ", e);
}catch(Exception e1){
this.logger.error("Ocorreu um uma exeção genérica: ", e1);
}
}
if (csvReader != null) {
try {
logger.info("Fechando o arquivo csvReader!");
csvReader.close();
} catch (IOException e) {
this.logger.error("Erro de cono fechamento de arquivo .CSV =>" +e.getMessage());
}
}
logger.info("Total de SfIDs atualizados = "+totalArquivosAtualizados);
}
logger.info("Gravação finalizada");
}
} catch (ConnectionException e) {
this.logger.error("Erro de conexão ao SF: " + e.getMessage(), e);
} catch (UnsupportedEncodingException e) {
this.logger.error("Erro de 'Encoding': " + e.getMessage(), e);
} catch (IOException e) {
this.logger.error("Erro de IO: " + e.getMessage(), e);
} catch (InterruptedException e) {
this.logger.error("Erro de Interrupção: " + e.getMessage(), e);
}
The line referenced in the error (AccountDataLoader.java:1387) is just:
while((curLine = csvReader.readLine()) != null){
When you are reading a file, are there any limits to the BufferedReader or Mysql for multiple updates in this way?