diff --git a/org/postgresql/core/Parser.java b/org/postgresql/core/Parser.java
index <HASH>..<HASH> 100644
--- a/org/postgresql/core/Parser.java
+++ b/org/postgresql/core/Parser.java
@@ -83,6 +83,9 @@ public class Parser {
                 break;
 
             case '?':
+				if (!withParameters)
+					break;
+
                 nativeSql.append(aChars, fragmentStart, i - fragmentStart);
                 if (i + 1 < aChars.length && aChars[i + 1] == '?') /* replace ?? with ? */
                 {
Replace question marks only in PreparedStatements

Question marks in the query text should be replaced with positional
parameters ($1, $2, ...) only in java.sql.PreparedStatement.
In a java.sql.Statement they should be left alone.