All Products
Search
Document Center

AnalyticDB:Enable client-side PrepareStatement in different programming languages

Last Updated:Mar 30, 2026

AnalyticDB for MySQL uses plan cache and strong query capabilities to deliver high performance without server-side SQL preprocessing. To avoid unnecessary overhead, disable server-side prepared statements and enable client-side parameter interpolation instead.

The following sections describe the configuration for each supported driver.

MySQL Connector/J (JDBC) driver

Set useServerPrepStmts to false in your JDBC connection URL or properties. For the full list of configuration options, see Configuration Properties for Connector/J.

Parameter Recommended value
useServerPrepStmts false

Example connection URL:

jdbc:mysql://<host>:<port>/<database>?useServerPrepStmts=false
Note

Do not set useCursorFetch to true. If useCursorFetch is enabled, it overrides the useServerPrepStmts setting and prevents client-side prepared statements from taking effect.

MariaDB Connector/J

Set useServerPrepStmts to false in your MariaDB connection URL or properties. For more information, see About MariaDB Connector/J.

Parameter Recommended value
useServerPrepStmts false

Example connection URL:

jdbc:mariadb://<host>:<port>/<database>?useServerPrepStmts=false

Go MySQL driver

Set interpolateParams to true in your DSN to enable client-side parameter interpolation. For more information, see go-sql-driver.

Parameter Recommended value
interpolateParams true

Example DSN:

<user>:<password>@tcp(<host>:<port>)/<database>?interpolateParams=true

PDO

Set PDO::ATTR_EMULATE_PREPARES to TRUE when creating your PDO connection. For more information, see PDO::setAttribute.

Parameter Recommended value
PDO::ATTR_EMULATE_PREPARES TRUE

Example:

$pdo = new PDO($dsn, $user, $password);
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, TRUE);

For setup instructions, see the PDO section in the PHP connection guide.