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 1vRqZc-006Xir-0N for pgsql-jdbc@arkaria.postgresql.org; Sat, 06 Dec 2025 11:35:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vRqZa-00BYp3-1C for pgsql-jdbc@arkaria.postgresql.org; Sat, 06 Dec 2025 11:35:34 +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 1vRqZZ-00BYov-2l for pgsql-jdbc@lists.postgresql.org; Sat, 06 Dec 2025 11:35:34 +0000 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vRqZX-003QrD-15 for pgsql-jdbc@lists.postgresql.org; Sat, 06 Dec 2025 11:35:33 +0000 Received: by mail-qk1-x732.google.com with SMTP id af79cd13be357-8b2ed01ba15so234129385a.1 for ; Sat, 06 Dec 2025 03:35:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yugabyte.com; s=google; t=1765020931; x=1765625731; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=K5UM2VGgbfef3kZJ0eYZ3Rb1bIzkaJAPTRqsqs2oH4M=; b=WZFOf11gVncXoUktUbasr9SS0p1y854r/KyMuIevVtBrAkoOSk6JubfEc4P0SH8YPV USMRdFr0Wzu10/AMDKd68yLOhoUAMrriCt3htoyihvkrT3Q+M4N9p/sxxqPU/UY6HlyK FohsVPTGRWvViVSEDSAIzxdzhA2TnCMZ8YFNQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765020931; x=1765625731; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=K5UM2VGgbfef3kZJ0eYZ3Rb1bIzkaJAPTRqsqs2oH4M=; b=f2lrmAadjoz3nMdfXC71y8MYVxVivdLc9RSUyiYMTyiQ3lpMu2bFX4YdTHJyIjv94G WlEJxtsg1w1to2OLGpUfgmKPBXW28QLU7a7yP7zFviV3SPSWbQFQkgrBpFjA8ZnDCANB Fh5riSOEYhQXlvsLnu81Wlc9lR0ES4LSf2vefAdL7c89a00xfn5Lhvcpwvzdu3Zup/pu h6mHqaagzbesHFs9hAarsswnc+igmRedaTWXpL6EmBJ++56pyzMldTyDTMKBfiL3ThD1 rwo9BwpbkK476H10TXI5JZM3f2NhNKy3TUbABx8c+PC8BNvhkrdkw9zzh/bzPCuxZcG8 ejUw== X-Gm-Message-State: AOJu0YzKX4VJOKh/9iqjBqhrpiP0SflgE8PHwqwZx1mhemSdb+9H0DBI VfqR5DWgvDvicysi48B4iPssmwE5jTKmKwbLlD81WPrjuaImllFKCh8FOebHb470t1v77U7rhm3 Y6QgPKhtP0dk8tgUANpV+RTd5NrAYk7EIrpzvlnw24j+OMsX2dtww X-Gm-Gg: ASbGnctRFOSvc8cTXLWNgGcHU+K+ziPbRU9ACVtKPOpFapxP1novot5QzCrlBk6lPXN kczCRC5we/yiSK/V348EzJNhclkGICzA5U+h+qcEJ3yxDFn1mmbXuvfDYF9H4ETVXXmd8kxbMu+ CIaCj/FBFGADP0XekEwL9+o54PlDtZO6mNKxEfAJW+t3zusmMEnOJRu4nx83GwoITj6oc0gSndc ZZKYu8vYC2he6BeRe1chrXmktIKoIgDVpsiIFZ9ysNdgVq4UIAAe2nOPbxNk4w/rt6SQ8Z1 X-Google-Smtp-Source: AGHT+IGNfyu5IxSINLr7cvzXRtmPLEMSzR7fbMCMvdO6FOdQaMpLxTJXHhd5MjDE2jEUKD+mThoamNXePal0e3fKdiA= X-Received: by 2002:a05:620a:1a2a:b0:89f:2d97:98fd with SMTP id af79cd13be357-8b6a2348dacmr283873285a.2.1765020930956; Sat, 06 Dec 2025 03:35:30 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Manav Kumar Date: Sat, 6 Dec 2025 17:05:19 +0530 X-Gm-Features: AQt7F2pcnV0AxaU6fs0GsOlvSp055PEETZMK8OnofTq35O7auQmMnIvJlOkyUxw Message-ID: Subject: Re: Don't see CLOSE packet been sent To: pgsql-jdbc@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000009c6e83064546f5ca" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000009c6e83064546f5ca Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 wr= ote: > 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 se= e > 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(); > } > } > } > > ``` > --0000000000009c6e83064546f5ca Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Team,
Writing to ask for a follow up. Can someone p= lease clarify. I only see CLOSE been sent by driver when server returns an = error message 'prepared statement does not exist".

<= /div>
Thanks
Manav

On Thu, Dec 4, = 2025 at 7:07=E2=80=AFPM Manav Kumar <mkumar@yugabyte.com> wrote:
Hi Team,
Wrote a simple below a= pplication 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 -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 sen= dClose {

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

try {
// prepareThreshold=3D1 is crucial here
= connection =3D DriverManager.getConnect= ion("jd= bc:postgresql://10.150.3.175:5433/yugabyte?prepareThreshold=3D1", &q= uot;yugabyte","yugabyte");
// ------------------------------------------= ---------------
= // CHANGE 1: Use place= holders (?)
= // 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 (?, ?)<= span style=3D"color:rgb(232,201,187)">");
pstmt1.setInt(1, 1);
= pstmt1.setI= nt(2,= 2);
= // Execute twice to ensure the driver switches to server-prepare mode
pstmt1.execute();=
pstmt1.execute();=
pstmt1= .execute();<= /div>
pstmt1<= span style=3D"color:rgb(180,180,180)">.execute();
pstmt1.execute();
pstmt1.execute();
pstmt1.execute();
pstmt1.execute();
=
pstmt1.execute();
<= div> pstmt1.execute();
= // --------------------------= -------------------------------
// CHA= NGE 2: Close the statement
// The driv= er now marks "S_1" as closed internally and queues the packet.
// -------------------------------------= --------------------
pstmt1.<= span style=3D"color:rgb(220,220,170)">close();

System.out.println= ("Statement 1 = closed. Sending Statement 2 to flush the buffer...");=

// ------------------------------= ---------------------------
// CHANGE = 3: Send ANY other traffic
// The drive= r will attach the buffered "CLOSE S_1" packet
<= span style=3D"color:rgb(180,180,180)"> // to the front of this new request.
// ------------------------------------------------------= ---
pstmt2 =3D connection.prepareStatement("SELECT 1&qu= ot;);
= pstmt2.execut= e();
= pstmt2.close();

= connection.= close();
= }
catch (Exception = e) {
e.= printStackTrace();
}
= }
}

```
--0000000000009c6e83064546f5ca--