Search in sources :

Example 16 with DataSet

use of net.sourceforge.sqlexplorer.dataset.DataSet in project tdq-studio-se by Talend.

the class AbstractDataSetTab method fillDetailComposite.

public final void fillDetailComposite(Composite composite) {
    try {
        _composite = composite;
        DataSet dataSet = getCachedDataSet();
        if (dataSet == null) {
            Label label = new Label(composite, SWT.FILL);
            label.setText(Messages.getString("DatabaseDetailView.NoInformation"));
            label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
            return;
        }
        // store for later use in dataset table
        // $NON-NLS-1$
        composite.setData("IDetailTab", this);
        new DataSetTable(composite, dataSet, getStatusMessage());
    } catch (Exception 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-2$
        label.setText(Messages.getString("DatabaseDetailView.Tab.Unavailable") + " " + e.getMessage());
        label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
        SQLExplorerPlugin.error(Messages.getString("AbstractDataSetTab.error"), e);
    }
}
Also used : DataSet(net.sourceforge.sqlexplorer.dataset.DataSet) DataSetTable(net.sourceforge.sqlexplorer.dataset.DataSetTable) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData)

Example 17 with DataSet

use of net.sourceforge.sqlexplorer.dataset.DataSet in project tdq-studio-se by Talend.

the class ImportedKeysTab 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().getImportedKeys(tableNode.getTableInfo());
        DataSet dataSet = new DataSet(resultSet, new int[] { 3, 4, 8, 9, 10, 11, 12, 13, 14 });
        resultSet.close();
        return dataSet;
    }
    return null;
}
Also used : INode(net.sourceforge.sqlexplorer.dbstructure.nodes.INode) DataSet(net.sourceforge.sqlexplorer.dataset.DataSet) TableNode(net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode) ResultSet(java.sql.ResultSet)

Example 18 with DataSet

use of net.sourceforge.sqlexplorer.dataset.DataSet in project tdq-studio-se by Talend.

the class PreviewTab method getDataSet.

public DataSet getDataSet() throws Exception {
    INode node = getNode();
    if (node == null) {
        return null;
    }
    if (node instanceof TableNode) {
        TableNode tableNode = (TableNode) node;
        int maxResults = SQLExplorerPlugin.getDefault().getPluginPreferences().getInt(IConstants.PRE_ROW_COUNT);
        if (maxResults == 0) {
            maxResults = 50;
        }
        SQLConnection connection = null;
        Statement statement = null;
        ResultSet resultSet = null;
        DataSet dataSet = null;
        try {
            connection = tableNode.getSession().grabConnection();
            statement = connection.createStatement();
            statement.setMaxRows(maxResults);
            // $NON-NLS-1$
            statement.execute("select * from " + tableNode.getQualifiedName());
            resultSet = statement.getResultSet();
            dataSet = new DataSet(resultSet, null);
        } finally {
            if (resultSet != null)
                try {
                    resultSet.close();
                } catch (SQLException e) {
                    SQLExplorerPlugin.error(Messages.getString("DataSet.errorCloseRs"), e);
                }
            if (statement != null)
                try {
                    statement.close();
                } catch (SQLException e) {
                    SQLExplorerPlugin.error(Messages.getString("DataSet.errorCloseStmt"), e);
                }
            if (connection != null)
                getNode().getSession().releaseConnection(connection);
        }
        return dataSet;
    }
    return null;
}
Also used : INode(net.sourceforge.sqlexplorer.dbstructure.nodes.INode) DataSet(net.sourceforge.sqlexplorer.dataset.DataSet) SQLException(java.sql.SQLException) Statement(java.sql.Statement) SQLConnection(net.sourceforge.sqlexplorer.dbproduct.SQLConnection) TableNode(net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode) ResultSet(java.sql.ResultSet)

Example 19 with DataSet

use of net.sourceforge.sqlexplorer.dataset.DataSet in project tdq-studio-se by Talend.

the class PrimaryKeysTab 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().getPrimaryKeys(tableNode.getTableInfo());
        DataSet dataSet = new DataSet(resultSet, new int[] { 4, 5, 6 });
        resultSet.close();
        return dataSet;
    }
    return null;
}
Also used : INode(net.sourceforge.sqlexplorer.dbstructure.nodes.INode) DataSet(net.sourceforge.sqlexplorer.dataset.DataSet) TableNode(net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode) ResultSet(java.sql.ResultSet)

Example 20 with DataSet

use of net.sourceforge.sqlexplorer.dataset.DataSet in project tdq-studio-se by Talend.

the class RowCountTab method getDataSet.

public DataSet getDataSet() throws ExplorerException {
    String nodeName = getNode().toString();
    if (getNode() instanceof TableNode) {
        TableNode tableNode = (TableNode) getNode();
        nodeName = tableNode.getQualifiedName();
    }
    try {
        // $NON-NLS-1$
        return new DataSet(null, "select count(*) from " + nodeName, null, getNode().getSession());
    } catch (SQLException e) {
        throw new ExplorerException(e);
    }
}
Also used : ExplorerException(net.sourceforge.sqlexplorer.ExplorerException) DataSet(net.sourceforge.sqlexplorer.dataset.DataSet) SQLException(java.sql.SQLException) TableNode(net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode)

Aggregations

DataSet (net.sourceforge.sqlexplorer.dataset.DataSet)24 INode (net.sourceforge.sqlexplorer.dbstructure.nodes.INode)12 TableNode (net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode)12 ResultSet (java.sql.ResultSet)8 File (java.io.File)7 SQLException (java.sql.SQLException)6 SQLConnection (net.sourceforge.sqlexplorer.dbproduct.SQLConnection)4 BufferedWriter (java.io.BufferedWriter)3 FileWriter (java.io.FileWriter)3 PrintStream (java.io.PrintStream)3 DataSetRow (net.sourceforge.sqlexplorer.dataset.DataSetRow)3 FileDialog (org.eclipse.swt.widgets.FileDialog)3 Statement (java.sql.Statement)2 DatabaseProduct (net.sourceforge.sqlexplorer.dbproduct.DatabaseProduct)2 Query (net.sourceforge.sqlexplorer.parsers.Query)2 Message (net.sourceforge.sqlexplorer.plugin.editors.Message)2 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 CallableStatement (java.sql.CallableStatement)1 DatabaseMetaData (java.sql.DatabaseMetaData)1