Java tutorial
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class Main { public static void main(String[] argv) throws Exception { Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jdbctutorial", "root", "root"); Statement st = con.createStatement(); ResultSet res = st.executeQuery("SELECT col_name FROM mytable ORDER BY col_name ASC"); while (res.next()) { int col = res.getInt(1); System.out.println(col); } } }