org.springframework.jdbc.support.rowset.SqlRowSetMetaData Java Examples

The following examples show how to use org.springframework.jdbc.support.rowset.SqlRowSetMetaData. 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: JdbcController.java    From yue-library with Apache License 2.0 6 votes vote down vote up
@GetMapping("/getMetaData")
public Result<?> getMetaData() {
	SqlRowSetMetaData metaData = db.getMetaData("user");
	int columnCount = metaData.getColumnCount();
	for (int i = 1; i <= columnCount; i++) {  
		Map<String,String> fieldMap = new HashMap<String,String>();
		fieldMap.put("ColumnName", metaData.getColumnName(i));
		fieldMap.put("ColumnType", String.valueOf(metaData.getColumnType(i)));
		fieldMap.put("ColumnTypeName", metaData.getColumnTypeName(i));
		fieldMap.put("CatalogName", metaData.getCatalogName(i));
		fieldMap.put("ColumnClassName", metaData.getColumnClassName(i));
		fieldMap.put("ColumnLabel", metaData.getColumnLabel(i));
		fieldMap.put("Precision", String.valueOf(metaData.getPrecision(i)));
		fieldMap.put("Scale", String.valueOf(metaData.getScale(i)));
		fieldMap.put("SchemaName", metaData.getSchemaName(i));
		fieldMap.put("TableName", metaData.getTableName(i));
		fieldMap.put("SchemaName", metaData.getSchemaName(i));
		System.out.println(fieldMap);
	}
	
	return ResultInfo.success();
}
 
Example #2
Source File: ListGrid.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Grid addHeaders( SqlRowSet rs )
{
    SqlRowSetMetaData rsmd = rs.getMetaData();

    int columnNo = rsmd.getColumnCount();

    for ( int i = 1; i <= columnNo; i++ )
    {
        addHeader( new GridHeader( rsmd.getColumnLabel( i ), false, false ) );
    }

    return this;
}
 
Example #3
Source File: DbQuery.java    From yue-library with Apache License 2.0 2 votes vote down vote up
/**
    * 获得表的元数据
    * <p>检索元数据,即此行集合的列的数字、类型和属性。
    * 
    * @param tableName
    * @return
    */
public SqlRowSetMetaData getMetaData(String tableName) {
	tableName = dialect.getWrapper().wrap(tableName);
	StringBuffer sql = new StringBuffer("SELECT * FROM ").append(tableName).append(dialect.getPageJoinSql());
	return queryForRowSet(sql.toString(), Page.builder().page(0L).limit(0).build().toParamJson()).getMetaData();
}