This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes MySQL query and JDBC using Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MySQL query and JDBC using "LIMIT"" Watch "MySQL query and JDBC using "LIMIT"" New topic
Author

MySQL query and JDBC using "LIMIT"

Walt Hoeltzer
Greenhorn

Joined: Apr 05, 2004
Posts: 2
I'm not sure if this is in the correct category, but I have a problem from a combination of things that are going on and I'm not sure where the problem actually exists. I was hoping for some insight.
We are using Tomcat to call a servlet that uses JDBC to connect to a MySql database. The problem is in the query.
When I submit the following, I get an error:
SELECT *
FROM table
WHERE col1 = "A1"
LIMIT 0,1
The error is:
HTTP/1.1 400 Communication link failure, message from server: "Unknown command"
However, when I changed the query and removed the "LIMIT 0,1" I don't get the error.
SELECT *
FROM table
WHERE COL1 = "A1"
LIMIT is specific to MySQL and I was wondering if anyone else had run across this issue and how they got around it. I need to extract a specific row from within the result set and I was hoping to do this through the query.
The error seems to be directly related to the query and the LIMIT, but I can't understand why. I've tried other clauses (ORDER BY and HAVING) with no problems.

Any ideas about how to get around this or why this is happening?
Is this a JDBC issue? Is this a MySQL issue? Or is this a Tomcat issue?
Thanks in advance.
Walt Hoeltzer
Greenhorn

Joined: Apr 05, 2004
Posts: 2
It appears that this is not a Java or JDBC issue. It's related to the connector/j from MySQL.

Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: MySQL query and JDBC using "LIMIT"
 
Similar Threads
No results in query using JDBC, works in Db
Hibernate SQL error
Invalid MySQL syntax when using 'select new list()'
MySQL error
Update with subquery