首页 > 代码库 > beanutils中jdbc
beanutils中jdbc
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"));
}
}
}
beanutils中jdbc