Edit 4: the problem came from using the string name of the column instead of the column number as indicated below by nuzz
I’ve been searching all day and can’t figure out how to get a full text search to return a string. It works fine when I type it directly into the mysql command prompt and also works fine if I just use SELECT username FROM user_info; but I get nothing with this.
String result = "";
String request = "SELECT username FROM user_info WHERE MATCH (username) AGAINST ('themanager');";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(request);
while (rs.next()) {
result += rs.getString("username") ;
result += "\n";
}
Edit 1:
Here’s the code for the table:
Create table user_info ( username varchar(16),
password varchar(16),
email varchar(16),
PRIMARY KEY(username,email));
ALTER table user_info add FULLTEXT(username,email);
Sorry I’m still new to this and have no clue how to copy the code from desc user_info without posting a print screen.
Edit 2: oops wrong code, same problem though.
Edit 3: Just figuered out how to copy the desc. The output gives me all the users in the database for SELECT username FROM user_info;. I haven’t a clue about the specifics of my database system just in that its a default install of mysql.
+-----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+-------------+------+-----+---------+-------+
| username | varchar(16) | NO | PRI | | |
| password | varchar(16) | YES | | NULL | |
| email | varchar(50) | NO | PRI | | |
+-----------------+-------------+------+-----+---------+-------+
Ok, this works for fulltext search. Heres what I ran. First I inserted into the database (via mysql console):
Once I had that I ran:
That printed:
FOUND: ‘themanager’
Try that. Let me know if it fails. If it does, it could well be a connection issue
see: http://www.petefreitag.com/item/477.cfm for more info about FULLTEXT querying