A PostgreSQL JDBC connection setting that forces the driver to send SQL as simple query protocol rather than the extended query protocol. It is used in application connection strings or properties, mainly to change how statements are parsed, prepared and escaped, which can affect compatibility and SQL injection exposure.
How PreferQueryMode=SIMPLE changes PostgreSQL query handling
PreferQueryMode=SIMPLE changes how the PostgreSQL JDBC driver sends statements to the database. Instead of using the extended query protocol, the driver sends SQL as a simple query, which changes parsing, parameter handling, and statement preparation behaviour. That makes it a compatibility switch as much as a transport choice.
Because the driver no longer uses the extended protocol, some application behaviours that depend on prepared statements, binary transfer, or server-side statement lifecycle can change. In practice, that can alter how the application experiences quoting, escaping, error handling, and multi-statement execution.
Why simple query mode matters for security
The security relevance is not the setting itself, but the way it changes the boundary between application-supplied text and database execution. If an application is already constructing SQL unsafely, simple query mode can make that exposure easier to exploit because the driver is leaning more heavily on raw SQL text rather than structured parameter binding.
That is why this setting should be treated as a statement-execution control, not just a compatibility toggle. It can influence whether safe parameterisation is preserved consistently across the code path, especially in older libraries or code that mixes literal SQL with user input.
Where compatibility and injection risk show up
Simple query mode is often chosen to work around driver or database behaviour that is awkward under extended protocol, but the trade-off is reduced protection through protocol-level structure. If the application relies on client-side escaping, complex concatenated SQL, or assumptions about prepared-statement behaviour, the resulting query path can become more fragile and easier to misuse.
It also matters for observability and troubleshooting. Queries that behave correctly in one mode may fail or behave differently in the other, which can hide latent SQL construction issues until a production change, driver upgrade, or database feature shift exposes them.
Operational implications for application teams
For practitioners, this setting is best understood as part of the application’s SQL execution model. It should be documented alongside connection string defaults, reviewed when changing database drivers, and tested wherever the application uses dynamic SQL, stored procedure calls, or mixed literal and parameterised statements.
When behaviour changes unexpectedly after enabling simple mode, the right question is usually not only “does the query still work?” but also “has the application lost a safety property it previously depended on?” That distinction is important for secure coding reviews and for change-management sign-off.
Risk and Threat Considerations
PreferQueryMode=SIMPLE can increase exposure when applications depend on the driver to preserve safer statement structure. The main risk is that a code path which looked controlled under the extended query protocol becomes more permissive when raw SQL text is sent directly, especially in code that already concatenates user-controlled values.
Failure mechanism: Unsafe SQL construction, brittle escaping, or incorrect assumptions about prepared-statement behaviour can produce exploitable injection paths once the driver sends simple queries instead of structured extended-protocol messages.
Impact: An attacker may gain the ability to alter database queries, read or modify unexpected data, or trigger broader application compromise if database privileges are excessive.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP ASVS, NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP ASVS | V4 — API and Web Service | This setting affects how application SQL is formed and sent. |
| V8 — Authorization | If SQL is altered or injected, authorization boundaries on data access become central. | |
| Recommendation — Verify that database calls use safe parameter handling and resist injection across all query paths. Enforce server-side authorization for every data access path exposed to SQL execution. | ||
| NIST SP 800-53 Rev 5 | SI-10 — Information Input Validation | The term changes how untrusted input can reach database statements. |
| AC-6 — Least Privilege | SQL injection impact depends heavily on database privileges reachable through the connection. | |
| Recommendation — Validate and constrain input before it is incorporated into executable SQL. Limit database account privileges so injected SQL cannot access more than required. | ||
| CIS Controls v8 | CIS-16 — Application Software Security | The setting is an application security choice that can influence injection exposure. |
| Recommendation — Review application database access patterns for injection risk before changing JDBC query mode. | ||
Practitioner Guidance
Why practitioners should care: This setting is not just a driver preference, it can change the security characteristics of how SQL reaches the database. Treat it as an application-level decision that deserves testing, code review, and change control.
Common misunderstanding: Teams sometimes assume that parameterised queries remain equally safe in every driver mode. In reality, the surrounding query construction pattern, driver behaviour, and application logic all matter when the protocol changes.
Practitioner takeaway: If simple mode is required for compatibility, validate every SQL path that handles user input and confirm that the application still uses safe parameter binding rather than relying on string concatenation.
Related resources from NHI Mgmt Group
- What is the difference between zero standing privilege and simple credential rotation for agents?
- What is the difference between secure identity optimisation and simple cost cutting?
- Why do agentic workflows need a protocol for human approval instead of a simple prompt?
- What breaks when nonhuman identities are managed like simple service accounts?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on November 25, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org