question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Amazon][JDBC](11220) Parameters cannot be used with normal Statement objects, use PreparedStatements instead.

See original GitHub issue

System 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:

  1. Create a with statement having a comment including ‘?’ in it
  2. 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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
Azizimjcommented, Jun 5, 2020

It can also happen if you have --? or – ? anywhere in your script, even in the comments.

1reaction
jdefontescommented, Jul 30, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When should we use a PreparedStatement instead of a ...
AccountID ; [Amazon][JDBC](11220) Parameters cannot be used with normal Statement objects, use PreparedStatements instead.
Read more >
Google Analytics Query Explorer Error - SnapLogic Community
Reason: [Amazon]JDBC Parameters cannot be used with normal Statement objects, use PreparedStatements instead. The error is always at a random ...
Read more >
Using prepared statement support - Amazon Redshift
A prepared statement is a SQL statement that is compiled on the server side but not run immediately.
Read more >
Using Prepared Statements - JDBC Basics - Oracle Help Center
Although you can use PreparedStatement objects for SQL statements with no parameters, you probably use them most often for SQL statements that take...
Read more >
Using Prepared Statements
You will need to supply values to be used in place of the question mark placeholders, if there are any, before you can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found