public Object getObject(String columnName) throws SQLException { return getObject(findColumn(columnName)); }
private void updateGeneratedKeys() { if (allGeneratedRows == null || allGeneratedRows.isEmpty()) { return; } for (List<byte[][]> rows : allGeneratedRows) { generatedKeys.addRows(rows); } allGeneratedRows.clear(); }
public int getType() throws SQLException { checkClosed(); return resultsettype; }
public ResultSetMetaData getMetaData() throws SQLException { checkClosed(); if (rsMetaData == null) { rsMetaData = createMetaData(); } return rsMetaData; }
public synchronized void updateNull(int columnIndex) throws SQLException { checkColumnIndex(columnIndex); String columnTypeName = getPGType(columnIndex); updateValue(columnIndex, new NullObject(columnTypeName)); }
int sqlType = getSQLType(columnIndex); if (type == BigDecimal.class) { if (sqlType == Types.NUMERIC || sqlType == Types.DECIMAL) { return type.cast(getBigDecimal(columnIndex)); } else { throw new PSQLException(GT.tr("conversion to {0} from {1} not supported", type, sqlType), return type.cast(getString(columnIndex)); } else { throw new PSQLException(GT.tr("conversion to {0} from {1} not supported", type, sqlType), boolean booleanValue = getBoolean(columnIndex); if (wasNull()) { return null; short shortValue = getShort(columnIndex); if (wasNull()) { return null; int intValue = getInt(columnIndex); if (wasNull()) { return null; long longValue = getLong(columnIndex); if (wasNull()) { return null; long longValue = getLong(columnIndex); if (wasNull()) {
public String getString(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getString columnIndex: {0}", columnIndex); checkResultSet(columnIndex); if (wasNullFlag) { return null; if (isBinary(columnIndex) && getSQLType(columnIndex) != Types.VARCHAR) { Field field = fields[columnIndex - 1]; Object obj = internalGetObject(columnIndex, field); if (obj == null) { obj = getObject(columnIndex); if (obj == null) { return null; oid == Oid.TIMESTAMPTZ || oid == Oid.TIMETZ); if ("hstore".equals(getPGType(columnIndex))) { return HStoreConverter.toString((Map<?, ?>) obj); return trimString(columnIndex, obj.toString()); return trimString(columnIndex, encoding.decode(this_row[columnIndex - 1])); } catch (IOException ioe) { throw new PSQLException(
protected void updateValue(int columnIndex, Object value) throws SQLException { checkUpdateable(); if (!onInsertRow && (isBeforeFirst() || isAfterLast() || rows.isEmpty())) { throw new PSQLException( GT.tr( "Cannot update the ResultSet because it is either before the start or after the end of the results."), PSQLState.INVALID_CURSOR_STATE); } checkColumnIndex(columnIndex); doingUpdates = !onInsertRow; if (value == null) { updateNull(columnIndex); } else { PGResultSetMetaData md = (PGResultSetMetaData) getMetaData(); updateValues.put(md.getBaseColumnName(columnIndex), value); } }
public void refreshRow() throws SQLException { checkUpdateable(); if (onInsertRow) { throw new PSQLException(GT.tr("Can''t refresh the insert row."), if (isBeforeFirst() || isAfterLast() || rows.isEmpty()) { return; ResultSetMetaData rsmd = getMetaData(); PGResultSetMetaData pgmd = (PGResultSetMetaData) rsmd; for (int i = 1; i <= rsmd.getColumnCount(); i++) { if (rs.next()) { rowBuffer = rs.this_row; rs.close(); selectStatement.close(); selectStatement = null;
final ResultSetMetaData rsMetaData = pgSet.getMetaData(); final int typeId = pgSet.getColumnOID(i); DbResultNode node = null; final Object obj = pgSet.getObject(i); final String name = rsMetaData.getColumnName(i); final DbFunction function = DbFunctionRegister.getFunction(name, pgSet.getStatement().getConnection()); List<String> fieldValues; try { if (fieldDef.getType().equals("USER-DEFINED")) { currentNode = new ObjectResultNode(fieldValue, fieldDef.getName(), fieldDef.getTypeName(), fieldDef.getTypeId(), pgSet.getStatement().getConnection()); } else if (fieldDef.getType().equals("ARRAY")) { currentNode = new ArrayResultNode(fieldDef.getName(), fieldValue, fieldDef.getTypeName().substring(1), fieldDef.getTypeId(), pgSet.getStatement().getConnection()); } else { currentNode = new SimpleResultNode(fieldValue, fieldDef.getName()); final PGobject pgObj = (PGobject) obj; node = new ObjectResultNode(pgObj.getValue(), name, pgObj.getType(), typeId, pgSet.getStatement().getConnection()); } else if (obj instanceof PgArray) { final PgArray arrayObj = (PgArray) obj; node = new ArrayResultNode(name, value, typeName, typeId, pgSet.getStatement().getConnection());
public boolean absolute(int index) throws SQLException { checkScrollable(); beforeFirst(); return false; internalIndex = rows_size + index; } else { beforeFirst(); return false; internalIndex = index - 1; } else { afterLast(); return false; initRowBuffer(); onInsertRow = false;
checkClosed(); parseQuery(); int oidIndex = findColumnIndex("oid"); // 0 if not present } else { String[] s = quotelessTableName(tableName); String quotelessTableName = s[0]; String quotelessSchemaName = s[1]; numPKcolumns++; String columnName = rs.getString(4); // get the columnName int index = findColumnIndex(columnName);
public Object getObjectImpl(int i, Map<String, Class<?>> map) throws SQLException { checkClosed(); if (map == null || map.isEmpty()) { return getObject(i); } throw org.postgresql.Driver.notImplemented(this.getClass(), "getObjectImpl(int,Map)"); }
public ResultSet createResultSet(Query originalQuery, Field[] fields, List<byte[][]> tuples, ResultCursor cursor) throws SQLException { PgResultSet newResult = new PgResultSet(originalQuery, this, fields, tuples, cursor, getMaxRows(), getMaxFieldSize(), getResultSetType(), getResultSetConcurrency(), getResultSetHoldability()); newResult.setFetchSize(getFetchSize()); newResult.setFetchDirection(getFetchDirection()); return newResult; }
Object getValue() throws SQLException { return getObject(index); } }
public boolean relative(int rows) throws SQLException { checkScrollable(); if (onInsertRow) { throw new PSQLException(GT.tr("Can''t use relative move methods while on the insert row."), PSQLState.INVALID_CURSOR_STATE); } // have to add 1 since absolute expects a 1-based index return absolute(current_row + 1 + rows); }
public synchronized void cancelRowUpdates() throws SQLException { checkClosed(); if (onInsertRow) { throw new PSQLException(GT.tr("Cannot call cancelRowUpdates() when on the insert row."), PSQLState.INVALID_CURSOR_STATE); } if (doingUpdates) { doingUpdates = false; clearRowBuffer(true); } }
public int findColumn(String columnName) throws SQLException { checkClosed(); int col = findColumnIndex(columnName); if (col == 0) { throw new PSQLException( GT.tr("The column name {0} was not found in this ResultSet.", columnName), PSQLState.UNDEFINED_COLUMN); } return col; }
private void checkUpdateable() throws SQLException { checkClosed(); if (!isUpdateable()) { throw new PSQLException( GT.tr( "ResultSet is not updateable. The query that generated this result set must select only one table, and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details."), PSQLState.INVALID_CURSOR_STATE); } if (updateValues == null) { // allow every column to be updated without a rehash. updateValues = new HashMap<String, Object>((int) (fields.length / 0.75), 0.75f); } }
public void setFetchDirection(int direction) throws SQLException { checkClosed(); switch (direction) { case ResultSet.FETCH_FORWARD: break; case ResultSet.FETCH_REVERSE: case ResultSet.FETCH_UNKNOWN: checkScrollable(); break; default: throw new PSQLException(GT.tr("Invalid fetch direction constant: {0}.", direction), PSQLState.INVALID_PARAMETER_VALUE); } this.fetchdirection = direction; }