Java Code Examples for org.springframework.jdbc.support.rowset.SqlRowSetMetaData#getColumnCount()

The following examples show how to use org.springframework.jdbc.support.rowset.SqlRowSetMetaData#getColumnCount() . 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;
}