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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:19:27+00:00 2026-06-09T06:19:27+00:00

I am already connected to my database: Connection con = DriverManager.getConnection( jdbc:mysql://instance23389.db.xeround.com:15296/Inventory,user,password); PreparedStatement Statement

  • 0

I am already connected to my database:

Connection con = DriverManager.getConnection(
    "jdbc:mysql://instance23389.db.xeround.com:15296/Inventory","user","password");
PreparedStatement Statement = con.prepareStatement("Select * from inventory");
ResultSet result = Statement.executeQuery();
while(result.next()) {
    //What to put here?
}

This is the arraylist I want stored in that database:

static ArrayList<Product> Chart=new ArrayList<Product>();

And that has these objects stored in the arraylist:

double Total;
String name;
double quantity;
String unit;
double ProductPrice;

What is the general code I need to use to get the arraylist to be stored in the MySQL database?
What is the general code I need to use to get the arraylist out of the MySQL database?

  • 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-09T06:19:29+00:00Added an answer on June 9, 2026 at 6:19 am

    This is a template of what to use for retrieving & populating the Arraylist productList

    while (result.next()) {
    
        Product product = new Product();
    
        product.setTotal(result.getDouble("Total"));
        product.setName(result.getString("Name"));
        // etc.
    
        productList.add(product);
    }
    

    In the meantime, I invite you to have a look at:

    http://www.jdbc-tutorial.com/

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

Sidebar

Related Questions

Working on Access 2007 and Visual Studio 2008, i already connected my database to
We already have the database with real data inside. Now we want to build
I want to prevent database connection being open as much as possible, because this
Let's create a very simple example file: index.php : <?php $connection = mysqli_connect('localhost', 'user',
I already have a connection string in my config file <connectionStrings> <add name=ConnectionString connectionString=Data
So I have a MySQL database set up on a Debian server and it
I am making a gallery that uses a MySQL database (yeah I know it's
Let's say you have a *SQL* buffer already open in Emacs that is connected
I am using node.js to query a MySQL database table every 10 seconds. Using
I need a database for this: <?php if (isset($_POST['addcontentbox'])) { // Connection to Database

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.