当前位置: 首页>>代码示例>>Java>>正文


Java ResultSetMetaData.getTableName方法代码示例

本文整理汇总了Java中java.sql.ResultSetMetaData.getTableName方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSetMetaData.getTableName方法的具体用法?Java ResultSetMetaData.getTableName怎么用?Java ResultSetMetaData.getTableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.ResultSetMetaData的用法示例。


在下文中一共展示了ResultSetMetaData.getTableName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTableColName

import java.sql.ResultSetMetaData; //导入方法依赖的package包/类
private String getTableColName(int nColSourceIndex)
{
	// DB2 JDBC Driver supports rsMetaData.getTableName(nColSourceIndex); See http://publib.boulder.ibm.com/infocenter/db2help/index.jsp?topic=/com.ibm.db2.udb.doc/ad/rjvjdapi.htm
	try
	{
		ResultSetMetaData rsMetaData = m_r.getMetaData();
		String csTableName = rsMetaData.getTableName(nColSourceIndex);
		String csColName = rsMetaData.getColumnName(nColSourceIndex);
		String csTableColName = SemanticContextDef.getTableColName(csTableName, csColName);
		return csTableColName;
	}
	catch (SQLException e)
	{
		LogSQLException.log(e);
	}
	return "";
}
 
开发者ID:costea7,项目名称:ChronoBike,代码行数:18,代码来源:CSQLResultSet.java

示例2: createTable

import java.sql.ResultSetMetaData; //导入方法依赖的package包/类
protected void createTable(){
    try {
        //Quoter qt = SQLIdentifiers.createQuoter(dbmd);
        ResultSet rs = conn.createStatement().executeQuery(context.getSqlSelect());
        ResultSetMetaData rsMeta = rs.getMetaData();
        String aName = rsMeta.getTableName(1);
        String aSchema = rsMeta.getSchemaName(1);
        String aCatalog = rsMeta.getCatalogName(1);
        table = new DBTable(aName, aSchema, aCatalog);
        table.setQuoter(SQLIdentifiers.createQuoter(conn.getMetaData()));
        //table.setQuoter(quoter);
    } catch (SQLException ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:DBTableTest.java

示例3: createTable

import java.sql.ResultSetMetaData; //导入方法依赖的package包/类
protected void createTable() {
    try {
        //Quoter qt = SQLIdentifiers.createQuoter(dbmd);
        ResultSet rs = conn.createStatement().executeQuery(context.getSqlSelect());
        ResultSetMetaData rsMeta = rs.getMetaData();
        String aName = rsMeta.getTableName(1);
        String aSchema = rsMeta.getSchemaName(1);
        String aCatalog = rsMeta.getCatalogName(1);
        table = new DBTable(aName, aSchema, aCatalog);
    //table.setQuoter(quoter);
    } catch (SQLException ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:DBPrimaryKeyTest.java

示例4: ResultSetIterator

import java.sql.ResultSetMetaData; //导入方法依赖的package包/类
public ResultSetIterator(ResultSet resultSet, String relationName) throws SQLException {
    this.resultSet = resultSet;
    ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
    this.numberOfColumns = resultSetMetaData.getColumnCount();
    this.nextCalled = false;
    this.relationName = resultSetMetaData.getTableName(1);
    if (this.relationName == null || this.relationName.isEmpty())
        this.relationName = relationName; // use as fallback only
    if (this.relationName == null || this.relationName.isEmpty())
        this.relationName = UNKNOWN_RELATION_NAME;
    this.columnNames = retrieveColumnNames(resultSetMetaData);
}
 
开发者ID:HPI-Information-Systems,项目名称:AdvancedDataProfilingSeminar,代码行数:13,代码来源:ResultSetIterator.java

示例5: QueryResult

import java.sql.ResultSetMetaData; //导入方法依赖的package包/类
public QueryResult(ResultSet resultSet) {

        if (resultSet == null) {
            return;
        }

        try {
            ResultSetMetaData md = resultSet.getMetaData();

            for (int i = 0; i < md.getColumnCount(); i++) {
                int index = i + 1;
                VariableDescriptor desc = new VariableDescriptor(
                        md.getColumnName(index),
                        md.getColumnLabel(index),
                        md.getTableName(index)
                );
                variableDescriptors.add(desc);
            }

            while (resultSet.next()) {
                List<Object> row = new ArrayList<>();
                for (int i = 0; i < md.getColumnCount(); i++) {
                    Object value = resultSet.getObject(i + 1);
                    row.add(value);
                }
                rows.add(new DataRow(variableDescriptors, row));
            }

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
 
开发者ID:EMResearch,项目名称:EvoMaster,代码行数:33,代码来源:QueryResult.java

示例6: getTableName

import java.sql.ResultSetMetaData; //导入方法依赖的package包/类
protected String getTableName(PredicateIndicator pi) throws SQLException {
    ResultSetMetaData meta = belsDB.get(pi);
    return meta.getTableName(1);
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:5,代码来源:JDBCPersistentBB.java

示例7: getMeta

import java.sql.ResultSetMetaData; //导入方法依赖的package包/类
/**
 * Creates a new {@link MetaData} object for a given sql query.
 * At this time only one table in the from clause can be specified
 * due to a Oracle inefficiency in their JDBC driver meta data fetch.
 * @param sql
 * @param sourceConn
 * @return
 * @throws SQLException
 * @throws IOException
 */
public static MetaData getMeta(String sql, Connection sourceConn)
  throws SQLException, IOException {
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    try {
        // To download the entire result set it is supposedly much
        // faster to do forward only. This means that we can only
        // call rs.next() and not rs.first(). So we must make sure
        // that rs.next() is not called before we start downloading
        // the table. This is called in populateTable.
        pstmt = sourceConn.prepareStatement(sql,
                ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);

        pstmt.setFetchSize(1);
        pstmt.setMaxRows(1);
        rs = pstmt.executeQuery();

        // If no data was found quit.
        if (rs == null) {
            log.warn("No data found in <SOURCE> using sql statement:" + sql);
            return null;
        }
        log.log(XLevel.DEBUG2, "Processing <SOURCE> data...");

        // Get the table's metadata
        ResultSetMetaData meta = rs.getMetaData();

        // For the result metadata set, we need to cache the count and
        // column names. Calls to getXXX for meta data can make calls
        // back to the database. We're pretty sure they're not going to
        // change while were running.
        int cols = meta.getColumnCount() + 1;
        ArrayList<String> sourceCols = new ArrayList<String>();
        for (int i = 1; i < cols; i++)
            sourceCols.add(meta.getColumnName(i));

        // XXX Oracle 10 Sucks!
        // Oracle does not implement the getTableName and getSchemaName
        // methods. Since they do not implement them, we have to parse
        // the query to determine the table name.
        String tableName = meta.getTableName(1);
        if (tableName.trim().length() == 0) {
            Pattern p = Pattern.compile(".*\\s+from\\s+\\w*?\\.?(\\w+).*",
                    Pattern.CASE_INSENSITIVE);
            Matcher m = p.matcher(sql);
            if (m.matches())
                tableName = m.group(1).toUpperCase();
        }

        MetaData metaData = new MetaData(tableName, meta, sourceConn.getMetaData());
        return metaData;
    } finally {
        try {
            if (rs != null)
                rs.close();
            if (pstmt != null)
                pstmt.close();
        } catch (SQLException ignored) {
        }
    }
}
 
开发者ID:applitect,项目名称:DbShadow,代码行数:73,代码来源:MetaDataRetriever.java


注:本文中的java.sql.ResultSetMetaData.getTableName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。