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 8801479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:50:39+00:00 2026-06-14T00:50:39+00:00

I am querying an Microsoft Access database with the code below. The database field

  • 0

I am querying an Microsoft Access database with the code below. The database field names are correctly stated in the SELECT statement. Trying to figure out why I am getting this error. Really need some help..thanks

public Item getIteminfo(String itemCode) throws ClassNotFoundException, SQLException {
     Statement myStatement = getConnection();
     Item item = null;
     String itemDescription;
     int itemPrice;
     String sql = "SELECT ItemDescription, ItemPrice FROM itemCatalog WHERE ItemCode = '"+itemCode+"'";
     ResultSet results = myStatement.executeQuery(sql);
     
     while (results.next()){
         itemDescription = results.getString("ItemDescription");
         itemPrice = results.getInt("ItemPrice");
         item = new Item(itemDescription, itemPrice);
     }
     closeConnection();
     return item;
 }

Here’s the error message:

java.sql.SQLException: Column not found
    at sun.jdbc.odbc.JdbcOdbcResultSet.findColumn(JdbcOdbcResultSet.java:1849)
    at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:410)
    at checkoutsimulation.DAO.getIteminfo(DAO.java:52)
    at checkoutsimulation.ItemCatalog.getItemdetails(ItemCatalog.java:61)
    at checkoutsimulation.CheckoutSystem.bnPurchaseActionPerformed(CheckoutSystem.java:463)
    at checkoutsimulation.CheckoutSystem.access$100(CheckoutSystem.java:20)

Edited: The fields are identical, here’s a screen shot
enter image description here

  • 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-14T00:50:40+00:00Added an answer on June 14, 2026 at 12:50 am

    I don’t have access myself so I cannot try this, but here is something that might work. First we print out the names of the columns in the result set in case there is some case sensitivity at work.

    Then we do a workaround int the result.next loop using positional arguments (1, 2, ..) instead of names. This should make it work regardless of what the names are.

    Once you figure out what the name problem is, replace the 1, 2 etc with the correct names.

     ResultSet results = myStatement.executeQuery(sql);
    
     ResultSetMetaData meta = results.getMetaData();
     for (int index = 1; index <= meta.getColumnCount(); index++)
     {
        System.out.println("Column " + index + " is named " + meta.getColumnName(index);
     }
     while (results.next()){
         itemDescription = results.getString(1);
         itemPrice = results.getInt(2);
         item = new Item(itemDescription, itemPrice);
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been successful in querying a Microsoft Access 2003 database (.mdb file) and
i'm querying a database like this: SELECT * from Log WHERE cookieId IN (select
I am querying a database for results and trying to convert them into JSON
I'm trying to do quite a lot of querying against a Microsoft SQL Server
I'm trying to figure out the available disk space programmatically in windows. For this,
I'm trying to access a Sql Server Compact Database. It's a clickonce application, so
Possible Duplicate: Query Microsoft Access MDB Database using LINQ and C# Im working with
AM querying an access database from vb6 using the following query INSERT INTO stock([i_name],[ref],[qty],[supplier_id])
AM querying an access database, selecting records from two tables, in vb6 using the
I am querying the Microsoft Office SharePoint Server Search Service to write some results

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.