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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:16:28+00:00 2026-05-28T00:16:28+00:00

How may i retrieve & populate output components at a .jsp page with MySQL?

  • 0

How may i retrieve & populate output components at a .jsp page with MySQL? Also, how may i retrieve records pertaining to a particular item_id? Im using IBM Rational Application Developer.

The following is what i have so far, ridden with errors or missing statements I’m sure.

@DB.class

public Items getItemDetails() {
                     Connection con = connect(true);
            PreparedStatement stmt = null;
            ResultSet rs = null;
            String select = "SELECT * FROM TEST.ITEMBOUGHT WHERE ITEM_ID = ?";
            Items item = null;

            try {
                stmt = con.prepareStatement(select);
                //stmt.setString(1,item_id);
                rs = stmt.executeQuery();
                while (rs.next()) {
                    //System.out.println("Record Found!");
                    item = new Items();
                    //item.setItem_id(item_id);
                    item.setItem_name(rs.getString("item_name"));
                    item.setItem_bidding_start_price(rs.getDouble("item_bidding_starting_price"));
                    item.setItem_bidding_highest_price(rs.getDouble("item_bidding_highest_price"));
                    item.setItem_description(rs.getString("item_description"));
                    item.setItem_quantity(rs.getInt("item_quantity"));
                    item.setItem_closing_date(rs.getDate("item_closing_date"));
                    item.setItem_image(rs.getString("item_image"));
                    item.setItem_status(rs.getString("item_closing_date"));
                }
            } catch (Exception e) {
                e.printStackTrace();
                item = null;
            } finally {
                try {
                    if (rs   != null) rs.close();
                    if (stmt != null) stmt.close();
                    if (con  != null) con.close();
                } catch (SQLException e) {}
            }
            return item;
        }
  • 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-28T00:16:29+00:00Added an answer on May 28, 2026 at 12:16 am

    You’re using PreparedStatement for the SQL: SELECT * FROM TEST.ITEMBOUGHT WHERE ITEM_ID = ?. That means you must tell JDBC what value to replace the question mark (?) in query string, but you put comment on it in //stmt.setString(1,item_id);

    If you want to select ITEM_ID 1 and ITEM_ID is INTEGER (numeric field), you can use the following code:

    public Items getItemDetails() {
       Connection con = connect(true);
       PreparedStatement stmt = null;
       ResultSet rs = null;
       String select = "SELECT * FROM TEST.ITEMBOUGHT WHERE ITEM_ID = ?";
       Items item = null;
    
       try {
           stmt = con.prepareStatement(select);
           stmt.setInt(1,1);
           rs = stmt.executeQuery();
           while (rs.next()) {
              ... // and so on
           }
       }
       ...
    }
    

    If you want to select all records, remove the WHERE clause: SELECT * FROM TEST.ITEMBOUGHT. If you don’t need PreparedStatement, you can rewrite the code into:

    Statement stmt = null;
    ...
    try {
    ...
       stmt = con.createStatement() ;
       rs = stmt.executeQuery(select) ;
    ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using GWT RPC & Hibernate to insert and retrieve data from MySql
I'm using PHP's IMAP functions to retrieve messages from a POP3 mailbox & was
May i have a working sample on how to retrieve records from a DB
How may i retrieve the total number of records from a table via a
Persistence ignorance is typically defined as the ability to persist & retrieve standard .NET
I am using the Tweetstream gem to retrieve statuses from Twitter. This works: Tweetstream::Client.new('user',
I would like to retrieve any text a user may have highlighted with the
I am using the following url to stream twitter data. http://stream.twitter.com/1/statuses/filter.json?count=-150&follow=16256661&track=indiana Without the count
I need to retrieve the last character of a file. It may be a
I wonder whether someone may be able to help me please. I'm using the

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.