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());

    }

  • 相关阅读:
    线程
    unix架构
    Unix命令
    可重入函数reentrant function
    Eclipse 中 program arguments 与 VM arguments 的区别
    Java中Generics的使用
    Java的Reflection机制
    Java按值传递、按引用传递
    Java label
    LeetCode Merge Intervals
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3402658.html
Copyright © 2011-2022 走看看