title: Trying to retrieve data from a database and use the ResultSet, but don't get the desired output
body: <p>I'm trying to retrieve data from a database and use the ResultSet , but I don't get the desired output</p>
  
  <p>Main program:</p>
  
  <pre><code>import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.lang.reflect.Array;
  import java.util.ArrayList;
  
  public class classname_main{
  
      public static void main(String[] args) throws SQLException{
  
      classname abc=new classname();
       ResultSet asdf= (ResultSet) abc.runconnect();
  
  
  
          abc.printdata();
  
  }
  
  
  }
  </code></pre>
  
  <p>Class:</p>
  
  <pre><code>import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.ResultSet;
  import java.sql.Statement;
  import java.util.ArrayList;
  
  public class classname{
  
  public static  Object runconnect(){
  
      try{
          //get connection
          Connection connection = DriverManager.getConnection("");
          //Create Statement
          Statement st = connection.createStatement();
          //ex query
          //Resultset
          ResultSet rs = st.executeQuery("");
  
          float time=9;
  
  
  
          while(rs.next())
  
          {
  
              if(time&lt;20){
              String x=(rs.getString(9));
              Float y=(rs.getFloat(5));
              //System.out.println(rs.getString(""));
  
              time=time+duration;
              //System.out.println(x);
              if(x&gt;=20){
                  x=9;
  
              }
  
          }
  
          }
          return rs;
      }
  
  
      catch(Exception ex){
          ex.printStackTrace();
  
      }
  
      return 0;
  
  }
  
  public static Object printdata(){
  
      classname pd = new classname();
      ResultSet drs =  (ResultSet) pd.runconnect();
  
      System.out.println(drs);
  
  
      return null;
  }
  
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>com.mysql.jdbc.JDBC42ResultSet@5910e440
  </code></pre>