MySQL的例外

编程入门 行业动态 更新时间:2024-10-24 13:23:44
本文介绍了MySQL的例外 - 在遇到数据读取致命错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的工作,从表中抓取大量记录一个C#控制台程序,运行它们通过医疗石斑鱼,然后更新每个记录。它使用的MySQL Connector / NET 5.2.7。它的工作方式是,我使用SQL_BUFFER_RESULT避免锁在一个时间(即20000行)获取数据块。每个记录是通过运行石斑鱼,然后单独的更新查询是在一个记录完成。有使用两个连接,一个读连接和写连接。

I am working on a C# console program that grabs large numbers of records from a table, runs them through a medical grouper, and then updates each of the records. It uses MySQL Connector/NET 5.2.7. The way it works is that I grab chunks of data at a time (i.e. 20,000 rows) using SQL_BUFFER_RESULT to avoid locks. Each record is run through the grouper, and then an individual update query is done on that one record. There are two connections used, a read connection and a write connection.

所以,随着程序的执行,并从读查询遍历记录,它的使用result.Read()这样做,其中的结果是了MySqlDataReader。该result.Read调用是哪里有异常。它发生随机(而不是在同一记录或其它)。一旦在第一个记录遇到的,它也遇到每个后续读呼吁数据读取器。我试过很多东西,寻找高和低相关问题的其他人了。任何有识之士将是巨大的,并随时让我知道还有什么其他的信息,我需要提供。

So as the program executes and it loops through records from the read query, its using result.Read() to do so, where result is a MySqlDataReader. The result.Read call is where there exception is thrown. It happens randomly (not on the same record or anything). Once it is encountered on the first record, it is also encountered on every subsequent read call for the data reader. I've tried many things and searched high and low for related problems others have had. Any insight would be great, and feel free to let me know what other info I need to provide.

推荐答案

connection.Open之间();和command.ExecuteNonQuery();我只是说两行是这样的:

Between connection.Open(); and command.ExecuteNonQuery(); I just added two lines like this:

connection.Open(); MySqlCommand cmd = new MySqlCommand("set net_write_timeout=99999; set net_read_timeout=99999", connection); // Setting tiimeout on mysqlServer cmd.ExecuteNonQuery(); int numOfRecordsUpdated = command.ExecuteNonQuery();

问题修正:)

Problem Fixed :)

更多推荐

MySQL的例外

本文发布于:2023-11-15 19:19:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1597242.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:MySQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!