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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:50:16+00:00 2026-06-01T09:50:16+00:00

I am getting a Cannot Find Symbol error for rowData, and columnLabels. Is the

  • 0

I am getting a “Cannot Find Symbol” error for rowData, and columnLabels. Is the reason I am getting this error because there is no value yet for the two variables? I figured that once I created arrays they would be null until the function was called with a ResultSet object.

import javax.swing.*;
import java.awt.*;
import java.sql.*;

public class Testing
{
     public static JTable getTable(ResultSet rs)
     {


     //get data from the resultSet using metaData and place into the arrays

     try
     {
          ResultSetMetaData metaData = rs.getMetaData();
              int numberOfColumns = metaData.getColumnCount();
          int numberOfRows = rs.getRow();

          String[] columnLabels = new String[numberOfColumns];
          Object[][] rowData = new Object[numberOfRows][numberOfColumns];   

          for (int column = 0; column < numberOfColumns; column++) {
              columnLabels[column]= metaData.getColumnLabel(column + 1);
              }//end of for loop

          for(int x = 1; x <= numberOfRows; x++)
          {
          for(int y = 1; y<=numberOfColumns;y++){
              rs.absolute(x);
      rowData[x][y] = rs.getObject(y);}
          }//end of loop
     }catch(SQLException sqlException){
      sqlException.printStackTrace();
     }//end of catch

     JTable table = new JTable(rowData,columnLabels);
     return table;
    }//end of getTable;
}//end of testing
  • 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-01T09:50:17+00:00Added an answer on June 1, 2026 at 9:50 am

    You’ve got a scope problem. rowData etc are declared inside of the try block and are visible only in the try block. A possible solution: declare the variable before the try block.

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

Sidebar

Related Questions

I'm getting an error cannot find symbol method add(java.util.Date), although what I'm passing it
I'm modifying inherited code and keep getting a weird cannot find symbol error which
I'm getting the following error when calling a stored procedure: Cannot find the object
I am getting the error Cannot resolve TargetName grdGeneral . What I am trying
I cannot understand why I am getting deadlock in this simple sample.What is wrong
I cannot seem to figure out I am getting the following error in IE
I am getting very frustrated because I cannot seem to figure out why Collections
I am getting the error A field initializer cannot reference the nonstatic field, While
Java is complaining! cannot find symbol symbol : constructor Bar() location: class Bar JPanel
Hi I'm getting a symbol not found error, when running mvn -e integration-test .

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.