public String getBaseTypeName() throws SQLException { buildArrayList(); int elementOID = connection.getTypeInfo().getPGArrayElement(oid); return connection.getTypeInfo().getPGType(elementOID); }
private void setTimestamp(int i, OffsetDateTime offsetDateTime) throws SQLException { int oid = Oid.TIMESTAMPTZ; bindString(i, connection.getTimestampUtils().toString(offsetDateTime), oid); } //JCP! endif
public void cancel() throws SQLException { connection.cancelQuery(); }
public CopyManager(BaseConnection connection) throws SQLException { this.encoding = connection.getEncoding(); this.queryExecutor = connection.getQueryExecutor(); this.connection = connection; }
if (state != STATE_IDLE || conn.getTransactionState() != ProtocolConnection.TRANSACTION_IDLE) throw new PGXAException(GT.tr("Not implemented: 2nd phase commit must be issued using an idle connection"), XAException.XAER_RMERR); localAutoCommitMode = conn.getAutoCommit(); conn.setAutoCommit(true); Statement stmt = conn.createStatement(); try conn.setAutoCommit(localAutoCommitMode);
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); } }
final int baseOid = connection.getTypeInfo().getPGArrayElement(oid); fields[0] = new Field("INDEX", Oid.INT4); fields[1] = new Field("VALUE", baseOid); byte[][] t = new byte[2][0]; String v = (String) arrayList.get(offset); t[0] = connection.encodeString(Integer.toString(offset + 1)); t[1] = v == null ? null : connection.encodeString(v); rows.add(t); Object v = arrayList.get(offset); t[0] = connection.encodeString(Integer.toString(offset + 1)); t[1] = v == null ? null : connection.encodeString(toString((PgArrayList) v)); rows.add(t); BaseStatement stat = (BaseStatement) connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); return (ResultSet) stat.createDriverResultSet(fields, rows);
this.conn = conn; this.fp = conn.getFastpathAPI(); if (conn.getMetaData().supportsSchemasInTableDefinitions()) { sql = "SELECT p.proname,p.oid " + " FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n " + " or proname = 'lo_truncate64'"; if (conn.getMetaData().supportsSchemasInTableDefinitions()) { sql += ")"; Statement stmt = conn.createStatement(); ResultSet res = stmt.executeQuery(sql); stmt.close(); conn.getLogger().log(Level.FINE, "Large Object initialised");
connection.encodeString(connection.getTimestampUtils().toString(null, (Date)valueObject)); break; connection.encodeString(connection.getTimestampUtils().toString(null, (Time)valueObject)); break; connection.encodeString(connection.getTimestampUtils().toString(null, (Timestamp)valueObject)); break; rowBuffer[columnIndex] = connection.encodeString(String.valueOf( valueObject)); break;
conn.rollback(); conn.setAutoCommit(localAutoCommitMode); conn.setAutoCommit(true); Statement stmt = conn.createStatement(); try
currentXid = null; conn.commit(); conn.setAutoCommit(localAutoCommitMode);
public String getString(int columnIndex) throws SQLException { connection.getLogger().log(Level.FINEST, " getString columnIndex: {0}", columnIndex); checkResultSet(columnIndex); if (wasNullFlag) { return connection.getTimestampUtils().timeToString((java.util.Date) obj, oid == Oid.TIMESTAMPTZ || oid == Oid.TIMETZ); Encoding encoding = connection.getEncoding(); try { return trimString(columnIndex, encoding.decode(this_row[columnIndex - 1]));
ResultSet rs = connection.execSQLQuery(sb.toString(), resultsettype, ResultSet.CONCUR_READ_ONLY); sb.append("CLOSE "); Utils.appendEscapedIdentifier(sb, cursorName); connection.execSQLUpdate(sb.toString()); ((AbstractJdbc2ResultSet)rs).setRefCursor(cursorName); return rs;
private Map<String, List<SchemaField>> getAllSchema(Connection connection, String project) throws SQLException { BaseConnection pgConnection = connection.unwrap(BaseConnection.class); Map<String, List<SchemaField>> map = new HashMap<>(); ResultSet resultSet = pgConnection.execSQLQuery(format("SELECT c.relname, a.attname, typname\n" + "FROM pg_catalog.pg_class c\n" + " JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n" + " LEFT JOIN pg_inherits i ON (i.inhrelid = c.oid)\n" + " JOIN pg_attribute a ON (a.attrelid=c.oid)\n" + " JOIN pg_type t ON (a.atttypid = t.oid)\n" + " WHERE n.nspname = '%s' and c.relkind IN ('r', 'p', '') and i.inhrelid is null\n" + " AND n.nspname <> 'pg_catalog'\n" + " AND n.nspname <> 'information_schema'\n" + " AND n.nspname !~ '^pg_toast' \n" + " AND a.attnum > 0 AND NOT a.attisdropped AND c.relname not like '\\$%%' ESCAPE '\\' and c.relname != '_users' AND a.attname != '$server_time'", checkLiteral(project))); while (resultSet.next()) { String columnName = resultSet.getString(2); FieldType fieldType; try { fieldType = fromSql(pgConnection.getTypeInfo().getSQLType(resultSet.getString(3)), resultSet.getString(3)); } catch (IllegalStateException e) { continue; } map.computeIfAbsent(resultSet.getString(1), (k) -> new ArrayList<>()).add(new SchemaField(columnName, fieldType)); } return map; }
connection.execSQLQuery(sb.toString(), resultsettype, ResultSet.CONCUR_READ_ONLY); sb.append("CLOSE "); Utils.escapeIdentifier(sb, cursorName); connection.execSQLUpdate(sb.toString()); ((PgResultSet) rs).setRefCursor(cursorName); return rs; return HStoreConverter.fromBytes(this_row[columnIndex - 1], connection.getEncoding());
currentXid = null; if (!conn.haveMinimumServerVersion("8.1")) throw new PGXAException(GT.tr("Server versions prior to 8.1 do not support two-phase commit."), XAException.XAER_RMERR); Statement stmt = conn.createStatement(); try conn.setAutoCommit(localAutoCommitMode);
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 CopyIn copyIn(String sql) throws SQLException { CopyOperation op = queryExecutor.startCopy(sql, connection.getAutoCommit()); if (op == null || op instanceof CopyIn) { return (CopyIn) op; } else { op.cancelCopy(); throw new PSQLException(GT.tr("Requested CopyIn but got {0}", op.getClass().getName()), PSQLState.WRONG_OBJECT_TYPE); } }
public synchronized Reader getCharacterStream() throws SQLException { Charset connectionCharset = Charset.forName(conn.getEncoding().name()); return new InputStreamReader(getBinaryStream(), connectionCharset); }
flags |= QueryExecutor.QUERY_ONESHOT; if (connection.getAutoCommit()) flags |= QueryExecutor.QUERY_SUPPRESS_BEGIN; connection.getQueryExecutor().execute(queries, parameterLists, handler,