You should execute the PrepareStatement
with no parameters as follows:
statement.executeQuery()
Calling executeQuery
with a String
parameter will execute the provided query as is (without the bound parameters).
More Related Contents:
- How to use prepared statement for select query in Java?
- Hours and seconds are lost when storing a date in the database [closed]
- Multiple queries executed in java in single statement
- Using setDate in PreparedStatement
- Java: Insert multiple rows into MySQL with PreparedStatement
- How can I get the SQL of a PreparedStatement?
- Using “like” wildcard in prepared statement
- How does a PreparedStatement avoid or prevent SQL injection?
- Variable column names using prepared statements
- MySQL and JDBC with rewriteBatchedStatements=true
- Getting java.sql.SQLException: Operation not allowed after ResultSet closed
- Running a .sql script using MySQL with JDBC
- java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/dbname [duplicate]
- mysql prepared statement error: MySQLSyntaxErrorException
- A datetime equivalent in java.sql ? (is there a java.sql.datetime ?)
- PreparedStatement IN clause alternatives?
- MySQL JDBC Driver 5.1.33 – Time Zone Issue
- How do I get the size of a java.sql.ResultSet?
- Android JDBC not working: ClassNotFoundException on driver
- What is the best approach using JDBC for parameterizing an IN clause? [duplicate]
- Reusing a PreparedStatement multiple times
- Where’s my invalid character (ORA-00911)
- Error: Client does not support authentication protocol requested by server; consider upgrading MySQL client
- Java JDBC MySQL exception: “Operation not allowed after ResultSet closed”
- Queries returning multiple result sets
- how to get list of Databases “Schema” names of MySql using java JDBC
- Access denied for user ‘root’@’localhost’
- Is there a way to retrieve the autoincrement ID from a prepared statement
- No matter what, I can’t batch MySQL INSERT statements in Hibernate
- How to connect to a remote MySQL database with Java?