pgjdbc/pgjdbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feedFrom: frlzk (@frlzk) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] issue #3955: The value of backend_xmin has different transaction behaviors in JDBC and PSQL
Date: Wed, 11 Mar 2026 12:34:08 +0000
Message-ID: <[email protected]> (raw)
**Describe the issue**
Use jdbc backend_xmin has value.
Use psql backend_xmin not have value.
**Driver Version?**
42.6.0
**Java Version?**
17
**OS Version?**
ubuntu 24
**PostgreSQL Version?**
15
**To Reproduce**
Use jdbc
```
import java.sql.*;
public class AdvisoryLockExample {
public static void main(String[] args) {
String url = "jdbc:postgresql://127.0.0.1:5432/testdb";
String user = "testuser";
String password = "123456";
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
conn = DriverManager.getConnection(url, user, password);
conn.setAutoCommit(false);
System.out.println("Transaction started (auto-commit disabled).");
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT '888888 '");
if (rs.next()) {
String info = rs.getString(1);
System.out.println("info: " + info);
}
rs.close();
System.out.println("Transaction left open (idle in transaction).");
System.out.println("Press Enter to commit and exit...");
System.in.read();
conn.commit();
System.out.println("Transaction committed.");
} catch (SQLException | java.io.IOException e) {
e.printStackTrace();
if (conn != null) {
try {
conn.rollback();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
} finally {
if (rs != null) try { rs.close(); } catch (SQLException ignored) {}
if (stmt != null) try { stmt.close(); } catch (SQLException ignored) {}
if (conn != null) try { conn.close(); } catch (SQLException ignored) {}
}
}
}
```
```
SELECT * FROM pg_stat_activity WHERE query like '%8888%' \gx
```
Use psql
```
BEGIN;
SELECT '888888';
```
```
SELECT * FROM pg_stat_activity WHERE query like '%8888%' \gx
```
**Expected behaviour**
When use jdbc the backend_xmin is null
view thread (4+ 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 #3955: The value of backend_xmin has different transaction behaviors in JDBC and PSQL
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