Results 1 to 5 of 5
- 11-11-2011, 01:17 AM #1
Member
- Join Date
- Oct 2011
- Posts
- 27
- Rep Power
- 0
SQL statement working in one class but not another
Hi i have this SQL statement
and this errorJava Code:ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM Users Where "+searchType+" = '"+searchText+"'");
SQLException: 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 'Name = 'Danny'' at line 1
searchType can be First Name or Second name from a Combo box using String searchType = (String) Cbsearchby.getSelectedItem();
and searchText something type in by user take using getText
yes i have the exact same line in another class that works fine any pondering on the situation?
Thanks
- 11-11-2011, 01:19 AM #2
Re: SQL statement working in one class but not another
Use a PreparedStatement instead.
- 11-11-2011, 01:22 AM #3
Member
- Join Date
- Oct 2011
- Posts
- 27
- Rep Power
- 0
Re: SQL statement working in one class but not another
can you use Prepared-statement for Query
- 11-11-2011, 01:22 AM #4
Re: SQL statement working in one class but not another
Did you read about it in the Java API?
- 11-11-2011, 01:35 AM #5
Member
- Join Date
- Oct 2011
- Posts
- 27
- Rep Power
- 0
Similar Threads
-
Java, if statement calling class
By illinit in forum New To JavaReplies: 5Last Post: 08-25-2011, 08:04 PM -
Problem understanding class statement.
By martijnburger in forum New To JavaReplies: 3Last Post: 07-21-2011, 11:07 PM -
oracle update statement within the resultset is not working.pls see code.
By renu in forum New To JavaReplies: 1Last Post: 05-17-2011, 09:43 AM -
if statement with strings not working... again
By hardcorebadger in forum New To JavaReplies: 4Last Post: 01-11-2011, 06:02 AM -
Update statement not working.
By OMFGITSROHIT in forum JDBCReplies: 5Last Post: 04-08-2010, 01:03 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks