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

  • Home
  • SEARCH
  • 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 7809357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:24:40+00:00 2026-06-02T03:24:40+00:00

when I try to search my database for a specific entry by using ‘Washing

  • 0

when I try to search my database for a specific entry by using ‘Washing Machine’ as the search string to try and find the Database entry for ‘Washing Machine’, an error appears saying:

04-16 21:43:28.951: E/AndroidRuntime(545): FATAL EXCEPTION: main
04-16 21:43:28.951: E/AndroidRuntime(545): java.lang.RuntimeException: Unable to start   activity  ComponentInfo{com.lukeorpin.theappliancekeeper/com.lukeorpin.theappliancekeeper.EntryStatis tics}: android.database.sqlite.SQLiteException: near "Machine": syntax error: , while compiling: SELECT _id, appliance_name, appliance_wattage, energy_rates FROM ApplianceDetails WHERE appliance_name=Washing Machine

and more specifically to:

at com.lukeorpin.theappliancekeeper.Database.getWattage(Database.java:122)
04-16 21:43:28.951: E/AndroidRuntime(545):  at com.lukeorpin.theappliancekeeper.EntryStatistics.onCreate(EntryStatistics.java:47)

Here is the code for the search query for the Database:

public String getWattage(String spinnerChoice) {
    // TODO Auto-generated method stub
    String[] columns = new String[] { KEY_ROWID, KEY_NAME, KEY_WATTAGE, KEY_ENERGY};
    Cursor c = ourDatabase.query(DATABASE_TABLE, columns, KEY_NAME + "=" + spinnerChoice, null, null, null, null);
    if (c != null){
        c.moveToFirst();
        String wattage = c.getString(2);
        return wattage;
    }
    return null;
}

public String getEnergyRate(String spinnerChoice) {
    // TODO Auto-generated method stub
    String[] columns = new String[] { KEY_ROWID, KEY_NAME, KEY_WATTAGE, KEY_ENERGY};
    Cursor c = ourDatabase.query(DATABASE_TABLE, columns, KEY_NAME + "=" + spinnerChoice, null, null, null, null);
    if (c != null){
        c.moveToFirst();
        String energyRate = c.getString(3);
        return energyRate;
    }
    return null;
}

and this is the original class where the method was created:

final String spinnerChoice = getIntent().getStringExtra("Name");
    if(spinnerChoice==null){ 
        return;
    } 

Database data = new Database(this);
    data.open();
    String returnedWattage = data.getWattage(spinnerChoice); 
    String returnedEnergyRate = data.getEnergyRate(spinnerChoice);
    data.close();

Does anyone have any ideas why this error message is appearing? Thanks

EDIT: Here is the line of code that the error is pointing too (line 122):

Cursor c = ourDatabase.query(DATABASE_TABLE, columns, KEY_NAME + "=" + spinnerChoice, null, null, null, null);
  • 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-06-02T03:24:42+00:00Added an answer on June 2, 2026 at 3:24 am

    Given the error message, it seems like you don’t have quotes denoting a string for the appliance_name value comparison. It should be

    WHERE appliance_name = 'Washing Machine'
    

    I’m not familiar with the api, but you can try changing line 122 to

    Cursor c = ourDatabase.query(DATABASE_TABLE, columns, KEY_NAME + "='" + spinnerChoice + "'", null, null, null, null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I try to search for a value in mysql database and the string
When I try to search a string starting with the slash / character in
just to put it out there -I really did search and try to find
I'm getting a nothing to repeat error when I try to compile this: search
Currently users can search a database using php and ajax with the results shown
I am using the below code to search a mysql database but cannot get
I am using an asp gridview element to do a search on the database
I'm trying to search through my inbox to find specific email's but there every
I have indexed my database using Hibernate Search. I use a custom analyzer, both
I have an XML document that I load in and try to search with

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.