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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:07:03+00:00 2026-06-01T05:07:03+00:00

I am trying to read in values from the SQLite database and I have

  • 0

I am trying to read in values from the SQLite database and I have the following question: What data structure would you use if the API only allows you to proceed row by row without the possibility of checking how many rows there are? I would like to stress the fact that I want to return a two dimensional array at the end… Would you you list of lists and then convert?

  • 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-01T05:07:05+00:00Added an answer on June 1, 2026 at 5:07 am

    i think its better to return list of object you trying to get its data, for example if you want to get all students form database, you could make class for that:

    public final class Student {
      private int id;
      private String name;
      private int age;
    
      public Student(int id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
      }
    
      public int getId() {
          return this.id;
      }
    
      // other getter methods
    }
    

    then you can retrieve all student in list

    public List<Student> getAllStudents() throws SQLException {
        List<Student> students = new ArrayList<Student>();
    
        String select = "SELECT * FROM students";
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery(select);
    
        while ( resultSet.next() ) {
            int id = resultSet.getInt(1);
            String name = resultSet.getString(2);
            int age = resultSet.getInt(3);
    
            Student student = new Student(id, name, age);
            students.add(student);
        }
    
        return students;
    }
    

    Edit:
    to get the size of result set, you can call resultset.last() then call resultset.getRow(), it was discussed here:

    How do I get the size of a java.sql.ResultSet?

    How to get a number of rows a ResultSet contains?

    ResultSet resultSet = ps.executeQuery();
    int rowcount = 0;
    if (resultSet.last()) {
      rowcount = resultSet.getRow();
      resultSet.beforeFirst();
    }
    

    then you can build your 2D array:

        String[][] result = new String[rowCount][ColumnCount];
    
        int i=0;
        while (resultSet.next()) {
          // build result[i] array
          i++;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read hex values from a binary file. I don't have a
I'm trying to read out the values from a jStorage JSON object called data.shake
I'm trying to read use fread to read in values from an external file
I'm trying to read some JSON data from the Tumblr API. I'm using the
im having some problems trying to read a SQlite data base from flash using
So I'm trying to get the values from a SQLite database into a cursor,
I am Trying to read data from text files and save tokens in SQLite
I'm trying to read some BigDecimal values from the string. Let's say I have
I am trying to read values from an input file in Perl. Input file
I am trying to read values from a text file using the Qt code

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.