當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。