pgjdbc/pgjdbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feedFrom: tract-rob (@tract-rob) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] issue #3426: 42.7.4 introduced error when binding java.io.FileInputStream
Date: Mon, 28 Oct 2024 23:27:39 +0000
Message-ID: <[email protected]> (raw)
Please read https://stackoverflow.com/help/minimal-reproducible-example
**Describe the issue**
Production code has been running error free since 2016, with the only change being regular driver upgrades. Upgrading from version 42.7.4 causes code to error...rolling back to 42.7.3 fixes the issue.
The code is binding a java.io.FileInputStream via Anorm 2.5.3. Looking at Anorm source code it looks like it's bound using PreparedStatement.setBinaryStream. The exception returned when the statement is executed is:
org.postgresql.util.PSQLException: Unable to bind parameter values for statement.
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:394)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:517)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:434)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:194)
at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:155)
at com.zaxxer.hikari.proxy.PreparedStatementProxy.executeUpdate(PreparedStatementProxy.java:61)
at com.zaxxer.hikari.proxy.PreparedStatementJavassistProxy.executeUpdate(PreparedStatementJavassistProxy.java)
...
**Driver Version?**
42.7.4
**Java Version?**
openjdk version "1.8.0_412"
**OS Version?**
Amazon Linux 2
**PostgreSQL Version?**
15.8
**To Reproduce**
Steps to reproduce the behaviour:
1. Bind a java.io.FileInputStream object to e PreparedStatement using setBinaryStream.
2. call executeUpdate
**Expected behaviour**
A clear and concise description of what you expected to happen.
And what actually happens
For the last 8 years it's always successfully inserted the file into the database table. After driver upgrade, it just throws an error "Unable to bind parameter values for statement."
**Logs**
If possible PostgreSQL logs surrounding the occurrence of the issue
Additionally logs from the driver can be obtained adding
Using the following template code make sure the bug can be replicated in the driver alone.
```
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;
public class TestNullsFirst {
public static void main(String []args) throws Exception {
String url = "jdbc:postgresql://localhost:5432/test";
Properties props = new Properties();
props.setProperty("user", "test");
props.setProperty("password", "test");
try ( Connection conn = DriverManager.getConnection(url, props) ){
try ( Statement statement = conn.createStatement() ) {
try (ResultSet rs = statement.executeQuery( "select lastname from users order by lastname asc nulls first") ){
if (rs.next())
System.out.println( "Get String: " + rs.getString(1));
}
}
}
}
}
```
view thread (14+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: github://pgjdbc/pgjdbc
Cc: [email protected], [email protected]
Subject: Re: [pgjdbc/pgjdbc] issue #3426: 42.7.4 introduced error when binding java.io.FileInputStream
In-Reply-To: <<[email protected]>>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox