zoukankan      html  css  js  c++  java
  • jdbc操作数据库并自动获取字段类型

    //获取改功能编码的关联功能
    public void getLinkdb(String gnbianma){
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    Connection conn = null;
    /**
    select * from SY_FUNC          fc   where fc.func_code ='SY_FUNC'         --功能定义
    select * from SY_FORM_LINK     FLK    where FLK.main_func_code='SY_FUNC'  --关联功能

    **/
    String strSql =" select * from SY_FORM_LINK  FLK where FLK.main_func_code in "
     +" ( select FLK.Main_Func_Code from SY_FORM_LINK FLK where FLK.main_func_code=? ) ";
    List<HashMap<String, Object>> stepLists = new ArrayList<HashMap<String, Object>>();
    HashMap<String, Object> map =null;
    try {
    conn = DbUtil.getConnection();
    pstmt = conn.prepareStatement(strSql);
    pstmt.setString(1, gnbianma);
    rs = pstmt.executeQuery();
    ResultSetMetaData rsmd;
    while (rs.next()){
    map = new HashMap<String, Object>();
    rsmd = (ResultSetMetaData) rs.getMetaData();
    for (int i = 1; i <= rsmd.getColumnCount(); i++) {
    map.put(rsmd.getColumnName(i), rs.getObject(i));
    }
    stepLists.add(map);
    }
    rs.close();
    }catch (SQLException e) {
    e.printStackTrace();
    }finally {
    DbUtil.close(pstmt);
    DbUtil.close(conn);
    }
    System.out.println(stepLists.size());

    }

  • 相关阅读:
    Android消息的提示,Toast吐司方式
    Java内部类
    Android环境配置及运行helloWord案例
    翻译Android API Guides: App Manifest
    Android Configuration介绍 (未完成)
    jquery之效果操作
    jquery之属性操作
    JQuery之dom文档操作
    jQuery之css操作
    jQuery选择器的优点
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3402658.html
Copyright © 2011-2022 走看看