aspose file tools*
The moose likes JDBC and the fly likes PreparedStatement fails to execute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "PreparedStatement fails to execute " Watch "PreparedStatement fails to execute " New topic

PreparedStatement fails to execute

olze oli
Ranch Hand

Joined: Jun 20, 2009
Posts: 148

i created a prepared statement with a simple select, but it wont be executed:

The error message is:
org.postgresql.util.PSQLException: FEHLER: Syntaxfehler am Ende der Eingabe
Position: 52
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(
at org.postgresql.core.v3.QueryExecutorImpl.processResults(
at org.postgresql.core.v3.QueryExecutorImpl.execute(
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(

I have no idea whats wrong with that query. Can please someone explain me what the problem is?

Syntaxfehler am Ende der Eingabe means: Syntax Error at the end of the input.
Ed Ward
Ranch Hand

Joined: Jan 30, 2006
Posts: 147
Where did "stmt" come from?
You sure you do not want to do prepStmt.executeQuery() since you went through the trouble of prepping it?
stmt.executeQuery(sql) in your code is attempting to execute the raw SQL statement, with the ? which has not yet been set.

Least, looks that way to me.
olze oli
Ranch Hand

Joined: Jun 20, 2009
Posts: 148
You have been right... thanks
I had a normal Statement (stmt) and a PreparedStatement (prepStmt).
I agree. Here's the link:
subject: PreparedStatement fails to execute
Similar Threads
onetoone unidirectional relationship problem
Weired error comes while using stored procedure with hibernate
Error Calling stored procedure from my java codes.
[RESOLVED] jasper & iReport multi-reports
How to Escape single quotes with PreparedStatment while using PostGresql?