use of net.sourceforge.sqlexplorer.dataset.DataSet in project tdq-studio-se by Talend.
the class PriviligesTab method getDataSet.
public DataSet getDataSet() throws Exception {
INode node = getNode();
if (node == null) {
return null;
}
if (node instanceof TableNode) {
TableNode tableNode = (TableNode) node;
ResultSet resultSet = node.getSession().getMetaData().getTablePrivileges(tableNode.getTableInfo());
DataSet dataSet = new DataSet(resultSet, new int[] { 3, 4, 5, 6, 7 });
resultSet.close();
return dataSet;
}
return null;
}
use of net.sourceforge.sqlexplorer.dataset.DataSet in project tdq-studio-se by Talend.
the class RowIdsTab method getDataSet.
public DataSet getDataSet() throws Exception {
INode node = getNode();
if (node == null) {
return null;
}
if (node instanceof TableNode) {
TableNode tableNode = (TableNode) node;
BestRowIdentifier[] rowIds = node.getSession().getMetaData().getBestRowIdentifier(tableNode.getTableInfo());
Comparable[][] data = new Comparable[rowIds.length][];
int index = 0;
for (BestRowIdentifier rowId : rowIds) {
Comparable[] row = new Comparable[COLUMN_LABELS.length];
data[index++] = row;
int i = 0;
row[i++] = rowId.getScope();
row[i++] = rowId.getColumnName();
row[i++] = rowId.getSQLDataType();
row[i++] = rowId.getTypeName();
row[i++] = rowId.getPrecision();
row[i++] = rowId.getScale();
row[i++] = rowId.getPseudoColumn();
if (i != COLUMN_LABELS.length)
throw new RuntimeException(Messages.getString("RowIdsTab.RuntimeException"));
}
DataSet dataSet = new DataSet(COLUMN_LABELS, data);
return dataSet;
}
return null;
}
use of net.sourceforge.sqlexplorer.dataset.DataSet in project tdq-studio-se by Talend.
the class VersionsTab method getDataSet.
public DataSet getDataSet() throws Exception {
INode node = getNode();
if (node == null) {
return null;
}
if (node instanceof TableNode) {
TableNode tableNode = (TableNode) node;
ResultSet resultSet = node.getSession().getMetaData().getVersionColumns(tableNode.getTableInfo());
DataSet dataSet = new DataSet(resultSet, null);
resultSet.close();
return dataSet;
}
return null;
}
use of net.sourceforge.sqlexplorer.dataset.DataSet in project tdq-studio-se by Talend.
the class IndexesTab method getDataSet.
public DataSet getDataSet() throws Exception {
INode node = getNode();
if (node == null) {
return null;
}
if (node instanceof TableNode) {
TableNode tableNode = (TableNode) node;
List<IndexInfo> indexes = node.getSession().getMetaData().getIndexInfo(tableNode.getTableInfo());
List<Comparable[]> dataRows = new ArrayList<Comparable[]>();
int index = 0;
for (IndexInfo col : indexes) {
// type)
if ("STATISTIC".equalsIgnoreCase(col.getIndexType().name())) {
continue;
}
Comparable[] row = new Comparable[COLUMN_LABELS.length];
dataRows.add(row);
int i = 0;
row[i++] = col.isNonUnique();
row[i++] = col.getIndexQualifier();
row[i++] = col.getSimpleName();
row[i++] = col.getIndexType();
row[i++] = col.getOrdinalPosition();
row[i++] = col.getColumnName();
row[i++] = col.getSortOrder();
row[i++] = col.getCardinality();
row[i++] = col.getPages();
row[i++] = col.getFilterCondition();
if (i != COLUMN_LABELS.length)
throw new RuntimeException(Messages.getString("ColumnInfoTab.runtimeException"));
}
DataSet dataSet = new DataSet(COLUMN_LABELS, dataRows.toArray(new Comparable[dataRows.size()][]));
return dataSet;
}
return null;
}
use of net.sourceforge.sqlexplorer.dataset.DataSet in project tdq-studio-se by Talend.
the class AbstractSQLTab method getDataSet.
public final DataSet getDataSet() throws Exception {
DataSet dataSet = null;
int timeOut = SQLExplorerPlugin.getDefault().getPluginPreferences().getInt(IConstants.INTERACTIVE_QUERY_TIMEOUT);
SQLConnection connection = null;
ResultSet rs = null;
Statement stmt = null;
PreparedStatement pStmt = null;
try {
connection = getNode().getSession().grabConnection();
Object[] params = getSQLParameters();
if (params == null || params.length == 0) {
// use normal statement
stmt = connection.createStatement();
stmt.setQueryTimeout(timeOut);
rs = stmt.executeQuery(getSQL());
} else {
// use prepared statement
pStmt = connection.prepareStatement(getSQL());
pStmt.setQueryTimeout(timeOut);
for (int i = 0; i < params.length; i++) {
if (params[i] instanceof String) {
pStmt.setString(i + 1, (String) params[i]);
} else if (params[i] instanceof Integer) {
pStmt.setInt(i + 1, ((Integer) params[i]).intValue());
} else if (params[i] instanceof String) {
pStmt.setLong(i + 1, ((Long) params[i]).longValue());
}
}
rs = pStmt.executeQuery();
}
dataSet = new DataSet(rs, null);
rs.close();
rs = null;
} catch (Exception e) {
SQLExplorerPlugin.error(Messages.getString("AbstractSQLSourceTab.cannotLoadSource") + getNode().getName(), e);
} finally {
if (rs != null)
try {
rs.close();
} catch (SQLException e) {
SQLExplorerPlugin.error(Messages.getString("DataSet.errorCloseRs"), e);
}
if (stmt != null)
try {
stmt.close();
} catch (SQLException e) {
SQLExplorerPlugin.error(Messages.getString("DataSet.errorCloseStmt"), e);
}
if (pStmt != null)
try {
pStmt.close();
} catch (SQLException e) {
SQLExplorerPlugin.error(Messages.getString("DataSet.errorCloseStmt"), e);
}
if (connection != null)
getNode().getSession().releaseConnection(connection);
}
return dataSet;
}
Aggregations