public java.io.Reader getCharacterStream(int i) throws SQLException { checkResultSet(i); if (wasNullFlag) { return null; } // Version 7.2 supports AsciiStream for all the PG text types // As the spec/javadoc for this method indicate this is to be used for // large text values (i.e. LONGVARCHAR) PG doesn't have a separate // long string datatype, but with toast the text datatype is capable of // handling very large values. Thus the implementation ends up calling // getString() since there is no current way to stream the value from the server return new CharArrayReader(getString(i).toCharArray()); }
/** * <p>This is used to fix get*() methods on Money fields. It should only be used by those methods!</p> * * <p>It converts ($##.##) to -##.## and $##.## to ##.##</p> * * @param col column position (1-based) * @return numeric-parsable representation of money string literal * @throws SQLException if something wrong happens */ public String getFixedString(int col) throws SQLException { return trimMoney(getString(col)); }
public String getString(String columnName) throws SQLException { return getString(findColumn(columnName)); }
public SQLXML getSQLXML(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getSQLXML columnIndex: {0}", columnIndex); String data = getString(columnIndex); if (data == null) { return null; } return new PgSQLXML(connection, data); }
public InputStream getAsciiStream(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getAsciiStream columnIndex: {0}", columnIndex); checkResultSet(columnIndex); if (wasNullFlag) { return null; } // Version 7.2 supports AsciiStream for all the PG text types // As the spec/javadoc for this method indicate this is to be used for // large text values (i.e. LONGVARCHAR) PG doesn't have a separate // long string datatype, but with toast the text datatype is capable of // handling very large values. Thus the implementation ends up calling // getString() since there is no current way to stream the value from the server try { return new ByteArrayInputStream(getString(columnIndex).getBytes("ASCII")); } catch (UnsupportedEncodingException l_uee) { throw new PSQLException(GT.tr("The JVM claims not to support the encoding: {0}", "ASCII"), PSQLState.UNEXPECTED_ERROR, l_uee); } }
public InputStream getUnicodeStream(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getUnicodeStream columnIndex: {0}", columnIndex); checkResultSet(columnIndex); if (wasNullFlag) { return null; } // Version 7.2 supports AsciiStream for all the PG text types // As the spec/javadoc for this method indicate this is to be used for // large text values (i.e. LONGVARCHAR) PG doesn't have a separate // long string datatype, but with toast the text datatype is capable of // handling very large values. Thus the implementation ends up calling // getString() since there is no current way to stream the value from the server try { return new ByteArrayInputStream(getString(columnIndex).getBytes("UTF-8")); } catch (UnsupportedEncodingException l_uee) { throw new PSQLException(GT.tr("The JVM claims not to support the encoding: {0}", "UTF-8"), PSQLState.UNEXPECTED_ERROR, l_uee); } }
String s = getString(columnIndex);
public Object getObject(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getObject columnIndex: {0}", columnIndex); Field field; checkResultSet(columnIndex); if (wasNullFlag) { return null; } field = fields[columnIndex - 1]; // some fields can be null, mainly from those returned by MetaData methods if (field == null) { wasNullFlag = true; return null; } Object result = internalGetObject(columnIndex, field); if (result != null) { return result; } if (isBinary(columnIndex)) { return connection.getObject(getPGType(columnIndex), null, this_row[columnIndex - 1]); } return connection.getObject(getPGType(columnIndex), getString(columnIndex), null); }
String string = getString(i); if (oid == Oid.TIME || oid == Oid.TIMETZ) {
case Types.VARCHAR: case Types.LONGVARCHAR: return getString(columnIndex); case Types.DATE: return getDate(columnIndex); return getString(columnIndex); return getUUID(this_row[columnIndex - 1]); return getUUID(getString(columnIndex)); String cursorName = getString(columnIndex); return HStoreConverter.fromBytes(this_row[columnIndex - 1], connection.getEncoding()); return HStoreConverter.fromString(getString(columnIndex));
String string = getString(i); return connection.getTimestampUtils().toTime(cal, string);
return BooleanTypeUtil.castToBoolean(getString(columnIndex));
private LocalDateTime getLocalDateTime(int i) throws SQLException { checkResultSet(i); if (wasNullFlag) { return null; } int col = i - 1; int oid = fields[col].getOID(); if (oid != Oid.TIMESTAMP) { throw new PSQLException( GT.tr("Cannot convert the column of type {0} to requested type {1}.", Oid.toString(oid), "timestamp"), PSQLState.DATA_TYPE_MISMATCH); } if (isBinary(i)) { TimeZone timeZone = getDefaultCalendar().getTimeZone(); return connection.getTimestampUtils().toLocalDateTimeBin(timeZone, this_row[col]); } String string = getString(i); return connection.getTimestampUtils().toLocalDateTime(string); } //JCP! endif
@Override public java.sql.Date getDate(int i, java.util.Calendar cal) throws SQLException { checkResultSet(i); if (wasNullFlag) { return null; } if (cal == null) { cal = getDefaultCalendar(); } if (isBinary(i)) { int col = i - 1; int oid = fields[col].getOID(); TimeZone tz = cal.getTimeZone(); if (oid == Oid.DATE) { return connection.getTimestampUtils().toDateBin(tz, this_row[col]); } else if (oid == Oid.TIMESTAMP || oid == Oid.TIMESTAMPTZ) { // If backend provides just TIMESTAMP, we use "cal" timezone // If backend provides TIMESTAMPTZ, we ignore "cal" as we know true instant value Timestamp timestamp = getTimestamp(i, cal); // Here we just truncate date to 00:00 in a given time zone return connection.getTimestampUtils().convertToDate(timestamp.getTime(), tz); } else { throw new PSQLException( GT.tr("Cannot convert the column of type {0} to requested type {1}.", Oid.toString(oid), "date"), PSQLState.DATA_TYPE_MISMATCH); } } return connection.getTimestampUtils().toDate(cal, getString(i)); }
return type.cast(getString(columnIndex)); } else { throw new PSQLException(GT.tr("conversion to {0} from {1} not supported", type, sqlType), object = connection.getObject(getPGType(columnIndex), null, this_row[columnIndex - 1]); } else { object = connection.getObject(getPGType(columnIndex), getString(columnIndex), null);
private LocalTime getLocalTime(int i) throws SQLException { checkResultSet(i); if (wasNullFlag) { return null; } if (isBinary(i)) { int col = i - 1; int oid = fields[col].getOID(); if (oid == Oid.TIME) { return connection.getTimestampUtils().toLocalTimeBin(this_row[col]); } else { throw new PSQLException( GT.tr("Cannot convert the column of type {0} to requested type {1}.", Oid.toString(oid), "time"), PSQLState.DATA_TYPE_MISMATCH); } } String string = getString(i); return connection.getTimestampUtils().toLocalTime(string); } //JCP! endif