private void loadDbView(HttpServletRequest req, HttpServletResponse resp) throws IOException { String dsName = req.getParameter("dsName"); String[] allSchemas = DBView.getSchemas(dsName); String defaultSchema = DBView.getDefaultSchema(dsName); int id = 0; resp.setContentType("application/json;charset=UTF-8"); PrintWriter writer = resp.getWriter(); // writer.write( "[ " // ); // writer.write( " {id:0, name:'mydemo [Default]', nodes:[ " ); // writer.write( " {id:1, name:'Tables', nodes:[ " ); // writer.write( " {id:2, name:'company'}, " ); // writer.write( " {id:3, name:'demouser'}, " ); // writer.write( " {id:4, name:'department'}, " ); // writer.write( " {id:5, name:'loan_money'}, " ); // writer.write( " {id:6, name:'ralasafe_sequence'} ]}" ); // writer.write( " ]} " // ); // writer.write( "] " // ); writer.write("[\r\n"); for (int i = 0; i < allSchemas.length; i++) { String schema = allSchemas[i]; boolean isDefault = defaultSchema.equals(schema); String[] tableNames = DBView.getTableNames(dsName, schema); String[] viewNames = DBView.getViewNames(dsName, schema); if (isDefault) { schema = schema + " [Default]"; } if (i != 0) { writer.write(",\r\n"); } writer.write("\t{id:" + id++ + ", iconSkin: 'schema', name:'" + schema + "', nodes:[\r\n"); // if it's default schema, keep schema attribute value as blank if (isDefault) { schema = ""; } writer.write("\t\t{id:" + id++ + ", iconSkin: 'tables', name:'Tables', nodes:[\r\n"); id = write(writer, tableNames, schema, "table", id); writer.write("\t\t]},\r\n"); writer.write("\t\t{id:" + id++ + ", iconSkin: 'views', name:'Views', nodes:[\r\n"); id = write(writer, viewNames, schema, "view", id); writer.write("\t\t]}\r\n"); writer.write("\t]}"); } writer.write("]"); writer.flush(); }