I have integrated jooq with spring and for all types of querying to the database (MySQL), I am using JDBC Template of spring. jooq library is used here to generate the sql query to pass to jdbc template.
Though my rest of the query works fine until I add limit and/or offset to the query.
I am generating query as follows:
create.select(Factory.field("table_name"))
.from("tables t")
.where("t.table_schema LIKE '" + schemaName + "'")
.limit(10)
.offset(2)
.getSQL();
I am getting error as follows:
org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [select table_name from tables t where (t.table_schema LIKE 'test') limit ? offset ?]; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? offset ?' at line 1
Which clearly says that the values passed to limit and offset method are not appended to the query.
I searched on the documentation but not found any other way to achieve this.