Postgresql Java Driver ((top)) -

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

String url = "jdbc:postgresql://localhost:5432/mydb"; Properties props = new Properties(); props.setProperty("user", "postgres"); props.setProperty("password", "secret"); props.setProperty("ssl", "true"); try (Connection conn = DriverManager.getConnection(url, props)) System.out.println("Connected to PostgreSQL!"); catch (SQLException e) e.printStackTrace(); postgresql java driver

// Delete try (PreparedStatement pstmt = conn.prepareStatement("DELETE FROM users WHERE id = ?")) pstmt.setLong(1, 1); pstmt.executeUpdate(); // Update try (PreparedStatement pstmt = conn

conn.setAutoCommit(false); // Required for streaming PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM large_table"); pstmt.setFetchSize(1000); // Fetch in chunks of 1000 rows try (ResultSet rs = pstmt.executeQuery()) while (rs.next()) processRow(rs); // No memory blow-up String url = "jdbc:postgresql://localhost:5432/mydb"

jdbc:postgresql://host:port/database?parameter1=value1¶meter2=value2

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


Contact us

place

Lemondim
ul. Kuropatwy 24k
02-892 Warszawa
Poland
map