MySQLSyntaxErrorException near “?” when trying to execute PreparedStatementMySQLSyntaxErrorException when trying to execute PreparedStatementcheck the manual that corresponds to your MySQL server version for the right syntax to use near '? and password = ?' at line 1PreparedStatement throws syntax errorUsing Java and Mysql getting exception 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 '? WHERE useridMySQL and JDBC PreparedStatement using SelectHow to insert sql query in javacom.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException with PreparedStatementWhy would JDBC-MySQL throws error in your SQL syntax though my generated query works fine?JAVA JDBC mySql Prepared statement Update queryDoes a finally block always get executed in Java?When to use LinkedList over ArrayList in Java?How can I create an executable JAR with dependencies using Maven?Java PreparedStatement complaining about SQL syntax on execute()Getting com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: SQL syntaxError while updating table com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorExceptioncom.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException Insert mysql errorWhy does PreparedStatement (JDBC) result in a MySQLSyntaxErrorException in MySQL 5.7.9?Using Java and Mysql getting exception com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:MySQLSyntaxErrorException when trying to select from sqoop
What is a common way to tell if an academic is "above average," or outstanding in their field? Is their h-index (Hirsh index) one of them?
What Kind of Wooden Beam is this
What do you call a painting on a wall?
How can I evaluate this integral
Discrete function is also a math function?
Is there precedent or are there procedures for a US president refusing to concede to an electoral defeat?
My large rocket is still flipping over
Determine if a grid contains another grid
about academic proof-reading, what to do in this situation?
Is there a word that describes the unjustified use of a more complex word?
In Futurama, how many beings has Leela slept with?
What to do when scriptures go against conscience?
How to pass query parameters in URL in Salesforce Summer 19 Release?
How can I get people to remember my character's gender?
Game artist computer workstation set-up – is this overkill?
What does にとり mean?
Simple Derivative Proof?
Does running exec do anything?
Why did the Apollo 13 crew extend the LM landing gear?
Why does sound not move through a wall?
How do I, as a DM, handle a party that decides to set up an ambush in a dungeon?
What's the 2-minute timer on mobile Deutsche Bahn tickets?
Who filmed the Apollo 11 trans-lunar injection?
Krull dimension of the ring of global sections
MySQLSyntaxErrorException near “?” when trying to execute PreparedStatement
MySQLSyntaxErrorException when trying to execute PreparedStatementcheck the manual that corresponds to your MySQL server version for the right syntax to use near '? and password = ?' at line 1PreparedStatement throws syntax errorUsing Java and Mysql getting exception 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 '? WHERE useridMySQL and JDBC PreparedStatement using SelectHow to insert sql query in javacom.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException with PreparedStatementWhy would JDBC-MySQL throws error in your SQL syntax though my generated query works fine?JAVA JDBC mySql Prepared statement Update queryDoes a finally block always get executed in Java?When to use LinkedList over ArrayList in Java?How can I create an executable JAR with dependencies using Maven?Java PreparedStatement complaining about SQL syntax on execute()Getting com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: SQL syntaxError while updating table com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorExceptioncom.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException Insert mysql errorWhy does PreparedStatement (JDBC) result in a MySQLSyntaxErrorException in MySQL 5.7.9?Using Java and Mysql getting exception com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:MySQLSyntaxErrorException when trying to select from sqoop
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm trying to execute a query using a PreparedStatement in Java.
I am getting error number 1064 when I try to execute my query (syntax error).
I have tested this in MySQL query browser with substituted values which works fine.
What's wrong with my code?
Here's the relevant code:
String query = "select MemberID, MemberName from members where MemberID = ? or MemberName = ?";
Connection conn = DriverManager.getConnection(DATABASE_URL, USERNAME, PASSWORD);
PreparedStatement s = conn.prepareStatement(query);
s.setInt(1, 2);
s.setString(2, "zen");
ResultSet rs = s.executeQuery(query);
Here's the exception I'm getting:
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 '? or MemberName
= ?' at line 1
java mysql jdbc
add a comment |
I'm trying to execute a query using a PreparedStatement in Java.
I am getting error number 1064 when I try to execute my query (syntax error).
I have tested this in MySQL query browser with substituted values which works fine.
What's wrong with my code?
Here's the relevant code:
String query = "select MemberID, MemberName from members where MemberID = ? or MemberName = ?";
Connection conn = DriverManager.getConnection(DATABASE_URL, USERNAME, PASSWORD);
PreparedStatement s = conn.prepareStatement(query);
s.setInt(1, 2);
s.setString(2, "zen");
ResultSet rs = s.executeQuery(query);
Here's the exception I'm getting:
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 '? or MemberName
= ?' at line 1
java mysql jdbc
1
give more details about the "error" - exceptions in Java have stacktraces
– Bozho
Nov 9 '10 at 6:56
Just before the executeQuery gets called I see during debugging that the parameters get substituted into the PreparedStatemet, the query becomes "com.mysql.jdbc.JDBC4PreparedStatement@6e9770a3: select MemberID, MemberName from members where MemberID = 2 or MemberName = 'zen'"
– Zen
Nov 9 '10 at 7:24
Well, you have provided your whole code. And that's the reason noone has answered - it's too long. Isolate the relevant bits and show only them.
– Bozho
Nov 9 '10 at 17:15
add a comment |
I'm trying to execute a query using a PreparedStatement in Java.
I am getting error number 1064 when I try to execute my query (syntax error).
I have tested this in MySQL query browser with substituted values which works fine.
What's wrong with my code?
Here's the relevant code:
String query = "select MemberID, MemberName from members where MemberID = ? or MemberName = ?";
Connection conn = DriverManager.getConnection(DATABASE_URL, USERNAME, PASSWORD);
PreparedStatement s = conn.prepareStatement(query);
s.setInt(1, 2);
s.setString(2, "zen");
ResultSet rs = s.executeQuery(query);
Here's the exception I'm getting:
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 '? or MemberName
= ?' at line 1
java mysql jdbc
I'm trying to execute a query using a PreparedStatement in Java.
I am getting error number 1064 when I try to execute my query (syntax error).
I have tested this in MySQL query browser with substituted values which works fine.
What's wrong with my code?
Here's the relevant code:
String query = "select MemberID, MemberName from members where MemberID = ? or MemberName = ?";
Connection conn = DriverManager.getConnection(DATABASE_URL, USERNAME, PASSWORD);
PreparedStatement s = conn.prepareStatement(query);
s.setInt(1, 2);
s.setString(2, "zen");
ResultSet rs = s.executeQuery(query);
Here's the exception I'm getting:
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 '? or MemberName
= ?' at line 1
java mysql jdbc
java mysql jdbc
edited Aug 28 '17 at 13:14
Mark Rotteveel
62.6k1479123
62.6k1479123
asked Nov 9 '10 at 6:36
ZenZen
5321810
5321810
1
give more details about the "error" - exceptions in Java have stacktraces
– Bozho
Nov 9 '10 at 6:56
Just before the executeQuery gets called I see during debugging that the parameters get substituted into the PreparedStatemet, the query becomes "com.mysql.jdbc.JDBC4PreparedStatement@6e9770a3: select MemberID, MemberName from members where MemberID = 2 or MemberName = 'zen'"
– Zen
Nov 9 '10 at 7:24
Well, you have provided your whole code. And that's the reason noone has answered - it's too long. Isolate the relevant bits and show only them.
– Bozho
Nov 9 '10 at 17:15
add a comment |
1
give more details about the "error" - exceptions in Java have stacktraces
– Bozho
Nov 9 '10 at 6:56
Just before the executeQuery gets called I see during debugging that the parameters get substituted into the PreparedStatemet, the query becomes "com.mysql.jdbc.JDBC4PreparedStatement@6e9770a3: select MemberID, MemberName from members where MemberID = 2 or MemberName = 'zen'"
– Zen
Nov 9 '10 at 7:24
Well, you have provided your whole code. And that's the reason noone has answered - it's too long. Isolate the relevant bits and show only them.
– Bozho
Nov 9 '10 at 17:15
1
1
give more details about the "error" - exceptions in Java have stacktraces
– Bozho
Nov 9 '10 at 6:56
give more details about the "error" - exceptions in Java have stacktraces
– Bozho
Nov 9 '10 at 6:56
Just before the executeQuery gets called I see during debugging that the parameters get substituted into the PreparedStatemet, the query becomes "com.mysql.jdbc.JDBC4PreparedStatement@6e9770a3: select MemberID, MemberName from members where MemberID = 2 or MemberName = 'zen'"
– Zen
Nov 9 '10 at 7:24
Just before the executeQuery gets called I see during debugging that the parameters get substituted into the PreparedStatemet, the query becomes "com.mysql.jdbc.JDBC4PreparedStatement@6e9770a3: select MemberID, MemberName from members where MemberID = 2 or MemberName = 'zen'"
– Zen
Nov 9 '10 at 7:24
Well, you have provided your whole code. And that's the reason noone has answered - it's too long. Isolate the relevant bits and show only them.
– Bozho
Nov 9 '10 at 17:15
Well, you have provided your whole code. And that's the reason noone has answered - it's too long. Isolate the relevant bits and show only them.
– Bozho
Nov 9 '10 at 17:15
add a comment |
2 Answers
2
active
oldest
votes
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 '? or MemberName = ?' at line 1
MySQL doesn't understand the meaning of ?
in the SQL query. It's indeed invalid SQL syntax. So somehow it's not been replaced by PreparedStatement
. And guess what?
PreparedStatement s = conn.prepareStatement(query);
s.setInt(1, intValue);
s.setString(2, strValue);
rs = s.executeQuery(query); // Fail!
You're overridding the prepared query with the original query! You need to call the argumentless PreparedStatement#executeQuery()
method instead of Statement#executeQuery(String)
.
PreparedStatement s = conn.prepareStatement(query);
s.setInt(1, intValue);
s.setString(2, strValue);
rs = s.executeQuery(); // OK!
Unrelated to the problem, your code is leaking resources. The DB will run out of them after several hours and your application will crash. To fix this, you need to follow the JDBC idiom of closing Connection
, Statement
and ResultSet
in the finally
block of the try
block where they're been acquired. Check the JDBC basic tutorial for more detail.
This is just for a Homework assignment, and also I truncated most of my code, I do have a method that closes all relevant resources. I tried executeQuery() it works now thanks :P
– Zen
Nov 10 '10 at 3:37
add a comment |
If you look at the javadocs for Statement
(the superclass of PreparedStatement
), the method docs for executeQuery(String)
and executeUpdate(String)
say this:
Note: This method cannot be called on a
PreparedStatement
orCallableStatement
.
That's what you are doing here: calling executeQuery(String)
from Statement
on a PreparedStatement
object.
Now since the javadocs say that you "cannot" do this, actual behavior you get is unspecified ... and probably JDBC driver dependent. In this case, it appears that the MySQL driver you are using is interpreting this to mean that you are doing the update as a non-prepared statement, so that the ?
tokens are NOT interpreted as parameter placeholder. That leads the server-side SQL parser to say "syntax error".
(It would be easier for programmers if a different unchecked exception was thrown by the MySQL driver if you did this; for example UnsupportedOperationException
. However, the standard JDBC javadocs don't say what should happen in this situation. It is up to the vendor what their drivers will do.)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4131092%2fmysqlsyntaxerrorexception-near-when-trying-to-execute-preparedstatement%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 '? or MemberName = ?' at line 1
MySQL doesn't understand the meaning of ?
in the SQL query. It's indeed invalid SQL syntax. So somehow it's not been replaced by PreparedStatement
. And guess what?
PreparedStatement s = conn.prepareStatement(query);
s.setInt(1, intValue);
s.setString(2, strValue);
rs = s.executeQuery(query); // Fail!
You're overridding the prepared query with the original query! You need to call the argumentless PreparedStatement#executeQuery()
method instead of Statement#executeQuery(String)
.
PreparedStatement s = conn.prepareStatement(query);
s.setInt(1, intValue);
s.setString(2, strValue);
rs = s.executeQuery(); // OK!
Unrelated to the problem, your code is leaking resources. The DB will run out of them after several hours and your application will crash. To fix this, you need to follow the JDBC idiom of closing Connection
, Statement
and ResultSet
in the finally
block of the try
block where they're been acquired. Check the JDBC basic tutorial for more detail.
This is just for a Homework assignment, and also I truncated most of my code, I do have a method that closes all relevant resources. I tried executeQuery() it works now thanks :P
– Zen
Nov 10 '10 at 3:37
add a comment |
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 '? or MemberName = ?' at line 1
MySQL doesn't understand the meaning of ?
in the SQL query. It's indeed invalid SQL syntax. So somehow it's not been replaced by PreparedStatement
. And guess what?
PreparedStatement s = conn.prepareStatement(query);
s.setInt(1, intValue);
s.setString(2, strValue);
rs = s.executeQuery(query); // Fail!
You're overridding the prepared query with the original query! You need to call the argumentless PreparedStatement#executeQuery()
method instead of Statement#executeQuery(String)
.
PreparedStatement s = conn.prepareStatement(query);
s.setInt(1, intValue);
s.setString(2, strValue);
rs = s.executeQuery(); // OK!
Unrelated to the problem, your code is leaking resources. The DB will run out of them after several hours and your application will crash. To fix this, you need to follow the JDBC idiom of closing Connection
, Statement
and ResultSet
in the finally
block of the try
block where they're been acquired. Check the JDBC basic tutorial for more detail.
This is just for a Homework assignment, and also I truncated most of my code, I do have a method that closes all relevant resources. I tried executeQuery() it works now thanks :P
– Zen
Nov 10 '10 at 3:37
add a comment |
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 '? or MemberName = ?' at line 1
MySQL doesn't understand the meaning of ?
in the SQL query. It's indeed invalid SQL syntax. So somehow it's not been replaced by PreparedStatement
. And guess what?
PreparedStatement s = conn.prepareStatement(query);
s.setInt(1, intValue);
s.setString(2, strValue);
rs = s.executeQuery(query); // Fail!
You're overridding the prepared query with the original query! You need to call the argumentless PreparedStatement#executeQuery()
method instead of Statement#executeQuery(String)
.
PreparedStatement s = conn.prepareStatement(query);
s.setInt(1, intValue);
s.setString(2, strValue);
rs = s.executeQuery(); // OK!
Unrelated to the problem, your code is leaking resources. The DB will run out of them after several hours and your application will crash. To fix this, you need to follow the JDBC idiom of closing Connection
, Statement
and ResultSet
in the finally
block of the try
block where they're been acquired. Check the JDBC basic tutorial for more detail.
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 '? or MemberName = ?' at line 1
MySQL doesn't understand the meaning of ?
in the SQL query. It's indeed invalid SQL syntax. So somehow it's not been replaced by PreparedStatement
. And guess what?
PreparedStatement s = conn.prepareStatement(query);
s.setInt(1, intValue);
s.setString(2, strValue);
rs = s.executeQuery(query); // Fail!
You're overridding the prepared query with the original query! You need to call the argumentless PreparedStatement#executeQuery()
method instead of Statement#executeQuery(String)
.
PreparedStatement s = conn.prepareStatement(query);
s.setInt(1, intValue);
s.setString(2, strValue);
rs = s.executeQuery(); // OK!
Unrelated to the problem, your code is leaking resources. The DB will run out of them after several hours and your application will crash. To fix this, you need to follow the JDBC idiom of closing Connection
, Statement
and ResultSet
in the finally
block of the try
block where they're been acquired. Check the JDBC basic tutorial for more detail.
answered Nov 10 '10 at 2:46
BalusCBalusC
864k30431983250
864k30431983250
This is just for a Homework assignment, and also I truncated most of my code, I do have a method that closes all relevant resources. I tried executeQuery() it works now thanks :P
– Zen
Nov 10 '10 at 3:37
add a comment |
This is just for a Homework assignment, and also I truncated most of my code, I do have a method that closes all relevant resources. I tried executeQuery() it works now thanks :P
– Zen
Nov 10 '10 at 3:37
This is just for a Homework assignment, and also I truncated most of my code, I do have a method that closes all relevant resources. I tried executeQuery() it works now thanks :P
– Zen
Nov 10 '10 at 3:37
This is just for a Homework assignment, and also I truncated most of my code, I do have a method that closes all relevant resources. I tried executeQuery() it works now thanks :P
– Zen
Nov 10 '10 at 3:37
add a comment |
If you look at the javadocs for Statement
(the superclass of PreparedStatement
), the method docs for executeQuery(String)
and executeUpdate(String)
say this:
Note: This method cannot be called on a
PreparedStatement
orCallableStatement
.
That's what you are doing here: calling executeQuery(String)
from Statement
on a PreparedStatement
object.
Now since the javadocs say that you "cannot" do this, actual behavior you get is unspecified ... and probably JDBC driver dependent. In this case, it appears that the MySQL driver you are using is interpreting this to mean that you are doing the update as a non-prepared statement, so that the ?
tokens are NOT interpreted as parameter placeholder. That leads the server-side SQL parser to say "syntax error".
(It would be easier for programmers if a different unchecked exception was thrown by the MySQL driver if you did this; for example UnsupportedOperationException
. However, the standard JDBC javadocs don't say what should happen in this situation. It is up to the vendor what their drivers will do.)
add a comment |
If you look at the javadocs for Statement
(the superclass of PreparedStatement
), the method docs for executeQuery(String)
and executeUpdate(String)
say this:
Note: This method cannot be called on a
PreparedStatement
orCallableStatement
.
That's what you are doing here: calling executeQuery(String)
from Statement
on a PreparedStatement
object.
Now since the javadocs say that you "cannot" do this, actual behavior you get is unspecified ... and probably JDBC driver dependent. In this case, it appears that the MySQL driver you are using is interpreting this to mean that you are doing the update as a non-prepared statement, so that the ?
tokens are NOT interpreted as parameter placeholder. That leads the server-side SQL parser to say "syntax error".
(It would be easier for programmers if a different unchecked exception was thrown by the MySQL driver if you did this; for example UnsupportedOperationException
. However, the standard JDBC javadocs don't say what should happen in this situation. It is up to the vendor what their drivers will do.)
add a comment |
If you look at the javadocs for Statement
(the superclass of PreparedStatement
), the method docs for executeQuery(String)
and executeUpdate(String)
say this:
Note: This method cannot be called on a
PreparedStatement
orCallableStatement
.
That's what you are doing here: calling executeQuery(String)
from Statement
on a PreparedStatement
object.
Now since the javadocs say that you "cannot" do this, actual behavior you get is unspecified ... and probably JDBC driver dependent. In this case, it appears that the MySQL driver you are using is interpreting this to mean that you are doing the update as a non-prepared statement, so that the ?
tokens are NOT interpreted as parameter placeholder. That leads the server-side SQL parser to say "syntax error".
(It would be easier for programmers if a different unchecked exception was thrown by the MySQL driver if you did this; for example UnsupportedOperationException
. However, the standard JDBC javadocs don't say what should happen in this situation. It is up to the vendor what their drivers will do.)
If you look at the javadocs for Statement
(the superclass of PreparedStatement
), the method docs for executeQuery(String)
and executeUpdate(String)
say this:
Note: This method cannot be called on a
PreparedStatement
orCallableStatement
.
That's what you are doing here: calling executeQuery(String)
from Statement
on a PreparedStatement
object.
Now since the javadocs say that you "cannot" do this, actual behavior you get is unspecified ... and probably JDBC driver dependent. In this case, it appears that the MySQL driver you are using is interpreting this to mean that you are doing the update as a non-prepared statement, so that the ?
tokens are NOT interpreted as parameter placeholder. That leads the server-side SQL parser to say "syntax error".
(It would be easier for programmers if a different unchecked exception was thrown by the MySQL driver if you did this; for example UnsupportedOperationException
. However, the standard JDBC javadocs don't say what should happen in this situation. It is up to the vendor what their drivers will do.)
answered Mar 23 at 2:25
Stephen CStephen C
530k72591950
530k72591950
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4131092%2fmysqlsyntaxerrorexception-near-when-trying-to-execute-preparedstatement%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
give more details about the "error" - exceptions in Java have stacktraces
– Bozho
Nov 9 '10 at 6:56
Just before the executeQuery gets called I see during debugging that the parameters get substituted into the PreparedStatemet, the query becomes "com.mysql.jdbc.JDBC4PreparedStatement@6e9770a3: select MemberID, MemberName from members where MemberID = 2 or MemberName = 'zen'"
– Zen
Nov 9 '10 at 7:24
Well, you have provided your whole code. And that's the reason noone has answered - it's too long. Isolate the relevant bits and show only them.
– Bozho
Nov 9 '10 at 17:15