Fri, 17 May 2024


How to get data from a result set?

By: Peter, NetArt Media
Mon, 20 April 2020

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: Web Development
Share this post:



See All Scripts






Subscribe for our newsletter

Receive the latest blog posts direct in your mailbox