java.sql.SQLSyntaxErrorException Unknown column
Confluence User - 23 Apr, 2021
Trying to run a SQL query in Java Bean Shell validator however the SQL seems wrong:
PreparedStatement stmt = con.prepareStatement("SELECT * from app_fd_hotdesk_reservation where reservationDate=? and rsrvTimeSlotStart=? and selectedHotdesk=?");
stmt.setObject(1, strreservationDate);
stmt.setObject(2, strrsrvTimeSlotStart);
stmt.setObject(3, strselectedHotdesk);
ResultSet rs = stmt.executeQuery();
The log shows:
ERROR 21 Apr 2021 02:20:13 org.joget.apps.form.lib.BeanShellValidator - jwc_kennyfpk : Error executing script 289Sourced file: inline evaluation of: ``import java.sql.Connection; import java.sql.PreparedStatement; import java.sql . . . '' : Typed variable declaration : Method Invocation stmt.executeQuery : at Line: 46 : in file: inline evaluation of: ``import java.sql.Connection; import java.sql.PreparedStatement; import java.sql . . . '' : stmt .executeQuery ( ) 290Target exception: java.sql.SQLSyntaxErrorException: (conn=112271973) Unknown column 'reservationDate' in 'where clause' 291 at bsh.BSHMethodInvocation.eval(Unknown Source)
I checked the column name and it seems correct. Is the field naming convention wrong?
The Advanced Tools shows the table only as 12 fields/columns. Could it be table field limit?
forms;database;table-name;field