This is the first packet sent by the client on connection.
int protocolMajor: the major version of the protocol. Check the Postgres documentation for the exact meaning.
int protocolMinor: the minor version of the protocol.
Map<String, String> parameters: the parameters and their value.
Known parameters:
user: required, the Postgres user name.
database: optional, the database to which to connect.
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");
}