sql server - java.sql.BatchUpdateException: I/O Error: Connection reset by peer: socket write error -
i connect mssql server 2008 sp3 jtds 1.3.1.i create 3 preparedstatements in 3 seperate threads add querys them. when execute preparedstatements exception:
java.sql.batchupdateexception: i/o error: connection reset peer: socket write error @ net.sourceforge.jtds.jdbc.jtdsstatement.executebatch(jtdsstatement.java:1091) @ de.mvn.gotdb_mvn.main.main(main.java:181)
please me solve problem. code:
public static void main(string[] args) throws sqlexception { final importer importer = new importer(); importer.openconnection(); final connection connection = importer.getcon(); importer.createnewtables(); statementpreparer test_falldata = new statementpreparer(connection.preparestatement(q1)) { @override public void dorun() { try { preparedstatement falldata_stmt = getstmt(); // | string[] line = this.getline(); falldata_stmt.setint(1, integer.parseint(line[0].trim())); //fallnr falldata_stmt.setstring(2, line[1]); //drg falldata_stmt.setstring(3, line[18]); //mdc falldata_stmt.setstring(4, line[19]); //pccl falldata_stmt.setstring(5, line[20]); falldata_stmt.addbatch(); } catch (exception e) { e.printstacktrace(); } } }; statementpreparer test_diagnosen = new statementpreparer(connection.preparestatement(q2)) { @override public void dorun() { try { preparedstatement diagnosen_stmt = getstmt(); string[] line = this.getline(); string[] diagnose_only = line[13].split("~"); (int = 0; < diagnose_only.length; i++) { int index_of_roof = diagnose_only[i].indexof("^"); //fallnr diagnosen_stmt.setstring(1, line[1]); //code diagnosen_stmt.setstring(2, diagnose_only[i].substring(0, index_of_roof)); //used int diagnosen_stmt.setint(3, integer.parseint(diagnose_only[i].substring(index_of_roof + 1, index_of_roof + 2))); //hdx/ndx int if (i == 1) { diagnosen_stmt.setint(4, 1); } else { diagnosen_stmt.setint(4, 0); } diagnosen_stmt.addbatch(); } } catch (exception e) { e.printstacktrace(); } } }; statementpreparer test_proceduren = new statementpreparer(connection.preparestatement(q3)) { @override public void dorun() { try { preparedstatement proceduren_stmt = getstmt(); string[] line = this.getline(); string[] procedure_only = line[14].split("~"); (string single_proce : procedure_only) { if (!single_proce.isempty()) { int index_of_amp = single_proce.indexof("&"); //fallnr proceduren_stmt.setstring(1, line[1]); //code proceduren_stmt.setstring(2, single_proce.substring(0, index_of_amp)); //lokalisation if (single_proce.lastindexof("&") == index_of_amp + 1) { proceduren_stmt.setstring(4, ""); //datum proceduren_stmt.setdate(3, getproceduredate(single_proce, proce_no_lok)); } else { string lokalisation = single_proce.substring(index_of_amp + 1, single_proce.lastindexof("&")); proceduren_stmt.setstring(4, lokalisation); //datum proceduren_stmt.setdate(3, getproceduredate(single_proce, proce_with_lok)); } //used proceduren_stmt.setint(5, integer.parseint(single_proce.substring(single_proce.indexof("^") + 1, single_proce.indexof("^") + 2))); proceduren_stmt.addbatch(); } } } catch (exception e) { e.printstacktrace(); } } }; preparerlistener listener = new preparerlistener(); test_falldata.addlistener(listener); test_diagnosen.addlistener(listener); test_proceduren.addlistener(listener); try { (string nextline = importer.getnextline(); nextline != null; nextline = importer.getnextline()) { test_falldata.setline(nextline); test_diagnosen.setline(nextline); test_proceduren.setline(nextline); test_falldata.resumethread(); test_diagnosen.resumethread(); test_proceduren.resumethread(); } if(!connection.isclosed()) { test_falldata.getstmt().executebatch(); if(connection.isclosed()) { system.out.print("closed"); system.exit(-10); } test_diagnosen.getstmt().executebatch();// exception test_proceduren.getstmt().executebatch(); }else { system.out.println("connection has closed"); } } catch (exception e) { e.printstacktrace(); } }
the openconnection method:
public void openconnection(string p_propertys) { try{ class.forname("net.sourceforge.jtds.jdbc.driver"); string url="jdbc:jtds:sqlserver://lb236/checkpointdb;logintimeout=30;sockettimeout=1800"; string user ="jadmin"; string pw="jadmin123"; con = drivermanager.getconnection(url,user,pw); }catch(exception e){e.printstacktrace();} }
Comments
Post a Comment