Postgresql Java: Driver

try (Statement stmt = conn.createStatement()) stmt.execute("LISTEN my_channel"); // Wait for notifications while (true) PGNotification[] notifications = conn.unwrap(PGConnection.class).getNotifications(1000); if (notifications != null) for (PGNotification notification : notifications) System.out.println("Received: " + notification.getParameter());

// Update try (PreparedStatement pstmt = conn.prepareStatement("UPDATE users SET name = ? WHERE id = ?")) pstmt.setString(1, "Alice B."); pstmt.setLong(2, 1); pstmt.executeUpdate(); postgresql java driver

for (int i = 0; i < 10000; i++) pstmt.setString(1, "data" + i); pstmt.addBatch(); try (Statement stmt = conn

When fetching millions of rows, avoid OutOfMemoryError by streaming. for (int i = 0

PostgreSQL supports asynchronous messaging. The JDBC driver can listen for notifications.