• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Could not find prepared statement with handle 1.

New Here ,
Aug 02, 2012 Aug 02, 2012

Copy link to clipboard

Copied

[Macromedia][SQLServer JDBC Driver][SQLServer]Could not find prepared statement with handle 1.

I'm getting this error message in what appear to be random ways. The first time I look at a page I might not get it, but the second time I might. I discovered that removing a cfqueryparam tag worked, but that is not really a safe solution. I checked that the cf_sql_type matched the database field, and in one case changed a cf_sql_varchar to a cf_sql_char so it would match a SQL Server nchar(10) field. But still these errors. Any ideas? I've not had any luck Googling this.

I should add that I'm running Coldfusion 9 as a Tomcat webapp on a Linux server. The database is SQL Server 2005, I think.

TOPICS
Database access

Views

8.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 02, 2012 Aug 02, 2012

Copy link to clipboard

Copied

hard to say without looking at your code.  However, since you mentioned cfqueryparam, maybe you are sending an empty string without specifying null="true" or something like that.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 02, 2012 Aug 02, 2012

Copy link to clipboard

Copied

It's possible there's something in my logic that is doing that ... but it was happening to one query that was referring to a value set at the top of the file (via cfqueryparam) and when I removed that cfqueryparam it started to happen to a different query. And, I should add, the queries in question were working fine for years before on a coldfusion MX server. This is a new page in the app, but the queries are all being included from old working template files.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 02, 2012 Aug 02, 2012

Copy link to clipboard

Copied

Here's the one that is breaking now:

<cfquery name="CheckCredentials" datasource="#application.crossreg_dsn#">

                                        SELECT [name_first]+' '+[name_last] as name

                                                    ,p.[uni]

                                                    ,p.email

                                                    ,p.role_id

                                                     ,r.role_name

                                                  ,p.external_program_id

                                          FROM [CrossReg].[dbo].[People] p

                                           INNER JOIN dbo.Roles r on r.role_id = p.role_id

                                          WHERE uni = <cfqueryparam cfsqltype="cf_sql_char" value="#Session.username#">

</cfquery>

Session.username is being returned from a CAS authentication system. I've never had troubles with it before.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 02, 2012 Aug 02, 2012

Copy link to clipboard

Copied

Restarting tomcat seemed to clear it up. Still, if anyone knows what that error message means ...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 10, 2012 Aug 10, 2012

Copy link to clipboard

Copied

It's happening again. And again, restarting tomcat fixed it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 14, 2012 Sep 14, 2012

Copy link to clipboard

Copied

Just to let you know that you are not crazy, I have had the same issue in CF9 (standard Windows install) with SQL Server 2005.  I also have not found a solution, and in all cases I have had to remove the <cfqueryparam> tag.  Restarting CF (or, alternately, restarting SQL Server) solves the problem temporarily, but after a few days it always comes back.

If you come across a solution, please update this post!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 08, 2012 Oct 08, 2012

Copy link to clipboard

Copied

I had the same problem due to a query that errored then all subsequent queries would error as well with this error message

I found this blog post regarding this issue:

http://www.sstwebworks.com/entry.cfm?entry_id=AAF6E42A-F14A-4716-88B98BD231596CA6

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 29, 2015 Jun 29, 2015

Copy link to clipboard

Copied

LATEST

I know this is a very old post but maybe this will help someone still experiencing this. I too was having the same issue and as a previous post suggested, it is related to the driver. I am going to assume that the OP is using the built in Microsoft SQL Server driver for the data source. Switching to the more perfomant jTDS driver eliminated these random errors.

P.S. We've since upgraded to CF11 and the issue still persists when using the SQL Server driver.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation