This is the first packet sent by the client on connection. It simply contains name/value pairs, accessible using:

  • getParameter(String name): get the value of the specified parameter.

  • getParameters(): returns a Map<String, String> of all parameters defined in this startup packet. This is read-only, use setParameter or removeParameter to change parameters.

  • setParameter(String name, String value): sets the value of the specified parameter.

  • String removeParameter(String name) : unsets the value of the specified parameter, returns the old value if present

Known parameters:

  • user: required, the Postgres user name.

  • database: optional, the database to which to connect. Defaults to the user name if not specified.

  • options: deprecated

  • replication: can be true, false or database. The default is false.

Other parameters are usually present (like client_encoding, DateStyle or TimeZone), but that depends on the client type and settings.


Set the database if it is not specified by the client.

if ( ! context.packet.getParameter("database")) {
context.packet.setParameter("database", "maindb");