I was curious on how to get a list of rows and add values from each row to an array in Java.
Here is what it looks like in PHP:
<?php
$result = mysql_query("SELECT * FROM names");
while($row = mysql_fetch_array($result)) {
// Get variables from this row and such
}
?>
I can't seem to find out how to do this in Java.
Resolution Found
Statement sta = con.createStatement();
ResultSet res = sta.executeQuery("SELECT TOP 10 * FROM SalesLT.Customer");
while (res.next()) {
String firstName = res.getString("FirstName");
String lastName = res.getString("LastName");
System.out.println(" " + firstName + " " + lastName);
}