Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZOcW0-0001E7-HM for pgsql-jdbc@arkaria.postgresql.org; Mon, 10 Aug 2015 02:08:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZOcW0-0005bx-3i for pgsql-jdbc@arkaria.postgresql.org; Mon, 10 Aug 2015 02:08:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZOcVW-0004uw-7S for pgsql-jdbc@postgresql.org; Mon, 10 Aug 2015 02:08:10 +0000 Received: from mail-io0-x234.google.com ([2607:f8b0:4001:c06::234]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZOcVT-0003xr-BX for pgsql-jdbc@postgresql.org; Mon, 10 Aug 2015 02:08:09 +0000 Received: by ioeg141 with SMTP id g141so156598100ioe.3 for ; Sun, 09 Aug 2015 19:08:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=DhasRW+ip9S/tOZlnCYzySV1siFi2C7CucRRV7ZMz90=; b=C+wxnP9n/RNrxvJLgaQwpBuRtJoyBUQLS+KCGc+ZgEBl+MbXogFZU9aDyiDkI16fAO oz3zAvfioTW957nkbSwg8ToIhZNqPuKBrE+Vvp5O1niTN1qn2VilcKj4+tSe6f1utRbx aDXNXxak9nONnIeRTh0i4peGjDHgWXP3L63BxIAWaGEEqTflboPfEMeg30Fmzo92Ew6b VOk8iNiVXbRV7V4n36D0b+Gl/N+6ktPSIavy1zYinIinDbIULLwt32813POc3B6PsYFH C+ehMr0peX9zyUciWJAIgpJ00ptjvVWvvsi3RhSTfEQlW1Mx4zgmzuIae+GMDJD8diM8 kBvA== X-Received: by 10.107.13.201 with SMTP id 192mr19263630ion.70.1439172485491; Sun, 09 Aug 2015 19:08:05 -0700 (PDT) Received: from [18.189.11.37] (dhcp-18-189-11-37.dyn.MIT.EDU. [18.189.11.37]) by smtp.googlemail.com with ESMTPSA id v18sm4915992igr.3.2015.08.09.19.08.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Aug 2015 19:08:04 -0700 (PDT) Message-ID: <55C80783.70703@gmail.com> Date: Sun, 09 Aug 2015 22:08:03 -0400 From: =?UTF-8?B?IkdhYnJpZWwgRS4gU8OhbmNoZXogTWFydMOtbmV6Ig==?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Bad value for type int Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Hello everyone, Is there a known bug that makes the postgres JDBC driver treat long variables as int variables, in the context of prepared statements? I am getting the following error: org.postgresql.util.PSQLException: Bad value for type int : 2759496100 while executing a prepared statement with the following Java code: StringBuilder sb = new StringBuilder(); sb.append("SELECT * FROM table "); sb.append("WHERE timestamp BETWEEN ? AND ? "); sb.append("AND id IN ( "); for (int i = 0; i < ids.size() - 1; i++) { sb.append("?, "); } sb.append("? );"); final String query = sb.toString(); try (Connection c = db.getConnection()) { PreparedStatement p = c.prepareStatement(query); p.setDate(1, new java.sql.Date(startDate.getTime())); p.setDate(2, new java.sql.Date(endDate.getTime())); for (int i = 0; i < ids.size(); i++) { int arg = 3 + i; long id = ids.get(i); p.setLong(arg, id); } ResultSet r = p.executeQuery(); This code is being executed by tomcat7 on Ubuntu 14.04, and I am using the current version of the driver, 9.4-1201. The query executes well on pgAdmin in all cases, and in tomcat7 only when all the long ids are in the int range. Help will be greatly appreciated! Regards, Gabriel -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc