This topic describes how to enable PrepareStatement for a client in different programming languages.

In most databases, SQL statements can be preprocessed on the server to improve database performance. AnalyticDB for MySQL databases deliver high performance without preprocessing SQL statements on the server because these databases have the plan cache feature and strong query capabilities and computing power.

We recommend that you do not preprocess SQL statements on the server for AnalyticDB for MySQL databases. In most programming languages, you can enable PrepareStatement for a client to prepare statements or interpolate parameters on the client.

MySQL Connector/J (JDBC) driver

To enable PrepareStatement for the MySQL Connector/J (JDBC) driver, you must set the useServerPrepStmts parameter to false. For more information, see Configuration Properties for Connector/J.

Note Do not set the useCursorFetch parameter to true. Otherwise, the useServerPrepStmts parameter configuration becomes ineffective and PrepareStatement cannot be enabled.

MariaDB Connector/J

To enable PrepareStatement for MariaDB Connector/J, you must set the useServerPrepStmts parameter to false. For more information, see About MariaDB Connector/J.

Go MySQL driver

To enable PrepareStatement for the Go MySQL driver, you must set the interpolateParams parameter to true. For more information, see go-sql-driver.

PDO

To enable PrepareStatement for PDO, you must set the PDO::ATTR_EMULATE_PREPARES parameter to TRUE. For more information, see PDO::setAttribute.