zoukankan      html  css  js  c++  java
  • 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"));
            }
        }
    }

  • 相关阅读:
    python基础易错题
    经典案例题2
    经典案例题1
    Http和Https的区别
    爬虫过程中需要注意的问题
    [转]项目规模估计方法介绍
    [转]23种设计模式总结
    [转]分布式session的几种实现方式
    [转]Redis哨兵模式(sentinel)学习总结及部署记录(主从复制、读写分离、主从切换)
    [转]【Linux】Linux 目录结构
  • 原文地址:https://www.cnblogs.com/danmao/p/4053355.html
Copyright © 2011-2022 走看看