×
Home About Us Products Services News Free Scripts Contact
news php scripts and software

JAVA example - How to get data from a result set?


JAVA - How to get data from a result set?

try 
  {
	         // Create a result set containing all data from   my_table
	         Statement stmt = connection.createStatement();
	         ResultSet rs = stmt.executeQuery("SELECT * FROM my_table");

	         // Fetch each row from the result set
	         while (rs.next()) 
    {
		// Get the data from the row using the column index
		String s = rs.getString(1);

		// Get the data from the row using the column name
		s = rs.getString("col_string");
    }
    
  } 
  
  catch (SQLException e)
 
  {
    
  }

Category: JAVA

 
<< Go back