V2Query(String query, boolean withParameters, ProtocolConnection pconn) { useEStringSyntax = pconn.getServerVersion() != null && pconn.getServerVersion().compareTo("8.1") > 0; boolean stdStrings = pconn.getStandardConformingStrings(); if (!withParameters) { fragments = new String[] {query}; return; } // Parse query and find parameter placeholders. Vector v = new Vector(); int lastParmEnd = 0; char[] aChars = query.toCharArray(); for (int i = 0; i < aChars.length; ++i) { switch (aChars[i]) { case '\'': // single-quotes i = Parser.parseSingleQuotes(aChars, i, stdStrings); break; case '"': // double-quotes i = Parser.parseDoubleQuotes(aChars, i); break; case '-': // possibly -- style comment i = Parser.parseLineComment(aChars, i); break; case '/': // possibly /* */ style comment i = Parser.parseBlockComment(aChars, i); break; case '$': // possibly dollar quote start i = Parser.parseDollarQuotes(aChars, i); break; case '?': v.addElement(query.substring(lastParmEnd, i)); lastParmEnd = i + 1; break; default: break; } } v.addElement(query.substring(lastParmEnd, query.length())); fragments = new String[v.size()]; for (int i = 0; i < fragments.length; ++i) fragments[i] = (String) v.elementAt(i); }