Java Code Examples for org.postgresql.core.Utils

The following examples show how to use org.postgresql.core.Utils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hugegraph   Source File: PostgresqlSessions.java    License: Apache License 2.0 5 votes vote down vote up
public static String escapeAndWrapString(String value) {
    StringBuilder builder = new StringBuilder(8 + value.length());
    builder.append('\'');
    try {
        Utils.escapeLiteral(builder, value, false);
    } catch (SQLException e) {
        throw new HugeException("Failed to escape '%s'", e, value);
    }
    builder.append('\'');
    return builder.toString();
}
 
Example 2
Source Project: hugegraph-loader   Source File: JDBCUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static String escapePostgresql(String value) {
    StringBuilder builder = new StringBuilder(8 + value.length());
    builder.append('\'');
    try {
        Utils.escapeLiteral(builder, value, false);
    } catch (SQLException e) {
        throw new LoadException("Failed to escape '%s'", e, value);
    }
    builder.append('\'');
    return builder.toString();
}
 
Example 3
Source Project: digdag   Source File: RedshiftConnection.java    License: Apache License 2.0 5 votes vote down vote up
private static String escapeParam(String param)
{
    StringBuilder sb = new StringBuilder();
    try {
        return Utils.escapeLiteral(sb, param, false).toString();
    }
    catch (SQLException e) {
        throw new ConfigException("Failed to escape a parameter in configuration file: param=" + param, e);
    }
}