Fatal error encountered during command execution

简介: 错误信息:Fatal error encountered during command execution.(命令执行过程中遇到的致命错误。)出现这种问题有可能是两种情况:1.查询结果包含海量数据。

错误信息:

Fatal error encountered during command execution.(命令执行过程中遇到的致命错误。)

出现这种问题有可能是两种情况:

1.查询结果包含海量数据。长时间检索无响应。这种情况,需要优化SQL,尽量减少数据输出量。

2.表结构损坏。可以通过 CHECK TABLE REPAIR TABLE 语句进行检测或修复。

初步判断是第一种情况,有两种解决方案:优化sql语句,但是如果数据量确实大,而且对程序性能要求不高的情况下,有一种简单的解决方法就是设置CommandTimeOut属性。

 MySqlCommand optcom = new MySqlCommand(strOpt, mysqlcon, trans);
                optcom.CommandTimeout = 0;

CommandTimeout 属性

指示执行命令期间在终止尝试和产生错误之前需等待的时间。

设置和返回值

设置或返回 Long 值,该值指示等待命令执行的秒数。默认值为 30。

说明

用 Connection 对象或 Command 对象的 CommandTimeout 属性来允许因网络拥挤或服务器负载过重产生的延迟而取消 Execute 方法调用。如果在 CommandTimeout 属性设置的时间间隔内未执行完命令,将产生错误,并且 ADO 取消该命令。如果将属性设置为零,ADO 将一直等待到命令执行完毕。请确保正在为其编写代码的提供者和数据源支持 CommandTimeout 功能。

Connection 对象的 ConnectionTimeout 设置对同一 Connection 中 Command 对象上的 CommandTimeout 设置没有影响,即 Command 对象的 CommandTimeout 属性不继承 Connection 对象的ConnectionTimeout 值。

在 Connection 对象上,打开 Connection 后,ConnectionTimeout 属性将保持为读/写。

ConnectionTimeout 属性

指示在终止尝试和产生错误前建立连接期间所等待的时间。

设置和返回值

设置或返回指示等待连接打开的时间的长整型值(单位为秒)。默认值为 15。

说明

如果由于网络拥塞或服务器负载过重导致的延迟使得必须放弃连接尝试时,请使用 Connection 对象的 ConnectionTimeout 属性。如果打开连接前所经过的时间超过 ConnectionTimeout 属性上设置的时间,将产生错误,并且 ADO 将取消该尝试。如果将该属性设置为零,ADO 将无限等待直到连接打开。请确认正在对其编写代码的提供者会支持 ConnectionTimeout 功能。

连接关闭时 ConnectionTimeout 属性为读/写,而打开时其属性为只读。

目录
相关文章
|
6月前
|
SQL Java 数据库连接
sql injection violation, syntax error: syntax error, error in :‘**‘expect IDENTIFIER, actual IDENTIF
sql injection violation, syntax error: syntax error, error in :‘**‘expect IDENTIFIER, actual IDENTIF
118 0
|
8月前
|
Java Maven Android开发
成功解决FATAL ERROR in native method: JDWP on getting class status, jvmtiError=JVMTI_ERROR_WRONG_PHASE
成功解决FATAL ERROR in native method: JDWP on getting class status, jvmtiError=JVMTI_ERROR_WRONG_PHASE
排错-Error--memory violation Exception ACCESS_VIOLATION received解决方
排错-Error--memory violation Exception ACCESS_VIOLATION received解决方
168 0
SignTool Error: An error occurred while attempting/Error information: “SignerTimeStamp() failed.“
SignTool Error: An error occurred while attempting/Error information: “SignerTimeStamp() failed.“
109 0
Execution failed for task :Test:lintVitalRelease/Lint found fatal errors while assembling a release
Execution failed for task :Test:lintVitalRelease/Lint found fatal errors while assembling a release
98 0
|
Java
Error: A JNI error has occurred, please check your installation and try again
Error: A JNI error has occurred, please check your installation and try again
153 0
|
Java 应用服务中间件
Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
|
资源调度 JavaScript
The futex facility returned an unexpected error code
The futex facility returned an unexpected error code
601 0
|
Go iOS开发
The operation couldn’t be completed. Unable to log in with account 'myappleid'. An unexpected failure occurred while logging in (Underlying error code 1100).解决方法
The operation couldn’t be completed. Unable to log in with account 'myappleid'. An unexpected failure occurred while logging in (Underlying error code 1100).解决方法
351 0