[Amazon][JDBC](11220) Parameters cannot be used with normal Statement objects, use PreparedStatements instead.
See original GitHub issueSystem information:
- OS: Windows 10
- DBeaver version: 6.1.4.201908041900
- Additional extensions: None
Connection specification:
- Database name and version: Redshift
- Driver name: By default Redshift driver available in Dbeaver
- Do you use tunnels or proxies (SSH, SOCKS, etc)?: None
Issue:
Query containing ‘?’ in the comments if giving the error that ‘Parameters cannot be used with normal Statement objects, use PreparedStatements instead.’ The error does not show up if you use the comment in the normal select query but when you have ‘with’ statement in it then it gives this error.
Query:
WITH filter_data as(
SELECT
*
FROM
table_name
WHERE col_A >= '2019-07-20 00:00:00'
and col_A <= '2019-07-21 00:00:00'
-- dummy comment containing?
)
SELECT
*
FROM
filter_data limit 10
Steps to reproduce:
- Create a with statement having a comment including ‘?’ in it
- Run the query
warning/errors/backtraces from the logs
org.jkiss.dbeaver.model.sql.DBSQLException: SQL Error [11220] [HY000]: [Amazon]JDBC Parameters cannot be used with normal Statement objects, use PreparedStatements instead. at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:134) at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeStatement(SQLQueryJob.java:467) at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.lambda$0(SQLQueryJob.java:407) at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:146) at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeSingleQuery(SQLQueryJob.java:405) at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.extractData(SQLQueryJob.java:849) at org.jkiss.dbeaver.ui.editors.sql.SQLEditor$QueryResultsContainer.readData(SQLEditor.java:2776) at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$0(ResultSetJobDataRead.java:98) at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:146) at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.run(ResultSetJobDataRead.java:96) at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$17.run(ResultSetViewer.java:3271) at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:102) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) Caused by: java.sql.SQLException: [Amazon]JDBC Parameters cannot be used with normal Statement objects, use PreparedStatements instead. at com.amazon.exceptions.ExceptionConverter.toSQLException(Unknown Source) at com.amazon.jdbc.common.SStatement.executeNoParams(Unknown Source) at com.amazon.jdbc.common.SStatement.execute(Unknown Source) at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.execute(JDBCStatementImpl.java:338) at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:131) … 12 more
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:8 (2 by maintainers)
Top GitHub Comments
It can also happen if you have --? or – ? anywhere in your script, even in the comments.
More detail… I ran into this issue by introducing a regex with question marks
regexp_replace(url, '^([^/\\?]+)([/\\?]+.*)?', '\\1')
into a complex query which included a bunch of comments. Removing all comments from the query solved the problem for me.