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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:49:11+00:00 2026-05-27T01:49:11+00:00

I am using the mysql java connector. I need java to display the contents

  • 0

I am using the mysql java connector. I need java to display the contents of the first column and the second column in different steps. How do I achieve this?

String qry = "select col1,col2 from table1";
Resultset rs = statement.executeQuery(qry);
  • 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-27T01:49:12+00:00Added an answer on May 27, 2026 at 1:49 am

    I’ve posted a sample below:

       Statement s = conn.createStatement ();
       s.executeQuery ("SELECT id, name, category FROM animal");
       ResultSet rs = s.getResultSet ();
       int count = 0;
       while (rs.next ())
       {
           int idVal = rs.getInt ("id");
           String nameVal = rs.getString ("name");
           String catVal = rs.getString ("category");
           System.out.println (
                   "id = " + idVal
                   + ", name = " + nameVal
                   + ", category = " + catVal);
           ++count;
       }
       rs.close ();
       s.close ();
       System.out.println (count + " rows were retrieved");
    

    (From: http://www.kitebird.com/articles/jdbc.html#TOC_5 )

    Edit: just re-read the question and think you might mean you want to refer to a column later on in code, instead of in the inital loop as in my example above. In that case, you can create an array and refer to the array later on, or, as another answer suggests you can just do another query.

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

Sidebar

Related Questions

I'm accessing public mySQL database using JDBC and mySQL java connector . exonCount is
I'm using a MySQL database and accessing it through Java. PreparedStatement prep1 = this.connection.prepareStatement(
I am trying to implement an application by using MySQL/JAVA and I found this
Using Java, I get this error when attempting to connect to a mysql database:
I'm getting this error while running tomcat 'java.lang.ClassNotFoundException: com.mysql.jdbc.Driver'. I'm using a combination of
Hi I am using connector/j for connecting mysql database in my Advance Java Program.
Context: MySQL server deployed with MysqldResource java class (Connector/MXJ lib). They app using mysql
I'm using Ibatis 2.3.4 and Mysql 5.1.37, with mysql-java-connector 5.1.6 with java 1.6 I
I have made an application using Java/Hibernate/MySQL, but whenever I try running it, it
we are currently working on a new web application using Java and MySql. We

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.