pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: sebastian.sierra@netbeam.com.co
To: pgsql-bugs@postgresql.org
Subject: BUG #13803: too many clients exception
Date: Mon, 07 Dec 2015 15:29:28 +0000
Message-ID: <20151207152928.2629.79886@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      13803
Logged by:          Sebastian Sierra
Email address:      sebastian.sierra@netbeam.com.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;
	}


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (2+ messages)  latest in thread

Message-ID: <20151207152928.2629.79886@wrigleys.postgresql.org>
Permalink:  ../20151207152928.2629.79886@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20151207152928.2629.79886@wrigleys.postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: sebastian.sierra@netbeam.com.co
  Subject: Re: BUG #13803: too many clients exception
  In-Reply-To: <20151207152928.2629.79886@wrigleys.postgresql.org>
  References: <20151207152928.2629.79886@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox