CFC中的通信故障链接与查询

时间:2011-07-13 15:30:57

标签: mysql coldfusion cfc

我有一个CFC,可以在招聘网站上处理“与我们联系”的表格。 cfc旨在处理网站上的几种不同形式;一个通用的“联系我们”表格和另一个“我对这份工作感兴趣”表格。

当CFC获取数据,并且作业发布的ID#在参数中时,CFC执行快速查询并获取作业发布信息,将其包含在电子邮件中并向HR部门和用户发送发送有关职位发布信息以及用户联系信息的电子邮件。

如果未检测到ID,CFC只会通过电子邮件向用户发送确认电子邮件,并将联系信息发送给人力资源部门。

处理通用(非ID)表单时,一切正常。但是,当需要处理包含快速查询的表单时,我会收到错误:

Communications link failure The last packet successfully received from the server was 61,380 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago.

为什么填充我的页面的查询工作正常,但是这个CFC会在其中引发查询错误?

我们在共享托管环境中运行带有MYSQL的CF9。

CFC ......

<cfif len(local.data.job_id)>
        <cftry>
        <cfquery name="qJobsforEmail" datasource="#application.datasource#" username="#application.username#" password="#application.password#">
            SELECT * FROM #local.data.table# WHERE #local.data.table#.#local.data.column#= <cfqueryparam value="#local.data.job_id#" cfsqltype="cf_sql_numeric">
        </cfquery>
        <cfcatch type="any">
            <cfmail to="my@email.com" from="server@host.com" subject="Error processing query" type="html">
            <h3>There was an error processing the query</h3>
            <p><cfoutput>#cfcatch.Detail#</cfoutput></p>
            <p><cfoutput>#cfcatch.NativeErrorCode#</cfoutput></p>
            <p><cfoutput>#cfcatch.SQLState#</cfoutput></p>
            <p><cfoutput>#cfcatch.Sql#</cfoutput></p>
            <p><cfoutput>#cfcatch.queryError#</cfoutput></p>
            <p><cfoutput>#cfcatch.where#</cfoutput></p>
            <p><cfoutput>#cfcatch.type#</cfoutput></p>
            <cfdump var="#local#">
            </cfmail>
            <cfset local.response["error"] = 'true'>
            <cfset local.response["message"] = 'Error message to the page goes here...'>
            <cfreturn local.response>
            <cfabort>
        </cfcatch>
        </cftry>
        <cftry>
        <cfmail to="#local.data.email#" bcc="hr@theclient.com"  from="server@host.com" subject="Thank you for contacting us" type="html">
        <h2>We&rsquo;re glad you contacted us.</h2>
        <p>Warm and fuzzy thank you message here</p>
        <p>We received the following information on <cfoutput>#DateFormat(Now())#</cfoutput>, <cfoutput>#TimeFormat(Now())#</cfoutput>: </p>
        <p>First Name: <cfoutput>#local.data.first_name#</cfoutput></p>
        <p>Last Name: <cfoutput>#local.data.last_name#</cfoutput></p>
        <cfif len(local.data.suffix)>
            <p>Suffix: <cfoutput>#local.data.suffix#</cfoutput></p>
        </cfif>
        <p>Specialty: <cfoutput>#local.data.specialty#</cfoutput></p>
        <p>Email Address: <cfoutput>#local.data.email#</cfoutput></p>
        <p>Phone: <cfoutput>#local.data.phone#</cfoutput></p>
        <p> Current City and State: <cfoutput>#local.data.city#</cfoutput></p>
        <cfif len(local.data.comments)>
            <p>Message: <cfoutput>#local.data.comments#</cfoutput></p>
        </cfif>
        <p style="border-top:thin dotted black;padding-top:20px;font-weight:bold;">This is the position you&rsquo;re inquiring about:</p>
        <p style="font-weight:bold;"><cfoutput>#qJobsforEmail.title#</cfoutput></p>
        <p style="padding-bottom:20px;"><cfoutput>#qJobsforEmail.description#</cfoutput></p>
        <p>Our Recruiter will review this information and get in touch with you as soon as possible. Please make sure your email or phone number listed above is correct.</p>
        <p>Thanks again for contacting us. We look forward to speaking with you soon.</p>
        </cfmail>
        <cfcatch type="any">
            <cfmail to="my@email.com" from="server@host.com" subject="Error processing email" type="html">
            <h3>There was an error processing the email at</h3>
            <cfdump var="#cfcatch.Detail#">
            <cfdump var="#local#">
            </cfmail>
            <cfset local.response["error"] = 'true'>
            <cfset local.response["message"] = 'message to return to the page...'>
            <cfreturn local.response>
            <cfabort>
        </cfcatch>
        </cftry>

    <cfelse>

<!-- regular ol form process goes here -->
</cfif>

1 个答案:

答案 0 :(得分:5)

我不认为这是您的代码的问题,而是您的托管公司应该考虑的问题。

可能发生的事情是ColdFusion正在尝试从其连接池重用数据库连接,但通信链路已损坏。您通常可以通过向数据源设置添加验证查询(例如SELECT 1)或禁用连接池来解决此问题。

我必须相信Steven Erat对这一特定问题的了解:http://forums.adobe.com/message/3396333#3396333