java - Java,JDBC被多线程搞砸了?
问题描述
我正在使用 Java、Eclipse IDE 中的 JDBC 从数据库中获取约 20'000 行。
我逐步检查结果集(按 id 排序)。每行都包含有关其先前和后续“标识符”(行的唯一字符串)的信息。因此,对于每一行,我都会检查链条是否损坏,无论出于何种原因。
我下面的方法有效,不要引用我的话,但它似乎对前 10'000 人比对以下人更好。19'999 个条目的错误配额为 335。我亲眼检查了报告的错误是否符合实际,但肯定不是,至少有1个错误。
我错过了什么重要的事情吗?为什么会这样?它几乎看起来像是并行化、多线程等的结果?
int i = 0;
String actualprevious = "", previous = "", next = "";
boolean first = true; // we can't check if the first is in line because it is the first
int errors = 0;
while (rs.next())
{
if (i%10000==0) { System.out.println("Checked "+(i/10000)+" myriads."); } // inform
String current = rs.getString("identifier");
if (!current.equals(next)) { System.out.println("Current is: "+current); System.out.println("Expected "+next+" to be next, but "+current+" is."); errors++; } // inform
// ignore: Document doc = Jsoup.parse(rs.getString("source"));
next = rs.getString("next");
if (next==null) { System.out.println("There is no next listed in row "+current+"."); errors++; } // inform
previous = rs.getString("previous");
if (!first && !actualprevious.equals(previous)) { System.out.println("Expected "+actualprevious+" to be listed as previous, but "+previous+" was in document "+current+"."); errors++; } // inform
actualprevious = current;
i++;
first = false;
}
解决方案
推荐阅读
- javascript - 图层滑块导航在wordpress中的IOS上不起作用
- c - 从文件中捕获用逗号分隔的带引号的字符串
- jsonschema - RAML:对具有不同属性的 GET 和 POST 使用相同的数据类型
- java - 如何在spring web 4.3中持久化http请求销毁对象
- .htaccess - 重写 url - Rediriger sans index.php
- google-apps-script - 如何使用谷歌脚本在谷歌文档中创建一个超链接数组(或一个长字符串)
- jquery-ui - 在 JQuery UI 日期选择器中将一周的开始日期设置为星期五
- sql - sql中的内联和外联约束有什么区别吗?
- java - android.view.InflateException:二进制 XML 文件第 27 行:android.support.design.widget.TextInputEditText 无法转换为 android.view.ViewGroup
- c# - 当我在不使用 sqldependency 的情况下更新表数据时,如何使用存储过程获取 c# 方法的调用触发器