Skip to content
Advertisement

SQLException: Column not found

My sql query should take all the fields from the table and transfer them to the FTL page using the UserMapper template. The template indicates which object to create and to which fields of the object which table columns to match.

In summary: all the fields work correctly, but the seanceNumber field gives the error “Column ‘seanceNumber’ not found”.

This is strange, because column is correct, everywhere data type is int.

Table:

JavaScript

FTL:

JavaScript

SQL:

JavaScript

UserMapper:

JavaScript

Result:

Message Request processing failed; nested exception is org.springframework.jdbc.UncategorizedSQLException: StatementCallback; uncategorized SQLException for SQL [SELECT * FROM client]; SQL state [S0022]; error code [0]; Column ‘seanceNumber’ not found.; nested exception is java.sql.SQLException: Column ‘seanceNumber’ not found.

Checked for typos too. What am I doing wrong?

Advertisement

Answer

The problem was solved by renaming the column ‘seanceNumber’ to ‘seancenumber’ in the table.

“Column names in SQL are usually case-insensitive – so it doesn’t matter whether you ask for seance or SEANCE or SeAnCe. However, if you put the column names in double quotes, they become case sensitive – I guess your UserMapper did exactly that and asked for a column named “seanceNumber”, and the database couldn’t find it (since it’s called seancenumber or SEANCENUMBER in the database).”

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement