Re: JDBC drive 42 release breaks seriously for RETURNING?

From: Tom Smith <tomsmith1989sk(at)gmail(dot)com>
To: Dave Cramer <pg(at)fastcrypt(dot)com>
Cc: Jorge Solórzano <jorsol(at)gmail(dot)com>, List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: JDBC drive 42 release breaks seriously for RETURNING?
Date: 2017-06-17 23:15:31
Message-ID: CAKwSVFFjEL+0TMS22jZFQvr7A79u9KP0dXScFrAOOtrKB9_9ZQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Also, pg server 9.4

On Sat, Jun 17, 2017 at 7:14 PM, Tom Smith <tomsmith1989sk(at)gmail(dot)com> wrote:

> I was using jar from maven 42.1.1
>
> On Sat, Jun 17, 2017 at 6:25 PM, Dave Cramer <pg(at)fastcrypt(dot)com> wrote:
>
>> I just tested this:
>>
>> public class TestReturning {
>>
>> public static void main(String[] args) throws Exception {
>> try(Connection c = DriverManager.getConnection("jdbc:postgresql://localhost:5432/test", "test", "");
>> Statement stmt = c.createStatement())
>> {
>> stmt.execute("create table if not exists transportation_point(id serial primary key, address text, returning_allowed bool)");
>> try (
>> PreparedStatement ps3 = c.prepareStatement("insert into transportation_point values (nextval('transportation_point_id_seq'), 'foo')", new String[]{"id"} )) {
>> ps3.executeUpdate();
>> ResultSet rs3 = ps3.getGeneratedKeys();
>> if (rs3.next()) {
>> System.out.println("New Id: " + rs3.getInt(1));
>> }
>> else {
>> throw new RuntimeException("No Generated Keys for ps3");
>> }
>> }
>> finally {
>> stmt.execute("drop TABLE transportation_point");
>> stmt.close();
>> }
>> }
>> }
>> }
>>
>>
>> and it worked fine. This is using the latest code from github
>>
>>
>> Dave Cramer
>>
>> davec(at)postgresintl(dot)com
>> www.postgresintl.com
>>
>> On 17 June 2017 at 16:53, Dave Cramer <pg(at)fastcrypt(dot)com> wrote:
>>
>>> Certainly not intended. Thanks for the report!
>>>
>>> Dave Cramer
>>>
>>> davec(at)postgresintl(dot)com
>>> www.postgresintl.com
>>>
>>> On 17 June 2017 at 16:40, Tom Smith <tomsmith1989sk(at)gmail(dot)com> wrote:
>>>
>>>> Something like below
>>>>
>>>> sqlInsert = "insert into aTable ((select nextval()), "stringdata")
>>>> pstmt connection.prepareStatement(sqlInsert, new String[]{"id"})
>>>> pstmt.executeUpdate()
>>>> resultSet = pstmt.getGeneratedKeys() ---> resultset is empty
>>>> using 42 series, but one row returned using 94. series
>>>>
>>>> On Sat, Jun 17, 2017 at 2:58 PM, Jorge Solórzano <jorsol(at)gmail(dot)com>
>>>> wrote:
>>>>
>>>>> Hello Tom:
>>>>>
>>>>> Could you please provide an example code that reproduce the issue?
>>>>>
>>>>> Jorge Solórzano
>>>>>
>>>>>
>>>>> On Sat, Jun 17, 2017 at 10:38 AM, Tom Smith <tomsmith1989sk(at)gmail(dot)com>
>>>>> wrote:
>>>>>
>>>>>> Hello:
>>>>>>
>>>>>>
>>>>>> I have a working call using
>>>>>>
>>>>>> connection.prepareStatement(sqlInsert, generatedIds)
>>>>>>
>>>>>> and get the expected resultset after insertion using 9.4 series
>>>>>> driver.
>>>>>> I just upgraded to 42 series latest, it is not getting the resultset
>>>>>> anymore.
>>>>>>
>>>>>> I downgraded to 9.4 drive and it worked again. It is a bit shocking.
>>>>>> Is it a bug or change?
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Tom Smith 2017-06-18 01:20:20 Re: JDBC drive 42 release breaks seriously for RETURNING?
Previous Message Tom Smith 2017-06-17 23:14:24 Re: JDBC drive 42 release breaks seriously for RETURNING?