@Override public String escapeIdentifier(String identifier) throws SQLException { return Utils.escapeIdentifier(null, identifier).toString(); }
private static boolean addReturning(StringBuilder nativeSql, SqlCommandType currentCommandType, String[] returningColumnNames, boolean isReturningPresent) throws SQLException { if (isReturningPresent || returningColumnNames.length == 0) { return false; } if (currentCommandType != SqlCommandType.INSERT && currentCommandType != SqlCommandType.UPDATE && currentCommandType != SqlCommandType.DELETE && currentCommandType != SqlCommandType.WITH) { return false; } nativeSql.append("\nRETURNING "); if (returningColumnNames.length == 1 && returningColumnNames[0].charAt(0) == '*') { nativeSql.append('*'); return true; } for (int col = 0; col < returningColumnNames.length; col++) { String columnName = returningColumnNames[col]; if (col > 0) { nativeSql.append(", "); } Utils.escapeIdentifier(nativeSql, columnName); } return true; }
public String getPGName() throws SQLException { if (!_isValid) { throw new PSQLException(GT.tr("Cannot reference a savepoint after it has been released."), PSQLState.INVALID_SAVEPOINT_SPECIFICATION); } if (_isNamed) { // We need to quote and escape the name in case it // contains spaces/quotes/etc. // return Utils.escapeIdentifier(null, _name).toString(); } return "JDBC_SAVEPOINT_" + _id; } }
String columnName = columnNames.next(); Utils.escapeIdentifier(insertSQL, columnName); if (i < numColumns - 1) { insertSQL.append(", ");
Utils.escapeIdentifier(updateSQL, column); updateSQL.append(" = ?"); Utils.escapeIdentifier(updateSQL, primaryKey.name); updateSQL.append(" = ?");
Utils.escapeIdentifier(deleteSQL, primaryKeys.get(i).name); deleteSQL.append(" = ?"); if (i < numKeys - 1) {
Utils.escapeIdentifier(sb, cursorName); Utils.escapeIdentifier(sb, cursorName); connection.execSQLUpdate(sb.toString()); ((PgResultSet) rs).setRefCursor(cursorName);
@Override public String escapeIdent(String ident) { try { StringBuilder buf = new StringBuilder(); escapeIdentifier(buf, ident); return buf.toString(); } catch (SQLException ex) { throw new IllegalArgumentException( String.format(ENGLISH, "Invalid identifier name (%s): %s", ex.getMessage(), ident)); } }