public PGXAConnection(BaseConnection conn) throws SQLException { super(conn, true, true); this.conn = conn; this.state = STATE_IDLE; this.logger = conn.getLogger(); }
public Time getTime(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getTime columnIndex: {0}", columnIndex); return getTime(columnIndex, null); }
public Timestamp getTimestamp(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getTimestamp columnIndex: {0}", columnIndex); return getTimestamp(columnIndex, null); }
public RowId getRowId(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getRowId columnIndex: {0}", columnIndex); throw org.postgresql.Driver.notImplemented(this.getClass(), "getRowId(int)"); }
public Reader getNCharacterStream(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getNCharacterStream columnIndex: {0}", columnIndex); throw org.postgresql.Driver.notImplemented(this.getClass(), "getNCharacterStream(int)"); }
public NClob getNClob(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getNClob columnIndex: {0}", columnIndex); throw org.postgresql.Driver.notImplemented(this.getClass(), "getNClob(int)"); }
public String getNString(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getNString columnIndex: {0}", columnIndex); throw org.postgresql.Driver.notImplemented(this.getClass(), "getNString(int)"); }
public java.sql.Date getDate(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getDate columnIndex: {0}", columnIndex); return getDate(columnIndex, null); }
public java.net.URL getURL(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getURL columnIndex: {0}", columnIndex); checkClosed(); throw org.postgresql.Driver.notImplemented(this.getClass(), "getURL(int)"); }
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); }
/** * @param name Function name * @param resulttype True if the result is a numeric (Integer or Long) * @param args FastpathArguments to pass to fastpath * @return null if no data, Integer if an integer result, Long if a long result, or byte[] * otherwise * @throws SQLException if something goes wrong * @see #fastpath(int, FastpathArg[]) * @see #fastpath(String, FastpathArg[]) * @deprecated Use {@link #getData(String, FastpathArg[])} if you expect a binary result, or one * of {@link #getInteger(String, FastpathArg[])} or * {@link #getLong(String, FastpathArg[])} if you expect a numeric one */ @Deprecated public Object fastpath(String name, boolean resulttype, FastpathArg[] args) throws SQLException { connection.getLogger().log(Level.FINEST, "Fastpath: calling {0}", name); return fastpath(getID(name), resulttype, args); }
public InputStream getBinaryStream(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getBinaryStream columnIndex: {0}", columnIndex); checkResultSet(columnIndex); if (wasNullFlag) { return null; } // Version 7.2 supports BinaryStream for all PG bytea type // As the spec/javadoc for this method indicate this is to be used for // large binary values (i.e. LONGVARBINARY) PG doesn't have a separate // long binary datatype, but with toast the bytea datatype is capable of // handling very large values. Thus the implementation ends up calling // getBytes() since there is no current way to stream the value from the server byte[] b = getBytes(columnIndex); if (b != null) { return new ByteArrayInputStream(b); } return null; }
/** * <p>Send a function call to the PostgreSQL backend by name.</p> * * <p>Note: the mapping for the procedure name to function id needs to exist, usually to an earlier * call to addfunction().</p> * * <p>This is the preferred method to call, as function id's can/may change between versions of the * backend.</p> * * <p>For an example of how this works, refer to org.postgresql.largeobject.LargeObject</p> * * @param name Function name * @param args FastpathArguments to pass to fastpath * @return null if no data, byte[] otherwise * @throws SQLException if name is unknown or if a database-access error occurs. * @see org.postgresql.largeobject.LargeObject */ public byte[] fastpath(String name, FastpathArg[] args) throws SQLException { connection.getLogger().log(Level.FINEST, "Fastpath: calling {0}", name); return fastpath(getID(name), args); }
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); } }
public double getDouble(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getDouble 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.FLOAT8) { return ByteConverter.float8(this_row[col], 0); } return readDoubleValue(this_row[col], oid, "double"); } return toDouble(getFixedString(columnIndex)); }
public float getFloat(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getFloat 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.FLOAT4) { return ByteConverter.float4(this_row[col], 0); } return (float) readDoubleValue(this_row[col], oid, "float"); } return toFloat(getFixedString(columnIndex)); }
@Override public short getShort(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getShort 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.INT2) { return ByteConverter.int2(this_row[col], 0); } return (short) readLongValue(this_row[col], oid, Short.MIN_VALUE, Short.MAX_VALUE, "short"); } return toShort(getFixedString(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); }
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)); }