Java自学者论坛

 找回密码
 立即注册

手机号码,快捷登录

恭喜Java自学者论坛(https://www.javazxz.com)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,会员资料板块,购买链接:点击进入购买VIP会员

JAVA高级面试进阶训练营视频教程

Java架构师系统进阶VIP课程

分布式高可用全栈开发微服务教程Go语言视频零基础入门到精通Java架构师3期(课件+源码)
Java开发全终端实战租房项目视频教程SpringBoot2.X入门到高级使用教程大数据培训第六期全套视频教程深度学习(CNN RNN GAN)算法原理Java亿级流量电商系统视频教程
互联网架构师视频教程年薪50万Spark2.0从入门到精通年薪50万!人工智能学习路线教程年薪50万大数据入门到精通学习路线年薪50万机器学习入门到精通教程
仿小米商城类app和小程序视频教程深度学习数据分析基础到实战最新黑马javaEE2.1就业课程从 0到JVM实战高手教程MySQL入门到精通教程
查看: 766|回复: 0

SQL超时解决方法

[复制链接]
  • TA的每日心情
    奋斗
    5 天前
  • 签到天数: 802 天

    [LV.10]以坛为家III

    2053

    主题

    2111

    帖子

    72万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    726006
    发表于 2021-6-21 04:50:33 | 显示全部楼层 |阅读模式

    SQL超时解决方法

    关键字: sql超时解决方法

    在服务器端处理一些耗时很长的处理的时候,有时会遇到超时的情况。在无需发送响应到 IE 的时候,此问题无关大雅。但在需要处理完后发送响应的情况下,往往导致浏览器超时无响应。 
    由于生成统计表格需要很长时间,到下载的时候浏览器已超时。 
    解决:在统计时,同时打开一个请求下载的页面,这个页面会定时刷新,重复请求。在数据准备好的情况下,进行下载;未准备好的情况下,显示提示语。 
    总结:对于这种长时间的会导致浏览器超时的处理,可以先在服务器方处理完,然后用异步的方式(浏览器重复询问,异步通知等)方式来取得响应。 

    SQL超时解决方法 
    影响服务器产生超时的设置大致有: 
    1. Server.scrīpt Timeout
    2. Connection对象的CommandTimeOut属性, 
    3. Command对象的CommandTimeOut属性, 
    4. IE浏览器的设置. 

    Server.scrīptTimeout,默认值是90秒. 
    要增大它,在你的asp文件中加一句,如下: 
    Server.scrīptTimeout=999, 
    将页面超时设为999秒. 

    最初我只设置Server.scrīptTimeout
    但仍会出现timeout错误,无论它的值设成都多大. 
    后在社区里看到一帖子,提到commandTimeout属性, 
    于是查看Option Pack文档,果然还有其他的timeout

    Connection对象和Command对象都有个CommandTimeOut属性, 
    默认是30秒,如果你有一个耗时的查询或数据处理, 
    很容易就超时了.要增大它,也很容易,创建对象后, 
    设置它的属性,如下: 
    con.CommandTimeOut = 999, 
    设为999秒,其中con是一Connection对象. 
    如设为零,将无限等待,没有这一timeout限制. 

    Command对象不会继承Connection的这一属性, 
    所以对可能超时的Command也要单独设置CommandTimeout属性. 

    最后IE也有个超时设置,5分钟从服务器得不到数据,也超时. 
    这种情况可能很少碰到, 
    但当我把一10多万查询的结果保存为mdb文件时, 
    就遇到了.(至于保存的方法,请参看精华区中的一篇帖子.) 

    如何设置浏览器超时时间 
    setTimeout('window.close()',100) 其中100为毫秒 。在onload上面加上上面这段代码,应该可以了 
    在HTML HEAD 中加 
    <meta http-equiv="REFRESH" content="900;url=TimeOut?OpenForm"> 
    900是15分钟时间。 
    TimeOut?OpenForm 是超时转到的页面 

    链接超时问题的浏览器端解决方案 
    How to change the default Keep-Alive Time-Out Value in IE 
    View products that this article applies to. 
    Warning If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk. 

    You may have to increase the default time-out value for persistent HTTP connections in Internet Explorer if you are using a Web program that must communicate with Internet Explorer over the same TCP/IP socket after one idle minute. To change the default time-out value for persistent HTTP connections in Internet Explorer, add a DWORD value that is named KeepAliveTimeout to the following registry key, and then set its value data to the time (in milliseconds) that you want Internet Explorer to wait before resetting an idle connection: 
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings 
    To do this, follow these steps: 1. Click Start, click Run, type regedit, and then click OK. 
    2. Locate and then click the following key in the registry: 
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings 
    3. On the Edit menu, point to New, and then click DWORD Value. 
    4. Type KeepAliveTimeout, and then press ENTER. 
    5. On the Edit menu, click Modify. 
    6. Type the appropriate time-out value (in milliseconds), and then click OK. For example, to set the time-out value to two minutes, type 120000. 
    7. Restart Internet Explorer. 
    If you set the KeepAliveTimeout value to less than 60,000 (one minute), you may have problems communicating with Web servers that require persistent HTTP connections. For example, you may receive a "Page cannot be displayed" error message. 

    If you must have a KeepAliveTimeout value higher than 120000 (two minutes), you must create an additional registry key and set its value equal to the KeepAliveTimeout value that you want. The additional registry key is ServerInfoTimeout. It is a DWORD with a value (in milliseconds) and in the same location as KeepAliveTimeout

    For example, to use a three-minute KeepAliveTimeout value, you must create the following registry keys: 
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings 

    KeepAliveTimeout DWORD value 180000 (in milliseconds) 
    ServerInfoTimeout DWORD value 180000 (in milliseconds) 
    By default, HTTP 1.1 is enabled in Internet Explorer except when you establish an HTTP connection through a proxy server. When HTTP 1.1 is enabled, HTTP connections remain open (or persistent) by default until the connection is idle for one minute or until the value that is specified by the KeepAliveTimeout value in the registry is reached. You can modify HTTP 1.1 settings in Internet Explorer by using the Advanced tab in the Internet Options dialog box.
    哎...今天够累的,签到来了1...
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|小黑屋|Java自学者论坛 ( 声明:本站文章及资料整理自互联网,用于Java自学者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

    GMT+8, 2024-11-16 02:28 , Processed in 0.060072 second(s), 29 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表