标签:io os ar for sp on cti bs new
public class JDBCTest {
// public static void main(String[] args) throws Exception {
// Class.forName("com.mysql.jdbc.Driver");
// Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "123456");
// Statement statement=conn.createStatement();
// ResultSet rs= statement.executeQuery("select *from stuinfo");
// Iterator rows=(new ResultSetDynaClass(rs)).iterator();
// while (rows.hasNext()) {
// DynaBean row=(DynaBean) rows.next();
// System.out.println(row.get("stuname"));
// }
// rs.close();
// statement.close();
// conn.close();
// }
public static void main(String[] args) throws Exception {
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "123456");
Statement statement=conn.createStatement();
ResultSet rs= statement.executeQuery("select *from stuinfo");
RowSetDynaClass rstd=new RowSetDynaClass(rs);
rs.close();
statement.close();
conn.close();
List<DynaBean> list= rstd.getRows();
for (DynaBean dynaBean : list) {
System.out.println(dynaBean.get("stuname"));
}
}
}
标签:io os ar for sp on cti bs new
原文地址:http://www.cnblogs.com/danmao/p/4053355.html