This class emulates a backend PostgreSQL connection. Statements are buffered in memory until a
flush/sync is received. This makes it possible to batch multiple statements together before
sending these to Cloud Spanner. This class also keeps track of the transaction status of the
connection.
Buffers the given statement for execution on the backend connection when the next flush/sync
message is received. The returned future will contain the result of the statement when
execution has finished.
Buffers the given COPY operation for execution on the backend connection when the next
flush/sync message is received. The returned future will contain the result of the COPY
operation when execution has finished.
Sets the initial value of a pg_settings setting for this connection. This method should only be
called during startup with values that come from the connection request.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Class BackendConnection (0.27.1)\n\nVersion latestkeyboard_arrow_down\n\n- [0.27.1 (latest)](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.27.0](/java/docs/reference/pgadapter/0.27.0/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.26.0](/java/docs/reference/pgadapter/0.26.0/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.25.0](/java/docs/reference/pgadapter/0.25.0/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.24.0](/java/docs/reference/pgadapter/0.24.0/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.23.1](/java/docs/reference/pgadapter/0.23.1/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.22.1](/java/docs/reference/pgadapter/0.22.1/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.21.0](/java/docs/reference/pgadapter/0.21.0/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.20.0](/java/docs/reference/pgadapter/0.20.0/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.19.1](/java/docs/reference/pgadapter/0.19.1/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.18.4](/java/docs/reference/pgadapter/0.18.4/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.17.0](/java/docs/reference/pgadapter/0.17.0/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.16.0](/java/docs/reference/pgadapter/0.16.0/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.15.0](/java/docs/reference/pgadapter/0.15.0/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.14.1](/java/docs/reference/pgadapter/0.14.1/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.9.0](/java/docs/reference/pgadapter/0.9.0/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.8.0](/java/docs/reference/pgadapter/0.8.0/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.7.0](/java/docs/reference/pgadapter/0.7.0/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.6.1](/java/docs/reference/pgadapter/0.6.1/com.google.cloud.spanner.pgadapter.statements.BackendConnection)\n- [0.5.1](/java/docs/reference/pgadapter/0.5.1/com.google.cloud.spanner.pgadapter.statements.BackendConnection) \n\n public class BackendConnection\n\nThis class emulates a backend PostgreSQL connection. Statements are buffered in memory until a\nflush/sync is received. This makes it possible to batch multiple statements together before\nsending these to Cloud Spanner. This class also keeps track of the transaction status of the\nconnection. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e BackendConnection \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nStatic Fields\n-------------\n\n### MAX_PARTITIONS\n\n public static final int MAX_PARTITIONS\n\n### TRANSACTION_ABORTED_ERROR\n\n public static final String TRANSACTION_ABORTED_ERROR\n\nMethods\n-------\n\n### analyze(String command, AbstractStatementParser.ParsedStatement parsedStatement, Statement statement)\n\n public ListenableFuture\u003cStatementResult\u003e analyze(String command, AbstractStatementParser.ParsedStatement parsedStatement, Statement statement)\n\n### execute(ReleaseStatement releaseStatement)\n\n public Future\u003cStatementResult\u003e execute(ReleaseStatement releaseStatement)\n\n### execute(RollbackToStatement rollbackToStatement)\n\n public Future\u003cStatementResult\u003e execute(RollbackToStatement rollbackToStatement)\n\n### execute(SavepointStatement savepointStatement)\n\n public Future\u003cStatementResult\u003e execute(SavepointStatement savepointStatement)\n\n### execute(TruncateStatement truncateStatement)\n\n public Future\u003cStatementResult\u003e execute(TruncateStatement truncateStatement)\n\n### execute(VacuumStatement vacuumStatement)\n\n public Future\u003cStatementResult\u003e execute(VacuumStatement vacuumStatement)\n\n### execute(String command, AbstractStatementParser.ParsedStatement parsedStatement, Statement statement, Function\\\u003cStatement,Statement\\\u003e statementBinder)\n\n public Future\u003cStatementResult\u003e execute(String command, AbstractStatementParser.ParsedStatement parsedStatement, Statement statement, Function\u003cStatement,Statement\u003e statementBinder)\n\nBuffers the given statement for execution on the backend connection when the next flush/sync\nmessage is received. The returned future will contain the result of the statement when\nexecution has finished.\n\n### executeCopy(AbstractStatementParser.ParsedStatement parsedStatement, Statement statement, CopyDataReceiver copyDataReceiver, MutationWriter mutationWriter, ExecutorService executor)\n\n public Future\u003cStatementResult\u003e executeCopy(AbstractStatementParser.ParsedStatement parsedStatement, Statement statement, CopyDataReceiver copyDataReceiver, MutationWriter mutationWriter, ExecutorService executor)\n\nBuffers the given COPY operation for execution on the backend connection when the next\nflush/sync message is received. The returned future will contain the result of the COPY\noperation when execution has finished.\n\n### executeCopyOut(AbstractStatementParser.ParsedStatement parsedStatement, Statement statement)\n\n public Future\u003cStatementResult\u003e executeCopyOut(AbstractStatementParser.ParsedStatement parsedStatement, Statement statement)\n\n### getConnectionState()\n\n public BackendConnection.ConnectionState getConnectionState()\n\nReturns the current connection state.\n\n### getCurrentDatabase()\n\n public String getCurrentDatabase()\n\nReturns the id of the database that this connection uses.\n\n### getCurrentSchema()\n\n public String getCurrentSchema()\n\nReturns the current schema that is used by this [BackendConnection](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.statements.BackendConnection).\n\n### getSessionState()\n\n public SessionState getSessionState()\n\nReturns the session state of this connection.\n\n### getSpannerConnection()\n\n public Connection getSpannerConnection()\n\nReturns the Spanner connection used by this [BackendConnection](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.statements.BackendConnection).\n\n### initSessionSetting(String name, String value)\n\n public void initSessionSetting(String name, String value)\n\nSets the initial value of a pg_settings setting for this connection. This method should only be\ncalled during startup with values that come from the connection request."]]