public Reader getReader() { return new StringReader(getString()); }
@Override public void writeValue(DataBuffer buff, Value v) { String s = v.getString(); write0(buff, s); }
private static long length(Value v) { switch (v.getType()) { case Value.BLOB: case Value.CLOB: case Value.BYTES: case Value.JAVA_OBJECT: return v.getPrecision(); default: return v.getString().length(); } }
protected String getFileName() { if (fileNameExpr != null && fileName == null) { fileName = fileNameExpr.optimize(session).getValue(session).getString(); if (fileName == null || fileName.trim().length() == 0) { fileName = "script.sql"; } fileName = SysProperties.getScriptDirectory() + fileName; } return fileName; }
private Character getEscapeChar(Value e) { if (e == null) { return getEscapeChar(defaultEscape); } String es = e.getString(); Character esc; if (es == null) { esc = getEscapeChar(defaultEscape); } else if (es.length() == 0) { esc = null; } else if (es.length() > 1) { throw DbException.get(ErrorCode.LIKE_ESCAPE_ERROR_1, es); } else { esc = es.charAt(0); } return esc; }
@Override protected int compareSecure(Value v, CompareMode mode) { if (v instanceof ValueLob) { ValueLob v2 = (ValueLob) v; if (v == this) { return 0; } if (lobId == v2.lobId && small == null && v2.small == null) { return 0; } } if (type == Value.CLOB) { return Integer.signum(getString().compareTo(v.getString())); } byte[] v2 = v.getBytesNoCopy(); return Utils.compareNotNullSigned(getBytes(), v2); }
private static byte[] getByteArray(ServerSession session, Expression e) { String s = e.optimize(session).getValue(session).getString(); return s == null ? new byte[0] : StringUtils.convertHexToBytes(s); }
private static long getDiskSpaceUsed(ServerSession session, Value v0) { Parser p = new Parser(session); String sql = v0.getString(); Table table = p.parseTableName(sql); return table.getDiskSpaceUsed(); }
/** * Returns the value of the specified column as a String. * * @param columnIndex (1,2,...) * @return the value * @throws SQLException if the column is not found or if the result set is closed */ @Override public String getString(int columnIndex) throws SQLException { try { debugCodeCall("getString", columnIndex); return get(columnIndex).getString(); } catch (Exception e) { throw logAndConvert(e); } }
/** * Returns the value of the specified column as a String. * * @param columnLabel the column label * @return the value * @throws SQLException if the column is not found or if the result set is closed */ @Override public String getString(String columnLabel) throws SQLException { try { debugCodeCall("getString", columnLabel); return get(columnLabel).getString(); } catch (Exception e) { throw logAndConvert(e); } }
/** * Returns the value of the specified column as a String. * * @param columnLabel the column label * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Override public String getNString(String columnLabel) throws SQLException { try { debugCodeCall("getNString", columnLabel); return get(columnLabel).getString(); } catch (Exception e) { throw logAndConvert(e); } }
/** * Returns the value of the specified column as a String. * * @param columnIndex (1,2,...) * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Override public String getNString(int columnIndex) throws SQLException { try { debugCodeCall("getNString", columnIndex); return get(columnIndex).getString(); } catch (Exception e) { throw logAndConvert(e); } }
private String readString() { Expression expr = readExpression().optimize(session); if (!(expr instanceof ValueExpression)) { throw DbException.getSyntaxError(sqlCommand, parseIndex, "string"); } String s = expr.getValue(session).getString(); return s; }
/** * Set the password for the given user. * * @param user the user * @param session the session * @param password the password */ static void setPassword(User user, ServerSession session, Expression password) { String pwd = password.optimize(session).getValue(session).getString(); char[] passwordChars = pwd == null ? new char[0] : pwd.toCharArray(); byte[] userPasswordHash = ConnectionInfo.createUserPasswordHash(user.getName(), passwordChars); user.setUserPasswordHash(userPasswordHash); }
/** * Returns the input stream. * * @return the input stream */ @Override public InputStream getAsciiStream() throws SQLException { try { debugCodeCall("getAsciiStream"); checkClosed(); String s = value.getString(); return IOUtils.getInputStreamFromString(s); } catch (Exception e) { throw logAndConvert(e); } }
@Override public String getString() { StatementBuilder buff = new StatementBuilder("("); for (Value v : values) { buff.appendExceptFirst(", "); buff.append(v.getString()); } return buff.append(')').toString(); }
public MetaRecord(SearchRow r) { id = r.getValue(0).getInt(); objectType = DbObjectType.TYPES[r.getValue(1).getInt()]; sql = r.getValue(2).getString(); }
/** * Returns the value of the specified column as an input stream. * * @param columnIndex (1,2,...) * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Override public InputStream getAsciiStream(int columnIndex) throws SQLException { try { debugCodeCall("getAsciiStream", columnIndex); String s = get(columnIndex).getString(); return s == null ? null : IOUtils.getInputStreamFromString(s); } catch (Exception e) { throw logAndConvert(e); } }
@Override public int update() { String fileName = fileNameExpr.getValue(session).getString(); session.getUser().checkAdmin(); session.getDatabase().backupTo(fileName); return 0; }
private void initStore() { Database db = session.getDatabase(); byte[] key = null; if (cipher != null && password != null) { char[] pass = password.optimize(session).getValue(session).getString().toCharArray(); key = SHA256.getKeyPasswordHash("script", pass); } String file = getFileName(); fileStorage = FileStorage.open(db, file, "rw", cipher, key); fileStorage.setCheckedWriting(false); fileStorage.init(); }