use of org.talend.sqlbuilder.dataset.dataset.DataSet in project tdi-studio-se by Talend.
the class AbstractDataSetTab method fillDetailComposite.
public final void fillDetailComposite(Composite composite) {
try {
pComposite = composite;
DataSet dataSet = getCachedDataSet();
if (dataSet == null) {
return;
}
// store for later use in dataset table
//$NON-NLS-1$
composite.setData("IDetailTab", this);
new DataSetTable(composite, dataSet, getStatusMessage(), false);
} catch (Exception e) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("AbstractDataSetTab.logMessage1"), e);
// couldn't get results.. clean mess up
Control[] controls = composite.getChildren();
for (int i = 0; i < controls.length; i++) {
controls[i].dispose();
}
// and show error message
Label label = new Label(composite, SWT.FILL);
//$NON-NLS-1$ //$NON-NLS-2$
label.setText(Messages.getString("DatabaseDetailView.Tab.Unavailable") + " " + e.getMessage());
label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("AbstractDataSetTab.logMessage2"), e);
}
}
use of org.talend.sqlbuilder.dataset.dataset.DataSet in project tdi-studio-se by Talend.
the class AbstractSQLTab method getDataSet.
public final DataSet getDataSet() throws Exception {
DataSet dataSet = null;
int timeOut = SqlBuilderPlugin.getDefault().getPluginPreferences().getInt(IConstants.INTERACTIVE_QUERY_TIMEOUT);
SQLConnection connection = getNode().getSession().getInteractiveConnection();
ResultSet rs = null;
Statement stmt = null;
PreparedStatement pStmt = null;
try {
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(null, rs, null);
rs.close();
} catch (Exception e) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("AbstractSQLTab.logMessage1") + getNode().getName(), e);
} finally {
if (stmt != null) {
try {
stmt.close();
} catch (Exception e) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("AbstractSQLTab.logMessage2"), e);
}
}
if (pStmt != null) {
try {
pStmt.close();
} catch (Exception e) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("AbstractSQLTab.logMessage2"), e);
}
}
}
return dataSet;
}
use of org.talend.sqlbuilder.dataset.dataset.DataSet in project tdi-studio-se by Talend.
the class ImportedKeysTab method getDataSet.
public DataSet getDataSet() throws Exception {
INode node = getNode();
if (node == null) {
return null;
}
if (node.getSession() == null) {
return null;
}
if (node instanceof TableNode) {
TableNode tableNode = (TableNode) node;
ITableInfo ti = tableNode.getTableInfo();
if (tableNode.getTableInfo() == null) {
return null;
}
ResultSet resultSet = null;
SessionTreeNode treeNode = node.getSession();
// For synonym table, should get the corresponding table.
if (ti.getType().equals("SYNONYM")) {
//$NON-NLS-1$
String realTableName = ExtractMetaDataFromDataBase.getTableNameBySynonym(treeNode.getInteractiveConnection().getConnection(), ti.getSimpleName());
resultSet = treeNode.getMetaData().getJDBCMetaData().getImportedKeys(ti.getCatalogName(), ti.getSchemaName(), realTableName);
} else {
resultSet = node.getSession().getMetaData().getImportedKeys((tableNode.getTableInfo()));
}
DataSet dataSet = new DataSet(null, resultSet, new int[] { 3, 4, 8, 9, 10, 11, 12, 13, 14 });
resultSet.close();
return dataSet;
}
return null;
}
use of org.talend.sqlbuilder.dataset.dataset.DataSet in project tdi-studio-se by Talend.
the class PrimaryKeysTab method getDataSet.
public DataSet getDataSet() throws Exception {
INode node = getNode();
if (node == null) {
return null;
}
if (node.getSession() == null) {
return null;
}
if (node instanceof TableNode) {
TableNode tableNode = (TableNode) node;
ITableInfo ti = tableNode.getTableInfo();
if (tableNode.getTableInfo() == null) {
return null;
}
ResultSet resultSet = null;
SessionTreeNode treeNode = node.getSession();
// For synonym table, should get the corresponding table name .
if (ti.getType().equals("SYNONYM")) {
//$NON-NLS-1$
String realTableName = ExtractMetaDataFromDataBase.getTableNameBySynonym(treeNode.getInteractiveConnection().getConnection(), ti.getSimpleName());
resultSet = treeNode.getMetaData().getJDBCMetaData().getPrimaryKeys(ti.getCatalogName(), ti.getSchemaName(), realTableName);
} else {
resultSet = node.getSession().getMetaData().getPrimaryKeys((tableNode.getTableInfo()));
}
DataSet dataSet = new DataSet(null, resultSet, new int[] { 4, 5, 6 });
resultSet.close();
return dataSet;
}
return null;
}
use of org.talend.sqlbuilder.dataset.dataset.DataSet in project tdi-studio-se by Talend.
the class ExportedKeysTab method getDataSet.
public DataSet getDataSet() throws Exception {
INode node = getNode();
if (node == null) {
return null;
}
if (node.getSession() == null) {
return null;
}
if (node instanceof TableNode) {
TableNode tableNode = (TableNode) node;
ITableInfo ti = tableNode.getTableInfo();
if (tableNode.getTableInfo() == null) {
return null;
}
ResultSet resultSet = null;
SessionTreeNode treeNode = node.getSession();
// For synonym table, should get the corresponding table.
if (ti.getType().equals("SYNONYM")) {
//$NON-NLS-1$
String realTableName = ExtractMetaDataFromDataBase.getTableNameBySynonym(treeNode.getInteractiveConnection().getConnection(), ti.getSimpleName());
resultSet = treeNode.getMetaData().getJDBCMetaData().getExportedKeys(ti.getCatalogName(), ti.getSchemaName(), realTableName);
} else {
resultSet = node.getSession().getMetaData().getExportedKeys((tableNode.getTableInfo()));
}
DataSet dataSet = new DataSet(null, resultSet, new int[] { 4, 7, 8, 9, 10, 11, 12, 13, 14 });
resultSet.close();
return dataSet;
}
return null;
}
Aggregations