Only the first Row shows on querry
When I run the following Code only values from the first row show
package Database.H2;
package Database.H2;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class CreateTable {
public static void main (String[] args) throws ClassNotFoundException,
SQLException {
Class.forName("org.h2.Driver");
Connection conn =
DriverManager.getConnection("jdbc:h2:tcp://localhost/~/test",
"sa", "");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM TEST");
while (rs.next()) {
System.out.println(rs.getString("NAME"));
conn.close();
}
}
}
There are 5 rows in the database that I entered manually. How can I get
all the Rows to display?
Any help will be greatly appreciated. Thank you.
No comments:
Post a Comment