public class Utils
extends java.lang.Object
| Constructor and Description |
|---|
Utils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.StringBuilder |
escapeIdentifier(java.lang.StringBuilder sbuf,
java.lang.String value)
Escape the given identifier
value and append it to the string builder sbuf. |
static java.lang.StringBuilder |
escapeLiteral(java.lang.StringBuilder sbuf,
java.lang.String value,
boolean standardConformingStrings)
Escape the given literal
value and append it to the string builder sbuf. |
static int |
parseServerVersionStr(java.lang.String serverVersion)
Attempt to parse the server version string into an XXYYZZ form version number.
|
static java.lang.String |
toHexString(byte[] data)
Turn a bytearray into a printable form, representing each byte in hex.
|
public static java.lang.String toHexString(byte[] data)
data - the bytearray to stringizedatapublic static java.lang.StringBuilder escapeLiteral(java.lang.StringBuilder sbuf,
java.lang.String value,
boolean standardConformingStrings)
throws java.sql.SQLException
value and append it to the string builder sbuf. If
sbuf is null, a new StringBuilder will be returned. The argument
standardConformingStrings defines whether the backend expects standard-conforming
string literals or allows backslash escape sequences.sbuf - the string builder to append to; or nullvalue - the string valuestandardConformingStrings - if standard conforming strings should be usedjava.sql.SQLException - if the string contains a \0 characterpublic static java.lang.StringBuilder escapeIdentifier(java.lang.StringBuilder sbuf,
java.lang.String value)
throws java.sql.SQLException
value and append it to the string builder sbuf.
If sbuf is null, a new StringBuilder will be returned. This method is
different from appendEscapedLiteral in that it includes the quoting required for the identifier
while escapeLiteral(StringBuilder, String, boolean) does not.sbuf - the string builder to append to; or nullvalue - the string valuejava.sql.SQLException - if the string contains a \0 characterpublic static int parseServerVersionStr(java.lang.String serverVersion)
throws java.lang.NumberFormatException
Returns 0 if the version could not be parsed.
Returns minor version 0 if the minor version could not be determined, e.g. devel or beta releases.
If a single major part like 90400 is passed, it's assumed to be a pre-parsed version and returned verbatim. (Anything equal to or greater than 10000 is presumed to be this form).
The yy or zz version parts may be larger than 99. A NumberFormatException is thrown if a version part is out of range.
serverVersion - server version in a XXYYZZ formjava.lang.NumberFormatExceptionCopyright © 2025 PostgreSQL Global Development Group. All rights reserved.