Java JDBC Statement run select statement
import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Main { public static void performRead(Connection conn){ String qry = "select recipe_num, name, description from recipes"; Statement stmt = null;/* w w w . j a v a 2 s . c o m*/ try { stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(qry); while (rs.next()) { String recipe = rs.getString("RECIPE_NUM"); String name = rs.getString("NAME"); String desc = rs.getString("DESCRIPTION"); System.out.println(recipe + "\t" + name + "\t" + desc); } } catch (SQLException e) { e.printStackTrace(); } finally { if (stmt != null) { try { stmt.close(); } catch (SQLException ex) { ex.printStackTrace(); } } } } }