Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table in MySQL wih title and description and I want to search for rows by word that is in some of these fields.
So , I added this to my table :
ALTER TABLE test_table ADD FULLTEXT(title,description);

and test with this query :
SQL
SELECT * FROM defects WHERE MATCH(title,description) AGAINST ('strawberry') ;


And it works :)

Now , I want to write this select with preparedStatement , but don't now how .

I tried with
Java
PreparedStatement preparedStatement = connection.
	                    prepareStatement("select * from defects where WHERE MATCH(title,description) AGAINST (?) ;");
	            preparedStatement.setString(1, searchedword);
	            ResultSet rs = preparedStatement.executeQuery();

but it's wrong. Sorry for stuped question but I really don't know how is right
Posted
Updated 13-Sep-13 7:19am
v2
Comments
Shubhashish_Mandal 14-Sep-13 5:07am    
try again by removing the ';'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900