Handles a connection from a client to Spanner. This ConnectionHandler uses WireMessage to receive and send all messages from and to the client, using the intermediate
representation IntermediateStatement that servers as a middle layer between Postgres and
Spanner.
Each ConnectionHandler is also a Thread. Although a TCP connection does not
necessarily need to have its own thread, this makes the implementation more straightforward.
The PostgreSQL wire protocol can send data in both binary and text format. When using text
format, the Server will normally send output back to the client using a format
understood by PostgreSQL clients. If you are using the server with a text-only client that does
not try to interpret the data that is returned by the server, such as for example psql, then it
is advisable to use Cloud Spanner formatting. The server will then return all data in a format
understood by Cloud Spanner.
[[["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,["# Package com.google.cloud.spanner.pgadapter (0.27.1)\n\nVersion latestkeyboard_arrow_down\n\n- [0.27.1 (latest)](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter)\n- [0.27.0](/java/docs/reference/pgadapter/0.27.0/com.google.cloud.spanner.pgadapter)\n- [0.26.0](/java/docs/reference/pgadapter/0.26.0/com.google.cloud.spanner.pgadapter)\n- [0.25.0](/java/docs/reference/pgadapter/0.25.0/com.google.cloud.spanner.pgadapter)\n- [0.24.0](/java/docs/reference/pgadapter/0.24.0/com.google.cloud.spanner.pgadapter)\n- [0.23.1](/java/docs/reference/pgadapter/0.23.1/com.google.cloud.spanner.pgadapter)\n- [0.22.1](/java/docs/reference/pgadapter/0.22.1/com.google.cloud.spanner.pgadapter)\n- [0.21.0](/java/docs/reference/pgadapter/0.21.0/com.google.cloud.spanner.pgadapter)\n- [0.20.0](/java/docs/reference/pgadapter/0.20.0/com.google.cloud.spanner.pgadapter)\n- [0.19.1](/java/docs/reference/pgadapter/0.19.1/com.google.cloud.spanner.pgadapter)\n- [0.18.4](/java/docs/reference/pgadapter/0.18.4/com.google.cloud.spanner.pgadapter)\n- [0.17.0](/java/docs/reference/pgadapter/0.17.0/com.google.cloud.spanner.pgadapter)\n- [0.16.0](/java/docs/reference/pgadapter/0.16.0/com.google.cloud.spanner.pgadapter)\n- [0.15.0](/java/docs/reference/pgadapter/0.15.0/com.google.cloud.spanner.pgadapter)\n- [0.14.1](/java/docs/reference/pgadapter/0.14.1/com.google.cloud.spanner.pgadapter)\n- [0.9.0](/java/docs/reference/pgadapter/0.9.0/com.google.cloud.spanner.pgadapter)\n- [0.8.0](/java/docs/reference/pgadapter/0.8.0/com.google.cloud.spanner.pgadapter)\n- [0.7.0](/java/docs/reference/pgadapter/0.7.0/com.google.cloud.spanner.pgadapter)\n- [0.6.1](/java/docs/reference/pgadapter/0.6.1/com.google.cloud.spanner.pgadapter)\n- [0.5.1](/java/docs/reference/pgadapter/0.5.1/com.google.cloud.spanner.pgadapter) \n\nClasses\n-------\n\n### [ConnectionHandler](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.ConnectionHandler)\n\nHandles a connection from a client to Spanner. This [ConnectionHandler](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.ConnectionHandler) uses [WireMessage](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.wireprotocol.WireMessage) to receive and send all messages from and to the client, using the intermediate\nrepresentation [IntermediateStatement](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.statements.IntermediateStatement) that servers as a middle layer between Postgres and\nSpanner.\n\nEach [ConnectionHandler](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.ConnectionHandler) is also a [Thread](https://docs.oracle.com/javase/8/docs/api/java/lang/Thread.html). Although a TCP connection does not\nnecessarily need to have its own thread, this makes the implementation more straightforward.\n\n### [ProxyServer](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.ProxyServer)\n\nThe proxy server listens for incoming client connections and starts a new [ConnectionHandler](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.ConnectionHandler) for each incoming connection.\n\n### [Server](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.Server)\n\nEffectively this is the main class\n\nEnums\n-----\n\n### [ConnectionHandler.ConnectionStatus](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.ConnectionHandler.ConnectionStatus)\n\nStatus of a [ConnectionHandler](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.ConnectionHandler)\n\n### [ConnectionHandler.QueryMode](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.ConnectionHandler.QueryMode)\n\nPostgreSQL query mode (see also [here](https://www.postgresql.org/docs/current/protocol-flow.html)).\n\n### [ProxyServer.DataFormat](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.ProxyServer.DataFormat)\n\nThe PostgreSQL wire protocol can send data in both binary and text format. When using text\nformat, the [Server](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.Server) will normally send output back to the client using a format\nunderstood by PostgreSQL clients. If you are using the server with a text-only client that does\nnot try to interpret the data that is returned by the server, such as for example psql, then it\nis advisable to use Cloud Spanner formatting. The server will then return all data in a format\nunderstood by Cloud Spanner.\n\nThe default format used by the server is [DataFormat#POSTGRESQL_TEXT](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.ProxyServer.DataFormat#com_google_cloud_spanner_pgadapter_ProxyServer_DataFormat_POSTGRESQL_TEXT)."]]