JSON/JSONB:
CopyManager copyManager = ((PGConnection) conn).getCopyAPI(); String sql = "COPY users (name, email) FROM STDIN"; CopyIn copyIn = copyManager.copyIn(sql); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(copyIn)); writer.write("Alice\talice@example.com\n"); writer.write("Bob\tbob@example.com\n"); writer.close(); long rows = copyIn.getHandledRowCount(); 7.3 Logical Replication (PG 10+) PGConnection pgConn = conn.unwrap(PGConnection.class); PGReplicationStream stream = pgConn.getReplicationAPI() .replicationStream() .logical() .withSlotName("test_slot") .withSlotOption("proto_version", "1") .withSlotOption("publication_names", "mypub") .start(); while (true) ByteBuffer msg = stream.readPending(); if (msg != null) // process changes postgres jdbc driver
A type 4 JDBC driver that allows Java applications to connect to a PostgreSQL database using standard JDBC APIs. It translates JDBC calls into PostgreSQL's wire protocol (libpq). String sql = "COPY users (name