<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.alibaba.fastjson.JSONArray" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Vector" %>
<%
    ConnectionFactory cf = new ConnectionFactory();
    Pub pub = new Pub();
    Connection conn = null;
    Vector v_list = null;
    String json = "";
    StringBuffer sql = new StringBuffer();
    List list = new ArrayList();
    try {
        //conn = com.censoft.db.DBUtil.getConnection();
		conn = cf.getConnection("dm.jdbc.driver.DmDriver","jdbc:dm://51.31.250.3","TEL_POOL","TEL_POOL123456");
        sql.append("select id,p_id as pid,dept_name as name,dept_order from tp_dept ");
        sql.append(" order by dept_order asc");
        v_list = cf.doQuery(conn, sql.toString(), null, list.toArray());
        if (v_list == null) {
            out.println("查询用户出错");
            return;
        }
        if(v_list != null && v_list.size() > 0){
            json = JSONArray.toJSON(v_list).toString();
        }
    } catch (Exception e) {
        out.println("查询用户信息异常" + e);
        return;
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
            }
        }
    }
    response.setContentType("application/json;charset=utf-8");
    response.getWriter().write(json.replace("pid","pId"));
%>