zoukankan      html  css  js  c++  java
  • 周总结7

    所学时间 10h+
    博客量 6
    代码量 1000行+
    所学知识

    1、大数据HBase、NoSql、Mongo

    2、《河北省重大技术需求征集系统》三级下拉框

    3、数据库sql文件数据转js数据

    相关sql文件转js关键代码:

    package bean;
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.util.ArrayList;
    
    import com.alibaba.fastjson.JSON;
    
    import util.DBUtil;
    
    public class GCTree {
        private String name;
        private ArrayList<GCTree> sub;
        private boolean type;
        
        public boolean isType() {
            return type;
        }
        public void setType(boolean isType) {
            this.type = isType;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public ArrayList<GCTree> getSub() {
            return sub;
        }
        public void setSub(ArrayList<GCTree> sub) {
            this.sub = sub;
        }
        public static ArrayList<GCTree> proTrees(){
            Connection connection=null;
            PreparedStatement preparedStatement=null;
            ResultSet rSet=null;
            ArrayList<GCTree> list= new ArrayList<>();
            try {
                connection=DBUtil.getConnection();
                String sql="select * from gc where type=1";
                preparedStatement=connection.prepareStatement(sql);
                rSet = preparedStatement.executeQuery();
                String a = "",b="",c ="";
                while(rSet.next()) {
                    GCTree tree = new GCTree();
                    a = rSet.getString(2);
                    tree.setName(a+"."+rSet.getString(6));
                    tree.setType(true);
    //                System.out.println(tree.getName());
                    String newsql = "select * from gc where a='"+a+"' and type=2";
                    ArrayList<GCTree> list2 = new ArrayList<>();
                    preparedStatement = connection.prepareStatement(newsql);
                    ResultSet rSet2 = preparedStatement.executeQuery();
                    while(rSet2.next()) {
                        GCTree tree2 = new GCTree();
                        b = rSet2.getString(3);
                        tree2.setName(b+"."+rSet2.getString(6));
                        tree2.setType(true);
                        String newsql2 = "select * from gc where a='"+a+"' and b='"+b+"' and type=3";
                        ArrayList<GCTree> list3 = new ArrayList<>();
                        preparedStatement = connection.prepareStatement(newsql2);
                        ResultSet rSet3 = preparedStatement.executeQuery();
                        while(rSet3.next()) {
                            GCTree tree3 = new GCTree();
                            c = rSet3.getString(4);
                            tree3.setName(c+"."+rSet3.getString(6));
                            tree3.setType(true);
                            String newsql3 = "select * from gc where a='"+a+"' and b='"+b+"' and c='"+c+"' and type=4";
                            ArrayList<GCTree> list4 = new ArrayList<>();
                            preparedStatement = connection.prepareStatement(newsql3);
                            ResultSet rSet4 = preparedStatement.executeQuery();
                            while(rSet4.next()) {
                                GCTree tree4 = new GCTree();
                                tree4.setName(rSet4.getString(5)+"."+rSet4.getString(6));
    //                            System.out.println(tree4.getName());
                                list4.add(tree4);
                            }
                            tree3.setSub(list4);
    //                        System.out.println(tree3.getName()+" "+list4.size());
                            list3.add(tree3);
                        }
                        tree2.setSub(list3);
    //                    System.out.println(tree2.getName()+" "+list3.size());
                        list2.add(tree2);
                    }
                    tree.setSub(list2);
    //                System.out.println(tree.getName()+" "+list2.size());
                    list.add(tree);
                }
                return list;
            } catch (Exception e) {
                // TODO: handle exception
                e.printStackTrace();
            }
            return null;
        }
        public static void main(String[] args) {
            ArrayList<GCTree> list = proTrees();
    //        ArrayList<String> first = new ArrayList<>();
    //        for(int i=0;i<list.size();i++) {
    //            first.add(list.get(i).getName());
    //            ArrayList<String> second = new ArrayList<>();
    //            for(int j=0;j<list.get(i).getSub().size();j++) {
    //                second.add(list.get(i).getSub().get(j).getName());
    //                ArrayList<String> third = new ArrayList<>();
    //                for(int k=0;k<list.get(i).getSub().get(j).getSub().size();k++) {
    //                    third.add(list.get(i).getSub().get(j).getSub().get(k).getName());
    //                }
    //            }
    //            
    //        }
            System.out.println(JSON.toJSONString(list));
        }
    }
    View Code
  • 相关阅读:
    vs项目,点击.sln文件时出错:“项目所需的应用程序未安装,确保已安装项目类型(.csproj)的应用程序”解决办法
    Oracle VM VirtualBox各种显示模式切换 热键
    ajax从asp后台获取数据
    js获取页面的宽度
    SharePoint列表数据展现方法
    select改变执行操作
    SharePoint中删除列表记录
    HP EliteBook 8770p打开Vt-x
    SPlist按PID层级顺序导入datatable
    Excel导入DataTable
  • 原文地址:https://www.cnblogs.com/hhjing/p/13875634.html
Copyright © 2011-2022 走看看