Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vSFAX-009M0T-2E for pgsql-jdbc@arkaria.postgresql.org; Sun, 07 Dec 2025 13:51:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vSFAU-00DAxB-0Y for pgsql-jdbc@arkaria.postgresql.org; Sun, 07 Dec 2025 13:51:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vSFAT-00DAx3-2D for pgsql-jdbc@lists.postgresql.org; Sun, 07 Dec 2025 13:51:18 +0000 Received: from pgintl.fastcrypt.com ([149.56.129.164]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vSFAP-003bDW-0i for pgsql-jdbc@lists.postgresql.org; Sun, 07 Dec 2025 13:51:15 +0000 Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) by pgintl.fastcrypt.com (Postfix) with ESMTPSA id A93C920204 for ; Sun, 7 Dec 2025 08:51:11 -0500 (EST) Received: by mail-ot1-f51.google.com with SMTP id 46e09a7af769-7c750b10e14so1646444a34.2 for ; Sun, 07 Dec 2025 05:51:11 -0800 (PST) X-Gm-Message-State: AOJu0YwJL0o5g093xM07oX8l97ijDzGgpAj7uXAzGPD9Brb6Jrjk5G6W poi+2XBlcPG8s9ya4CK/UKXBJUn3M+a6K93UK4X88r3BMm4mvKL0CO4/yguQw7BOoorbhtKiVhu AZWX0/alsDq9AewLZT5izNV+xzcKw6WY= X-Google-Smtp-Source: AGHT+IHd91ig4zKhVbfr7eRKUCABjWFk7Kb3KUGrc7AN0OpGKLkntvMfC4OAh/X/Yxwhnd+FdzM9RdzcsYgyIDVRIQg= X-Received: by 2002:a05:6820:992:b0:659:9a49:90d5 with SMTP id 006d021491bc7-6599a99c1f8mr1654744eaf.84.1765115470884; Sun, 07 Dec 2025 05:51:10 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Dave Cramer Date: Sun, 7 Dec 2025 08:50:55 -0500 X-Gmail-Original-Message-ID: X-Gm-Features: AQt7F2qfGdRVGBJK75Ed7f98rh-uIKj8CRdR9Vf5xCuRwUsi3a2XHkKNywEDt7w Message-ID: Subject: Re: Don't see CLOSE packet been sent To: Manav Kumar Cc: pgsql-jdbc@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000a1359e06455cf800" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000a1359e06455cf800 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Please post this on github as you will get more traction https://github.com/pgjdbc/pgjdbc/issues Does seem like a bug though. Dave Cramer www.postgres.rocks On Sat, 6 Dec 2025 at 06:35, Manav Kumar wrote: > Hi Team, > Writing to ask for a follow up. Can someone please clarify. I only see > CLOSE been sent by driver when server returns an error message 'prepared > statement does not exist". > > Thanks > Manav > > On Thu, Dec 4, 2025 at 7:07=E2=80=AFPM Manav Kumar = wrote: > >> Hi Team, >> Wrote a simple below application to understand nature of CLOSE packet. >> But i don't see the JDBC sending CLOSE packet. Any ideas what i can do >> see CLOSE packet. >> I'm compiling with: >> javac -classpath /home/manavkumar/postgresql-42.7.1.jar sendClose.java &= & >> \ >> java -cp .:/home/manavkumar/postgresql-42.7.1.jar sendClose >> >> ```import java.sql.*; >> >> public class sendClose { >> >> public static void main(String[] args) { >> Connection connection =3D null; >> PreparedStatement pstmt1 =3D null, pstmt2 =3D null; >> >> try { >> // prepareThreshold=3D1 is crucial here >> connection =3D DriverManager.getConnection("jdbc:postgresql:// >> 10.150.3.175:5433/yugabyte?prepareThreshold=3D1", "yugabyte","yugabyte")= ; >> >> // --------------------------------------------------------- >> // CHANGE 1: Use placeholders (?) >> // This forces the driver to use Extended Query Protocol (Parse/Bind) >> // and create a named statement (e.g., "S_1") on the server. >> // --------------------------------------------------------- >> pstmt1 =3D connection.prepareStatement("insert into t_ values (?, ?)"); >> pstmt1.setInt(1, 1); >> pstmt1.setInt(2, 2); >> // Execute twice to ensure the driver switches to server-prepare mode >> pstmt1.execute(); >> pstmt1.execute(); >> pstmt1.execute(); >> pstmt1.execute(); >> pstmt1.execute(); >> pstmt1.execute(); >> pstmt1.execute(); >> pstmt1.execute(); >> pstmt1.execute(); >> pstmt1.execute(); >> // --------------------------------------------------------- >> // CHANGE 2: Close the statement >> // The driver now marks "S_1" as closed internally and queues the packet= . >> // --------------------------------------------------------- >> pstmt1.close(); >> >> System.out.println("Statement 1 closed. Sending Statement 2 to flush the >> buffer..."); >> >> // --------------------------------------------------------- >> // CHANGE 3: Send ANY other traffic >> // The driver will attach the buffered "CLOSE S_1" packet >> // to the front of this new request. >> // --------------------------------------------------------- >> pstmt2 =3D connection.prepareStatement("SELECT 1"); >> pstmt2.execute(); >> pstmt2.close(); >> >> connection.close(); >> } >> catch (Exception e) { >> e.printStackTrace(); >> } >> } >> } >> >> ``` >> > --000000000000a1359e06455cf800 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Please post this on github as you will get more tract= ion=C2=A0https://github= .com/pgjdbc/pgjdbc/issues

