pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
[pgjdbc/pgjdbc] issue #3763: Driver does not implement setURL() and getURL() methods
2+ messages / 2 participants
[nested] [flat]

* [pgjdbc/pgjdbc] issue #3763: Driver does not implement setURL() and getURL() methods
@ 2025-08-14 11:57  "Sudarvizhi-L (@Sudarvizhi-L)" <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Sudarvizhi-L (@Sudarvizhi-L) @ 2025-08-14 11:57 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

When using PreparedStatement.setURL(int, url) and ResultSet.getURL(url) with the PostgreSQL JDBC driver, the method throws SQLFeatureNotSupportedException stating it is not yet implemented. This makes it impossible to insert URL objects directly via the JDBC setURL and getURL method.

**Driver Version**
org.postgresql:postgresql:42.7.7

**Java Version**
OpenJDK 21 

**OS Version**
Windows 11

**PostgreSQL Version**
PostgreSQL 17.5

**To Reproduce**
Steps to reproduce the behaviour:

1. Create a table with a text column for URLs.
2. Try inserting a java.net.URL using PreparedStatement.setURL(...).
3. Observe that SQLFeatureNotSupportedException is thrown.


```java
import java.net.URL;
import java.sql.*;

public class UrlSample {
    public static void main(String[] args) throws Exception {
        String jdbcUrl = "jdbc:postgresql://localhost:5432/sampledb";
        String user = "user";
        String pass = "password";

        try (Connection conn = DriverManager.getConnection(jdbcUrl, user, pass)) {
            String createTable = "CREATE TABLE IF NOT EXISTS url_table (id SERIAL PRIMARY KEY, url_column VARCHAR(255))";
            try (Statement stmt = conn.createStatement()) {
                stmt.execute(createTable);
            }

            String insertSql = "INSERT INTO url_table (url_column) VALUES (?)";
            try (PreparedStatement pstmt = conn.prepareStatement(insertSql)) {
                URL sampleUrl = new URL("https://github.com/techatpark/rdbms-olap-practice";);
                pstmt.setURL(1, sampleUrl); // <-- Causes SQLFeatureNotSupportedException
                pstmt.executeUpdate();
            }

            String selectSql = "SELECT id, url_column FROM url_table";
            try (Statement stmt = conn.createStatement();
                 ResultSet rs = stmt.executeQuery(selectSql)) {
                while (rs.next()) {
                    int id = rs.getInt("id");
                    URL urlValue = rs.getURL("url_column");
                    System.out.println("Row " + id + ": " + urlValue);
                }
            }
        }
    }
}
```


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [pgjdbc/pgjdbc] issue #3763: Driver does not implement setURL() and getURL() methods
@ 2025-08-14 14:48  "davecramer (@davecramer)" <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: davecramer (@davecramer) @ 2025-08-14 14:48 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

Perfectly legitimate to throw a NotSupported Exception as there is no way to implement this in PostgreSQL https://docs.oracle.com/en/java/javase/17/docs/api/java.sql/java/sql/PreparedStatement.html#setURL(i...)

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2025-08-14 14:48 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-08-14 11:57 [pgjdbc/pgjdbc] issue #3763: Driver does not implement setURL() and getURL() methods "Sudarvizhi-L (@Sudarvizhi-L)" <[email protected]>
2025-08-14 14:48 Re: [pgjdbc/pgjdbc] issue #3763: Driver does not implement setURL() and getURL() methods "davecramer (@davecramer)" <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox