Loading

MuleSoft Anypoint Database Connector Error 'Could not find prepared statement with handle 1'

Publiceringsdatum: Dec 30, 2025
Beskrivning

From your Mule API, you are connecting to an MS SQL Server DB and using a Pooling Profile in your DB connector configuration, and intermittently observe the error "Could not find prepared statement with handle 1." as demonstrated in these sample logs:

Route 0:
********************************************************************************
Message : 'until-successful' retries exhausted
Element : CRGUpdateDeliveryStatusPending/processors/1 @ allegis-prod-crgdatapoller:subflows/db-calls.xml:96 (Until Successful)
Element DSL : (None)
Error type : (None)
Caused by : DB:BAD_SQL_SYNTAX: Could not find prepared statement with handle 1.
FlowStack : (None)
Payload Type : org.mule.runtime.core.api.util.CaseInsensitiveHashMap
--------------------------------------------------------------------------------
Root Exception stack trace:
com.microsoft.sqlserver.jdbc.SQLServerException: Could not find prepared statement with handle 1.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:265)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1695)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:620)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:539)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7685)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:4048)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:272)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:246)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:484)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:1502)
Lösning

 When the AnyPoint Database Connector throws the error 'Could not find prepared statement with handle 1', the cause can be from having a Pooling profile and PreparedStatementCache configured.

SOLUTION:

It has been observed that disabling the PreparedStatementCache (i.e, setting it to 0) resolves the issue. As usual, kindly make sure your application is performance tested properly when you make changes in your Pooling profile. 

Disclaimer: This article involves products and technologies which do not form part of the MuleSoft product set. Technical assistance for such products is limited to this article. This solution provides a suggestion that should be considered in conjunction with your specific use case and requirements and does not represent a complete solution for all circumstances.

Knowledge-artikelnummer

001123674

 
Laddar
Salesforce Help | Article