Does seem like a bug= though.

Dave Cramer
www.p= ostgres.rocks


On Sat, 6 De= c 2025 at 06:35, Manav Kumar <mku= mar@yugabyte.com> wrote:
Hi Team,
Writing to ask for a follow u= p. Can someone please clarify. I only see CLOSE been sent by driver when se= rver returns an error message 'prepared statement does not exist".=

Thanks
Manav

On Thu, Dec 4, 2025 = at 7:07=E2=80=AFPM Manav Kumar <mkumar@yugabyte.com> wrote:
Hi Team,
Wrote a s= imple below application to understand nature of CLOSE packet.
But= i don't see the JDBC sending CLOSE packet. Any ideas what i can do see= CLOSE packet.
I'm compiling with:=C2=A0
javac -cla= sspath /home/manavkumar/postgresql-42.7.1.jar sendClose.java && \java -cp .:/home/manavkumar/postgresql-42.7.1.jar sendClose
```import java.sql.*;

public class sendClose {
public static void main(String[] args) {
= Connection connection =3D null;
PreparedStatement pstmt1 =3D null, pstmt2 =3D null;

try {
// prepareThreshold=3D1 is crucial here<= /div>
connection =3D= DriverManager.getConnection("jdbc:postgresql://10.150.3.175:5433/yugabyte?prepareTh= reshold=3D1"<= span style=3D"color:rgb(180,180,180)">, "yugabyte","yugabyte")= ;

<= /span>// -----------------------------= ----------------------------
// CHANGE= 1: Use placeholders (?)
// This force= s the driver to use Extended Query Protocol (Parse/Bind)
<= span style=3D"color:rgb(180,180,180)"> // and create a named statement (e.g., "S_1") = on the server.
= // --------------------= -------------------------------------
pstmt1 <= span style=3D"color:rgb(180,180,180)">=3D connection.prepareStatement(= "insert into t_ values (= ?, ?)");
pstmt1.setInt(1, 1);
pstmt1.setInt(2, 2);
// Execute twice to ensure the driver switches to server-prepa= re mode
pstmt1.execute();
pstmt1.execute();
= pstmt1.execute();
p= stmt1.execute();
ps= tmt1.execute= ();
pst= mt1.execute(= );
pstm= t1.execute()= ;
pstmt= 1.execute();=
pstmt1= .execute();<= /span>
pstmt1<= /span>.execute();
// -------------= --------------------------------------------
// CHANGE 2: Close the statement
// The driver now marks "S_1" as closed internally and queues= the packet.
= // ----------------------= -----------------------------------
pstmt1.close();

System.out.println("Statement 1 closed. Sending Statement 2 to flush the buffer...<= span style=3D"color:rgb(232,201,187)">");

// -------------= --------------------------------------------
// CHANGE 3: Send ANY other traffic
// The driver will attach the buffered "CLOSE S_1" packe= t
// to the front of this new request= .
// ---------------------------------= ------------------------
pstmt2 =3D = connection.prepareStatement("= SELECT 1");
pstmt2.execute();
pstmt2.close();=

connectio= n.close();
}
catch (Exception e) {
e<= /span>.printStackTrace();
}
}
}

```
--000000000000a1359e06455cf800--