Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i4fpb-0000kb-GD for pgsql-jdbc@arkaria.postgresql.org; Mon, 02 Sep 2019 06:28:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i4fpZ-00013l-Mb for pgsql-jdbc@arkaria.postgresql.org; Mon, 02 Sep 2019 06:28:49 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1i4fpZ-00013e-66 for pgsql-jdbc@lists.postgresql.org; Mon, 02 Sep 2019 06:28:49 +0000 Received: from sonic303-1.consmr.mail.bf2.yahoo.com ([74.6.131.40]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i4fpS-0002CG-8G for pgsql-jdbc@lists.postgresql.org; Mon, 02 Sep 2019 06:28:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1567405719; bh=z3sAs3A6KIUfkswUoJ8wBjFgtkEPcrQjJCXGt8HRI28=; h=Date:From:To:Subject:From:Subject; b=n0hwXSlgUjomMEdZexiE/FykwAVdAytJIBujmvvhHZgsQRJcj9ajZ49Tiv/mLnu5QYZra8VtGTCWjFKS62dkOYow931VZ71qRZAV6Ke3xSitWWDIoaPgnUWeK8LFmVFxXM5b3nr/LbpyRjHW6KtxnN7ev9NvCjMjg0TJeDqnX5ikqW9Q1Yji5naRDtUaRtC//4YIs19KX+d7zgjLxPdpe5hY5p8OlEzcsm8E7qo9eoh+qHuR/PTh9BFQqgXw6pJtZE0rDrqWt++w4CqruqpB8NXvAQ/DDA/kDNfYFMMkAIMtNFtc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i4.cglANx76RQXcSvHTfpTl0vnhRLc BQMNGmAtipfKsdkNtOjW9v_eqWL37k91Xu7y46vXf4lgHZjH48QcBHNED2EliIxthFGWc0g7r5uB UmrSGluCbB6HoNj3ma5TN7HorqC94YUusq_1f49RzkesBynB._wW4WmiMWJ_gTJjOQCkGkVXxqBw ee9Hj2c20YW1cIIxVuo_Yv7TtI4jnlosiiZ2f79kGDboRDN9qt3LZlDgLcaj2jpFzI6_bl3Riylf uKHRQHGs- Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.bf2.yahoo.com with HTTP; Mon, 2 Sep 2019 06:28:39 +0000 Date: Mon, 2 Sep 2019 06:28:34 +0000 (UTC) From: Karen Goh To: pgsql-jdbc@lists.postgresql.org Message-ID: <932079842.712590.1567405714491@mail.yahoo.com> Subject: how to resolve org.postgresql.util.PSQLException: ResultSet not positioned properly, perhaps you need to call next. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Length: 2219 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi experts, I have been trying to find a solution in the internet but there is only 1 solution offered by stackoverflow in which the user uses if it is not there then use a else to print out there is no more data/row that appeared in that column. Basically, I was trying to get a List which meet certain search condition so the data will come from 2 tables - one of which is a column from a join table and the List falls under this table. So, here's the code that I attempt to get the data out but keep getting ResultSet not positioned properly. String[] subjectNames = request.getParameterValues("txtsubjects"); String zipcode = request.getParameter("location"); List subjList = new ArrayList(Arrays.asList(subjectNames)); List myList = new ArrayList<>(); ArrayList subList = new ArrayList<>(); CopyOnWriteArrayListnewSub = new CopyOnWriteArrayList(); tutor t = new tutor(); String sql1 = "select t.tutor_contact_no, t.zipcode, t.tutor_id, t2.subject_name FROM s_tutor t JOIN tutor_subject t2 ON t.tutor_id = t2.tutor_id where t.zipcode = ? And t2.subject_name = Any((?))"; PreparedStatement ps2 = connection.prepareStatement(sql1); ps2.setString(1, zipcode); for (int i = 0; i < subjectNames.length; i++) { Array array = connection.createArrayOf("text", subjList.toArray()); ps2.setArray(2, array); } ResultSet rs = ps2.executeQuery(); while (rs.next()) { t.setContactNo(rs.getString("tutor_contact_no")); t.setZipcode(rs.getString("zipcode")); t.settutor_id(rs.getInt("tutor_id")); for (String s: subjList) if (s.contains(rs.getString("subject_name"))) subjList.add(rs.getString("subject_name")); newSub.addAll(subjList); } myList.add(t); request.setAttribute("tutors", myList); request.setAttribute("sub", newSub); Please. I hope someone can tell me what's wrong with the code or how to overcome this error...I have been struggling for 2 weeks already. Thanks. } myList.add(t); request.setAttribute("tutors", myList); request.setAttribute("sub", newSub);