Java Code Examples for com.alibaba.druid.pool.DruidPooledConnection#close()
The following examples show how to use
com.alibaba.druid.pool.DruidPooledConnection#close() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SysMapperImpl.java From Autumn with GNU General Public License v2.0 | 4 votes |
@Override public List<SysMenu> getMenuBySys(String sys) throws SQLException { String sql_select_funcgrp = "SELECT * FROM af_funcgrp WHERE type = 'leftMenu' AND status = 1 AND sys = ? ORDER BY disporder"; String sq_select_func = "SELECT * FROM af_func WHERE grp_name = ? AND status = 1 ORDER BY disporder"; DruidPooledConnection connection = druidDataSource.getConnection(); PreparedStatement statement = connection.prepareStatement(sql_select_funcgrp); statement.setString(1, sys); ResultSet resultSet = statement.executeQuery(); List<SysMenu> sysMenuList = new ArrayList<>(); while (resultSet.next()){ SysMenu sysMenu = new SysMenu(); sysMenu.setMenu_name(resultSet.getString("namec")); sysMenu.setHref(resultSet.getString("plugin")); sysMenu.setIcon(resultSet.getString("icon")); PreparedStatement statement1 = connection.prepareStatement(sq_select_func); statement1.setString(1, resultSet.getString("name")); ResultSet resultSet1 = statement1.executeQuery(); List<SysMenu.ChildMenu> childMenuList = new ArrayList<>(); int i = 0; while (resultSet1.next()){ SysMenu.ChildMenu childMenu = sysMenu.new ChildMenu(); childMenu.setMenu_name(resultSet1.getString("namec")); childMenu.setHref(resultSet1.getString("plugin")); // childMenu.setIcon(resultSet1.getString("icon")); childMenuList.add(childMenu); i++; } statement1.close(); //resultSet1.close(); sysMenu.setChild_num(i); sysMenu.setChildes(childMenuList); sysMenuList.add(sysMenu); } connection.close(); resultSet.close(); // 只需关闭一次 statement.close(); return sysMenuList; }
Example 2
Source File: MenuManageMapperImpl.java From Autumn with GNU General Public License v2.0 | 4 votes |
@Override public List<VoMenu> getMenuByPage(int page, int limit, int level, String type, String sys) throws SQLException { // String sql_select_menu = "SELECT id, sys, name, state, disporder, type, level, parent_name"; // String sql_select_menu = "SELECT id, sys, name, state, disporder, type, level, parent_name"; String sql_select_menu = "SELECT * FROM ! WHERE type = ? AND sys = ? LIMIT " + (page - 1) * limit + "," + (page * limit); if (level == 1){ sql_select_menu = sql_select_menu.replace("!", "af_funcgrp"); }else if(level == 2){ sql_select_menu = sql_select_menu.replace("!", "af_func"); } DruidPooledConnection connection = druidDataSource.getConnection(); PreparedStatement statement = connection.prepareStatement(sql_select_menu); statement.setString(1, type); statement.setString(2, sys); ResultSet resultSet = statement.executeQuery(); List<VoMenu> voMenuList = new ArrayList<>(); while(resultSet.next()){ VoMenu voMenu = new VoMenu(); voMenu.setId(resultSet.getInt("id")); voMenu.setDisporder(resultSet.getInt("disporder")); voMenu.setLevel(level + "级菜单"); voMenu.setName(resultSet.getString("name")); voMenu.setNamee(resultSet.getString("namee")); voMenu.setNamec(resultSet.getString("namec")); voMenu.setSys(resultSet.getString("sys")); voMenu.setIcon(resultSet.getString("icon")); if (level == 1) { voMenu.setParent_name(""); } else if (level == 2) { voMenu.setParent_name(resultSet.getString("grp_name")); } if (resultSet.getInt("status") == 0){ voMenu.setStatus(BusinessConstants.SYS_MENU_STATUS_0.getMsg()); }else if (resultSet.getInt("status") == 1){ voMenu.setStatus(BusinessConstants.SYS_MENU_STATUS_1.getMsg()); } voMenu.setType(type); voMenuList.add(voMenu); } resultSet.close(); statement.close(); connection.close(); return voMenuList; }