BUG #13803: too many clients exception

From: sebastian(dot)sierra(at)netbeam(dot)com(dot)co
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #13803: too many clients exception
Date: 2015-12-07 15:29:28
Message-ID: 20151207152928.2629.79886@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 13803
Logged by: Sebastian Sierra
Email address: sebastian(dot)sierra(at)netbeam(dot)com(dot)co
PostgreSQL version: 9.4.0
Operating system: windows
Description:

hello, im using postgresql as my app database, but i find out it isn't
cleaning connections when i use conn.close() in java with jdbc, it clean
them but not instantly after i send this command, i find out using this
query select * from pg_stat_database; there you can see numbackends are not
closing, they stay almost 3 seconds, some times even more can you check if
it's your problem? this is the way im doing my querys List<DeviceDTO>
devices = new ArrayList<>();
Connection con = null;
try {
con = getDatasource().getConnection();
PreparedStatement ps = con.prepareStatement(getDevices);
ps.setInt(1, company);
System.out.println(ps.toString());
ResultSet rs = ps.executeQuery();
while (rs.next()) {
DeviceDTO deviceDTO = new DeviceDTO();
Device device = new Device(rs.getString("device_serial"),
rs.getInt("state"), rs.getInt("device_sleep"),
rs.getString("objecttypedescription"), rs.getString("description"),
new ArrayList<>(),
new ArrayList<>());
/**
PreparedStatement ps2 = con.prepareStatement(getMeasures);
int i = 1;
ps2.setString(i, device.getSerial());
i++;
ps2.setInt(i, company);
i++;
ps2.setString(i, dateSince);
i++;
ps2.setString(i, dateUntil);
ResultSet rs2 = ps2.executeQuery();
while (rs2.next()) {
device.getMeasures()
.add(new MeasureDTO(rs.getInt("measure_id"),
rs.getString("measure_name") + " - " +
rs.getString("measure_unit"),
rs.getDouble("value"), rs.getString("date")));
}
ps2.close();
rs2.close();*/
deviceDTO.copyDevicePOJOtoDeviceDTO(device);
devices.add(deviceDTO);

}
rs.close();
ps.close();
} catch (SQLException e) {
System.out.println("DeviceImpl sql exception on getCompanyDevices: " +
e.getMessage());
}finally {
if (null != con ) {
try {
con.close();
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
}
return devices;
}

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message pgdude 2015-12-07 16:35:20 BUG #13804: pg_restore returns unexpected error
Previous Message John R Pierce 2015-12-07 05:57:54 Re: BUG #13800: There is no UNLOAD command