use of com.varsql.core.db.valueobject.IndexInfo in project varsql by varsqlinfo.
the class IndexInfoHandler method handleResult.
@Override
public void handleResult(ResultContext<? extends ParamMap> paramResultContext) {
ParamMap rowData = paramResultContext.getResultObject();
String indexName = rowData.getString(MetaColumnConstants.INDEX_NAME);
if (!indexName.equals(beforeTableName)) {
currentIndexInfo = new IndexInfo();
currentIndexInfo.setName(indexName);
currentIndexInfo.setBufferPool(rowData.getString(MetaColumnConstants.BUFFER_POOL));
currentIndexInfo.setStatus(rowData.getString(MetaColumnConstants.STATUS));
currentIndexInfo.setTableSpace(rowData.getString(MetaColumnConstants.TABLE_SPACE));
currentIndexInfo.setTblName(rowData.getString(MetaColumnConstants.TABLE_NAME));
currentIndexInfo.setType(rowData.getString(MetaColumnConstants.INDEX_TYPE));
currentIndexInfo.setColList(new ArrayList<ObjectColumnInfo>());
indexInfoList.add(currentIndexInfo);
}
ObjectColumnInfo column = new ObjectColumnInfo();
column.setName(rowData.getString(MetaColumnConstants.COLUMN_NAME));
column.setNo(rowData.getInt(MetaColumnConstants.ORDINAL_POSITION));
column.setAscOrdesc(rowData.getString(MetaColumnConstants.ASC_OR_DESC));
currentIndexInfo.addColInfo(column);
beforeTableName = indexName;
}
use of com.varsql.core.db.valueobject.IndexInfo in project varsql by varsqlinfo.
the class DBMetaImpl method getIndexMetadata.
@Override
public List<IndexInfo> getIndexMetadata(DatabaseParamInfo dataParamInfo, String... indexNames) throws Exception {
SqlSession session = SQLManager.getInstance().openSession(dataParamInfo.getVconnid());
try {
Connection conn = null;
ResultSet rs = null;
List<IndexInfo> indexInfoList = new ArrayList<IndexInfo>();
String schema = dataParamInfo.getSchema();
try {
conn = session.getConnection();
DatabaseMetaData dbmd = conn.getMetaData();
List<TableInfo> tableList;
if (indexNames != null && indexNames.length > 0) {
tableList = new ArrayList<TableInfo>();
TableInfo tableInfo = null;
for (String nm : indexNames) {
tableInfo = new TableInfo();
tableInfo.setName(nm);
tableList.add(tableInfo);
}
} else {
tableList = dBMetaDataUtil.tableInfo(dataParamInfo, conn, "TABLE");
}
ObjectColumnInfo oci = null;
List<ObjectColumnInfo> columnList = new ArrayList<ObjectColumnInfo>();
String tblName;
for (int i = 0, len = tableList.size(); i < len; i++) {
tblName = tableList.get(i).getName();
rs = dbmd.getIndexInfo(null, schema, tblName, false, false);
IndexInfo indexInfo;
String indexName = null;
String beforeName = "";
while (rs.next()) {
indexName = rs.getString(MetaColumnConstants.INDEX_NAME);
if (indexName != null && !"".equals(indexName)) {
if (!beforeName.equals(indexName)) {
columnList = new ArrayList<ObjectColumnInfo>();
indexInfo = new IndexInfo();
indexInfo.setName(rs.getString(MetaColumnConstants.INDEX_NAME));
indexInfo.setTblName(tblName);
indexInfo.setType(rs.getString(MetaColumnConstants.INDEX_TYPE));
indexInfo.setColList(columnList);
indexInfoList.add(indexInfo);
}
beforeName = indexName;
oci = new ObjectColumnInfo();
oci.setName(rs.getString(MetaColumnConstants.COLUMN_NAME));
oci.setNo(rs.getInt(MetaColumnConstants.ORDINAL_POSITION));
oci.setAscOrdesc(rs.getString(MetaColumnConstants.ASC_OR_DESC));
columnList.add(oci);
}
}
}
} catch (SQLException e) {
throw e;
}
return indexInfoList;
} finally {
sessionClose(dataParamInfo.getVconnid(), session);
}
}
Aggregations