agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Karen Goh <karenworld@yahoo.com>
To: pgsql-sql@lists.postgresql.org
Subject: Would like to know what is the problem in my sql statement
Date: Fri, 12 Jul 2019 02:04:39 +0000 (UTC)
Message-ID: <662129345.116124.1562897079696@mail.yahoo.com> (raw)
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<Integer, ArrayList<String>> tutorSubject = new HashMap<Integer, ArrayList<String>>();
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<String>) o).size(); j++) {
tutorSubject.put(tutor_id, (ArrayList<String>) o);
}
view thread (4+ messages) latest in thread
Message-ID: <662129345.116124.1562897079696@mail.yahoo.com>
Permalink: ../662129345.116124.1562897079696@mail.yahoo.com/
Also on: postgresql.org/message-id/662129345.116124.1562897079696@mail.yahoo.com
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: karenworld@yahoo.com, pgsql-sql@lists.postgresql.org
Subject: Re: Would like to know what is the problem in my sql statement
In-Reply-To: <662129345.116124.1562897079696@mail.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox