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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:23:52+00:00 2026-06-01T20:23:52+00:00

When I compile my program, it makes first row, which is null. I think

  • 0

When I compile my program, it makes first row, which is null. I think it is default in Java. How to remove it? It is a program which is MySQL database client, where we can see data from our database. But this first row is annoying.

String dbtime;
String query = "Select * FROM EMP";
String[][] celDatas = null;
String[] celNames = null;
try {
    // Load the JDBC driver
    String driverName = "org.gjt.mm.mysql.Driver"; // MySQL MM JDBC driver
    Class.forName(driverName);

    // Create a connection to the database
    String serverName = "localhost";
    String mydatabase = "TestyNaukalne";
    String url = "jdbc:mysql://" + serverName +  "/" + mydatabase; // a JDBC url
    String username = "root";
    String password = "";
    connection = DriverManager.getConnection(url, username, password);

    Statement stmt = connection.createStatement();
    ResultSet rs = stmt.executeQuery(query);
    ResultSetMetaData rsmd = rs.getMetaData();

    int NumOfCol = rsmd.getColumnCount();
    rs.last();
    int rowCount = rs.getRow();
    rs = stmt.executeQuery(query);
    celNames = new String[NumOfCol];
    celDatas = new String[rowCount+1][NumOfCol];

    for(int weq=1; weq<=NumOfCol; weq++) {
        System.out.println(rsmd.getColumnName(weq));                   
        celNames[weq-1] = rsmd.getColumnName(weq);
        int tmp = 1;
        while (rs.next()) {
            dbtime = rs.getString(weq);
            System.out.println(dbtime);
            celDatas[tmp][weq-1] = dbtime;
            tmp++;
        } //end while
        rs = stmt.executeQuery(query);                   
        System.out.println();
    }
} catch (ClassNotFoundException e) {
    e.printStackTrace();
} catch (SQLException e) {
    e.printStackTrace();
}

final JTable source = new JTable(celDatas,celNames);
        JScrollPane pane = new JScrollPane(source);
        pane.setSize(f.getSize().width-60,300);
        pane.setLocation(30,20);
  • 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-01T20:23:53+00:00Added an answer on June 1, 2026 at 8:23 pm
            int tmp = 1; // ******
            while (rs.next()) {
               dbtime = rs.getString(weq);
               System.out.println(dbtime);
               celDatas[tmp][weq - 1] = dbtime;
               tmp++;
            } // end while
    

    arrays are 0 based making your celDatas[0] row of the array null. Solution: Don’t do that; initialize tmp to 0.

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

Sidebar

Related Questions

Can anyone else make and compile this program( Click here) up until the first
I'm trying to compile my first linux ARM hello world program and when I
Is there a way to log the commands, make invokes to compile a program?
I want to make a program work and compile in both WIN\Linux . I
When I compile my program, I get three undefined reference to 'PrintArgv(...)' errors. I
Question: Is it possible to compile a program on linux using a .dll file?
How do I save and compile a program in Befunge-93? What file extension do
I compile my C++ program to LLVM IR using the following command. clang++ -O4
I am trying to compile my C program in Ubuntu 9.10 (gcc 4.4.1). I
I'm trying to compile this simple program to start learning how to use timers:

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.