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 1hlkve-0006UV-3T for pgsql-sql@arkaria.postgresql.org; Fri, 12 Jul 2019 02:04:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hlkvb-0002sx-KT for pgsql-sql@arkaria.postgresql.org; Fri, 12 Jul 2019 02:04:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hlkva-0002sQ-At for pgsql-sql@lists.postgresql.org; Fri, 12 Jul 2019 02:04:50 +0000 Received: from sonic314-15.consmr.mail.bf2.yahoo.com ([74.6.132.125]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hlkvV-0007SA-IV for pgsql-sql@lists.postgresql.org; Fri, 12 Jul 2019 02:04:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1562897083; bh=z2puFfE7xk0yBVc8cEN+s+z33EaZLTkod3F7pDZD1sc=; h=Date:From:To:Subject:From:Subject; b=arBFRagfhG4Y7+LUxKt9I3bMvNKeo6WAuoKDhGTeimzL2wzkPXtOtabx3+Rix6Ynr1GAnyxHSXz+r7nNBXRAkdE9LSMz5lky/pEiOQaxz4HQRMhAXruhA75evGc1hwVq1rGB2aSdQ2I8Ac7vPZHLXvz/XhD+oiiu4s/R3I/SCLbrVMj3qmEH5OxrrrU+tnp+XkQHMfr+8/WLGdqZDbSgOk5LXfcd2gpQhT3S6LxjmhmQ5rFiO2esluS21iibwLsCqF8mL7EhGPrUzx3HMCNfyvSdFwhwAlo8CMcpi9JDzhuGiFYrKfVwYv3BqlD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lVsGxBplKqqKb9MgBDB_B.vKfldWYP Gs0293H2RXCKkMXZwK3euWs8M2Gcm.tIB99mm2hy9Jj5IyjSVki1onRsf78.Wg9J14SGW28KL3si q2nYhwHkaIrfgyZg5rI3RBOI1Zg0bFah1nSJUcXGEW4tQ4cl6ycPTlE3HaDlZiQSWw5Fbkp6pDET sKQsTX2xpMp0TqB.g4psw.sYu4ntNHXDbpyaF3Ms8hf8xJ5StB196op60xeIJ Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.bf2.yahoo.com with HTTP; Fri, 12 Jul 2019 02:04:43 +0000 Date: Fri, 12 Jul 2019 02:04:39 +0000 (UTC) From: Karen Goh To: pgsql-sql@lists.postgresql.org Message-ID: <662129345.116124.1562897079696@mail.yahoo.com> Subject: Would like to know what is the problem in my sql statement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Length: 2073 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, I hope that I am in the right forum because I am using pgAdmin4 running on Windows 10 to manage my database. However, the question I have is to do with a sql that is not working out quite right hence this forum. The error I am getting is org.postgresql.util.PSQLException: No value specified for parameter 1. at org.postgresql.core.v3.SimpleParameterList.checkAllParametersSet(SimpleParameterList.java:257) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:290) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365) at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:155) at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:118) at Controller.searchController.processRequest(searchController.java:123) at Controller.searchController.doGet(searchController.java:77) Basically, I am trying to retrieve from a table which contains the id and also the subjects as per the user input parameterValues. Here's my code snippet. Please tell me why it says no value specified for parameter 1. HashMap> tutorSubject = new HashMap>(); String sql1 = "select tutor_id, subject_name from tutor_subject where subject_name in (" + builder.deleteCharAt( builder.length() -1 ).toString() + ")"; PreparedStatement ps2 = connection.prepareStatement(sql1); rs = ps2.executeQuery(); if (rs.next()) { while(rs.next()) { // System.out.println("tutor ID=" + rs.getInt("tutor_id") + ", subjectName=" + rs.getString("subject_name")); for( Object o : subjs ) { int tutor_id = rs.getInt(1); ps2.setInt(1, tutor_id); int index = 1; for( Object o : subjs ) { ps2.setObject(index++, o ); for (int j = 0; j < tutorSubject.put(tutor_id, (ArrayList) o).size(); j++) { tutorSubject.put(tutor_id, (ArrayList) o); }