public CopyManager(BaseConnection connection) throws SQLException { this.encoding = connection.getEncoding(); this.queryExecutor = connection.getQueryExecutor(); this.connection = connection; }
public CopyManager(BaseConnection connection) throws SQLException { this.encoding = connection.getEncoding(); this.queryExecutor = connection.getQueryExecutor(); this.connection = connection; }
public synchronized Reader getCharacterStream() throws SQLException { Charset connectionCharset = Charset.forName(conn.getEncoding().name()); return new InputStreamReader(getBinaryStream(), connectionCharset); }
_data = _conn.getEncoding().decode(_byteArrayOutputStream.toByteArray()); } catch (IOException ioe) { throw new PSQLException(GT.tr("Failed to convert binary xml data to encoding: {0}.", _conn.getEncoding().name()), PSQLState.DATA_ERROR, ioe); } finally { _byteArrayOutputStream = null;
public synchronized InputStream getBinaryStream() throws SQLException { checkFreed(); ensureInitialized(); if (_data == null) { return null; } try { return new ByteArrayInputStream(_conn.getEncoding().encode(_data)); } catch (IOException ioe) { // This should be a can't happen exception. We just // decoded this data, so it would be surprising that // we couldn't encode it. // For this reason don't make it translatable. throw new PSQLException("Failed to re-encode xml data.", PSQLState.DATA_ERROR, ioe); } }
public synchronized InputStream getBinaryStream() throws SQLException { checkFreed(); ensureInitialized(); if (_data == null) return null; try { return new ByteArrayInputStream(_conn.getEncoding().encode(_data)); } catch (IOException ioe) { // This should be a can't happen exception. We just // decoded this data, so it would be surprising that // we couldn't encode it. // For this reason don't make it translatable. throw new PSQLException("Failed to re-encode xml data.", PSQLState.DATA_ERROR, ioe); } }
_data = _conn.getEncoding().decode(_byteArrayOutputStream.toByteArray()); } catch (IOException ioe) { throw new PSQLException(GT.tr("Failed to convert binary xml data to encoding: {0}.", _conn.getEncoding().name()), PSQLState.DATA_ERROR, ioe); } finally { _byteArrayOutputStream = null;
long oid = lom.createLO(); LargeObject lob = lom.open(oid); Charset connectionCharset = Charset.forName(connection.getEncoding().name()); OutputStream los = lob.getOutputStream(); Writer lw = new OutputStreamWriter(los, connectionCharset);
public int getInt(int columnIndex) throws SQLException { checkResultSet(columnIndex); if (wasNullFlag) return 0; // SQL NULL Encoding encoding = connection.getEncoding(); if (encoding.hasAsciiNumbers()) { try { return getFastInt(columnIndex); } catch (NumberFormatException ex) { } } return toInt( getFixedString(columnIndex) ); }
public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { checkResultSet(columnIndex); if (wasNullFlag) return null; Encoding encoding = connection.getEncoding(); if (encoding.hasAsciiNumbers()) { try { return getFastBigDecimal(columnIndex); } catch (NumberFormatException ex) { } } return toBigDecimal( getFixedString(columnIndex), scale ); }
public long getLong(int columnIndex) throws SQLException { checkResultSet(columnIndex); if (wasNullFlag) return 0; // SQL NULL Encoding encoding = connection.getEncoding(); if (encoding.hasAsciiNumbers()) { try { return getFastLong(columnIndex); } catch (NumberFormatException ex) { } } return toLong( getFixedString(columnIndex) ); }
public String getString(int columnIndex) throws SQLException { checkResultSet( columnIndex ); if (wasNullFlag) return null; Encoding encoding = connection.getEncoding(); try { return trimString(columnIndex, encoding.decode(this_row[columnIndex - 1])); } catch (IOException ioe) { throw new PSQLException(GT.tr("Invalid character data was found. This is most likely caused by stored data containing characters that are invalid for the character set the database was created in. The most common example of this is storing 8bit data in a SQL_ASCII database."), PSQLState.DATA_ERROR, ioe); } }
public java.io.Reader getCharacterStream(int i) throws SQLException { checkResultSet( i ); if (wasNullFlag) return null; if (((AbstractJdbc2Connection) connection).haveMinimumCompatibleVersion("7.2")) { //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()); } else { // In 7.1 Handle as BLOBS so return the LargeObject input stream Encoding encoding = connection.getEncoding(); InputStream input = getBinaryStream(i); try { return encoding.getDecodingReader(input); } catch (IOException ioe) { throw new PSQLException(GT.tr("Unexpected error while decoding character data from a large object."), PSQLState.UNEXPECTED_ERROR, ioe); } } }
Encoding encoding = connection.getEncoding(); if (encoding.hasAsciiNumbers()) { try {
private void setMap(int parameterIndex, Map<?, ?> x) throws SQLException { int oid = connection.getTypeInfo().getPGType("hstore"); if (oid == Oid.UNSPECIFIED) { throw new PSQLException(GT.tr("No hstore extension installed."), PSQLState.INVALID_PARAMETER_TYPE); } if (connection.binaryTransferSend(oid)) { byte[] data = HStoreConverter.toBytes(x, connection.getEncoding()); bindBytes(parameterIndex, data, oid); } else { setString(parameterIndex, HStoreConverter.toString(x), oid); } }
public int getInt(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getInt columnIndex: {0}", columnIndex); checkResultSet(columnIndex); if (wasNullFlag) { return 0; // SQL NULL } if (isBinary(columnIndex)) { int col = columnIndex - 1; int oid = fields[col].getOID(); if (oid == Oid.INT4) { return ByteConverter.int4(this_row[col], 0); } return (int) readLongValue(this_row[col], oid, Integer.MIN_VALUE, Integer.MAX_VALUE, "int"); } Encoding encoding = connection.getEncoding(); if (encoding.hasAsciiNumbers()) { try { return getFastInt(columnIndex); } catch (NumberFormatException ex) { } } return toInt(getFixedString(columnIndex)); }
public long getLong(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getLong columnIndex: {0}", columnIndex); checkResultSet(columnIndex); if (wasNullFlag) { return 0; // SQL NULL } if (isBinary(columnIndex)) { int col = columnIndex - 1; int oid = fields[col].getOID(); if (oid == Oid.INT8) { return ByteConverter.int8(this_row[col], 0); } return readLongValue(this_row[col], oid, Long.MIN_VALUE, Long.MAX_VALUE, "long"); } Encoding encoding = connection.getEncoding(); if (encoding.hasAsciiNumbers()) { try { return getFastLong(columnIndex); } catch (NumberFormatException ex) { } } return toLong(getFixedString(columnIndex)); }
Encoding encoding = connection.getEncoding(); try { return trimString(columnIndex, encoding.decode(this_row[columnIndex - 1]));
return HStoreConverter.fromBytes(this_row[columnIndex - 1], connection.getEncoding());
case Oid.TEXT: case Oid.VARCHAR: Encoding encoding = connection.getEncoding(); arr[i] = encoding.decode(fieldBytes, pos, len); break;