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

2


23 Apr, 2021
confluenceUser
1
confluenceUser

The error says "Unknown column 'reservationDate'", do try "c_reservationDate" field name. Joget form table columns is prefix with "c_fieldname".

23 Apr, 2021
confluenceUser
confluenceUser

Alright, my SQL works now.

Awesome! Thanks, I must've missed that bit of info about field name conventions in the Knowledge Base.

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print