Could not find prepared statement with handle xx

  • Hi

    I am having a randomly recurring problem where I get the error message:

    "Could not find prepared statement with handle xx"

    where xx is a number.

    The problem occurs randomly and can be solved just by forcing a dummy change in my SQL (such as a new line break) and re-running it, with no SQL changes.

    Does anyone have any ideas on what could cause this?

    Thanks!

  • Is it the full error message?

    Do you use JAVA?

    Does your server have a limit in concurrent users?

    The following link may help a little bit.

    http://developer.atlassian.com/jira/browse/SQL-30

  • It a Java app, although that is hidden from my interface, where I am writing just the SQL and submitting it. The full message I get is:

    sql: java.sql.SQLException: Could not find prepared statement with handle 1.

    ...but I don't get the java stack dump (maybe its hidden from my application).

    Not sure about the concurrent server user limit - it should be high.

    What is actually happening on SQL Server when I use (or at least the Java ODBC driver uses) prepared statements?

    I would guess that on first execution, the statement is prepared and executed. On subsequent executions, a handle is used to point to the prepared statement, and therefore only the execution actually takes place (instead of prepare & execute). Could anybody confirm that is how it should work?

    Thanks!

  • You can cooperate with your DBA to check the version of your SQL Server, and its setting of max connections.

  • We have SQL Server 2000 and maxActive is set to 20 for our connection.

  • Check out microsoft ADO.NET 2.0 hotfix in this link, it appears to be related to your problem:

    http://support.microsoft.com/kb/913765

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply