日期:2014-05-16  浏览次数:20399 次

获取数据库用户表格信息
package com.augurit.codebulder.builder.bpo.imp;

import com.augurit.codebulder.util.db.imp.ConnectionManagerImpl;
import java.sql.Connection;
import java.util.*;
import java.sql.*;
import com.augurit.codebulder.builder.bean.Field;
import com.augurit.codebulder.builder.bpo.inf.InfGetDBData;


public class ImpGetDBData extends ConnectionManagerImpl implements InfGetDBData {
    /**
     * 获得用户表集合
     * @return List 用户表集合
     * @throws Exception
     */
    public List getTableList() throws Exception {
        List list = new ArrayList();
        Connection connection = null;
        PreparedStatement prestat = null;
        try {
            connection = this.getConnection();
            String sql = "select table_name from sys.user_tables t";
            prestat = connection.prepareStatement(sql);
            ResultSet rs = prestat.executeQuery();
            while (rs.next()) {
                Map map = new HashMap();
                String tablename = rs.getString("TABLE_NAME");
                if (tablename.indexOf("==") != -1 ||
                    tablename.indexOf("$0") != -1) {
                    continue;
                }
                map.put("name", tablename);
                map.put("comment", this.getTableComment(connection, tablename));
                map.put("comment", "");
                list.add(map);
//                System.out.println(rs.getString("TABLE_NAME"));
            }
            rs.close();
            prestat.close();
        } catch (Exception ex) {
            throw new Exception(ex.getMessage());
        } finally {
            if (connection != null) {
                connection.close();
                connection = null;
            }
        }
        retur