Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6137821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:46:29+00:00 2026-05-23T17:46:29+00:00

Edit 4: the problem came from using the string name of the column instead

  • 0

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 |         |       |
+-----------------+-------------+------+-----+---------+-------+
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:46:29+00:00Added an answer on May 23, 2026 at 5:46 pm

    Ok, this works for fulltext search. Heres what I ran. First I inserted into the database (via mysql console):

    insert into user_info values('themanager', 'password', 'email@test.com');
    

    Once I had that I ran:

    import static org.junit.Assert.*;
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    
    import org.junit.Test;
    
    public class TestMysql {
    
        private String dbUrl = "jdbc:mysql://localhost:3306/test";
        private String user = "root";
        private String password = "password";
        private String dbClass = "com.mysql.jdbc.Driver";
        private String query = "SELECT username, email FROM  user_info WHERE MATCH (username, email) AGAINST ('themanager' IN BOOLEAN MODE)";
    
    
       @Test
       public void test() {
    
        try {
    
            Class.forName(dbClass);
            Connection con = DriverManager.getConnection (dbUrl, user, password);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(query);
    
            while (rs.next()) {
                String username = rs.getString(1);
                System.out.println("FOUND: '" + username + "'");
            } //end while
    
            con.close();
        } //end try
    
        catch(ClassNotFoundException e) {
            e.printStackTrace();
        }
    
        catch(SQLException e) {
            e.printStackTrace();
        }
    
    
      }
    
    }
    

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: This problem has been solved. See below. Hey all. I'm building an iPhone
Edit: I fixed the problem by just starting from scratch. Sorry to waste y'alls
Edit : The bug that caused this problem has been fixed. The @version tag
[Edit: This problem applies only to 32-bit systems. If your computer, your OS and
Edit 1: Uninstalled & Reinstalled Edit 2: Same problem. Seriously? Yes. I am having
Most of you probably know the following problem: You edit an HTML, view the
edit: I was trying to solve a spoj problem. Here is the link to
EDIT: I have realized the source of my problem. I only have count information
My problem: I have Ido-mode enabled and I want to edit (for example) a
THIRD EDIT: I now believe that this problem is due to a SOAP version

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.