Вы находитесь на странице: 1из 9

Dataview Module Overview

The Database DataView Module for netbeans provides many new features for
existing netbeans Database Explorer.

Besides many advanced features it provides following features:

• Sort results based on a column


• Edit data from a query and commit changes
• Display number of returned records
• Pagination, Option to set page size
• Copy selected records with/without HEADER detail
• Generate SQL script for CREATE, INSERT, UPDATE, DELETE statements from
resultset data.
• New records can be INSERTED in the table
• Delete Selected rows
• Truncate the table
• Optimized pagination for MySQL and Postgres

Result Pane is associated with SQL Editor and for each SQL Editor a separate Result
Pane will be displayed. All the features are described below in detail.
SQL Editor

Full Screen View


Result Pane

The above diagram shows full view of Database Explorer SQL Editor Panel, where
SQL script can be executed. Once SQL Script is executed results are displayed in
lower pane. Lower pane has many features which are shown with different
descriptive icons. Hovering mouse over a particular icon, displays the descriptive
name of the icon.

Most of the features are enabled when executed statement returns a resultset. The
edit buttons are enabled when one table participated in the query otherwise edit
buttons and row editing is disabled.
Result Pane

Records displayed above in Result Pane can be arranged /sorted in following order
based on any column.

As per the order records are inserted


Ascending Order
Descending Order

Records displayed in Result Pane can be modified and then can be committed into
database. Column cell on modification turns green hence modified column can be
differentiated easily.

Result Pane has a toolbar where different icons are shown which provide different
functionality. These features are described below:

Insert Record:

When Insert Record icon is clicked, it pops up a separate dialog, once valid values
are provided, the record will be inserted when user clicks on OK button. When user
clicks on Show SQL it shows the SQL based on the value provided for a columns.
Only valid values for columns are accepted if a value is invalid SHOW SQL Pane
prints out a message that a particular column’s value is invalid and it doesn’t show
SQL Script like above. Hide SQL will hide the SHOW SQL Pane.

If a column accepts a NULL value, CTRL+0 can used to make it null, for a NON-NULL
column when CTRL+0 is pressed, it will beep to notify this column can't be assigned
to NULL.

Delete Selected Record(s):

Using this feature, selected record(s) can be deleted, if no record is selected and this
icon is clicked, a message is displayed to select row(s) to delete.

Commit Record(s):

When record(s) are updated, using commit icon, updated record(s) can be
committed in database. This feature in Result Pane is enabled only when record is
updated/edited, by default it is in disabled state.
Cancel Edits:

This feature is used to undo the updated column value before commit. This is
enabled only when record is updated/edited, by default it is in disabled state.

Truncate Table:

Used to truncate a table

Refresh Records:

Refresh the records from database in Result Pane for the current page.

PAGINATION

Records can be displayed in multiple pages with user defined page size. So to
facilitate navigation to different pages, following features are available in Result Pane
toolbar.
First Page:

Used to return to first page of the record displayed in result pane hence first
page records are displayed here. If very first page is displayed, this icon is
disabled.

Previous Page:

Used to return to previous page of currently displayed page, if very first page
is displayed, this icon is disabled.

Next Page:

Used to display records in next page from displayed page, if the displayed
page is the last page then this Next Page Icon is disabled.

Last Page:

Used to move to last page of the records, if the displayed page is the last
page then this Next Page Icon is disabled.

Page Size:

Page size can be defined by user, depending on the page size number of pages is
calculated and value is displayed in pallet like above.
In Addition to new features some of the features explained above are also available
when mouse is right clicked on any record, Figure shown below.

Following features from the above figure work as described above

Insert Record
Delete Selected Record(s)
Commit Selected Record(s)
Cancel Edits
Truncate Table
Refresh Records

Copy Cell Value: Copy cell value of selected cell (column)


Copy Row Values: Copy values of selected rows
Copy Row Values (With Header): Copy values of selected rows with header
name.

Show SQL Script for CREATE: Display SQL script to create table with the column
definition of the selected table.
Show SQL Script for INSERT: Display SQL script to INSERT values into table with
value(s) of selected record(s).

Show SQL Script for DELETE: Display SQL Script to DELETE for selected row.

Show SQL Script for UPDATE: Displays SQL Script for UPDATE. This is enabled
only when records are modified. Modified cell is displayed in GREEN color.
Print Table Data: Prints the table data with Header.
DataVie API Overview

DataView Module is developed to show data for a given SQL query string, provides
static method to create the DataView Panel from a given SQL query string and a
connection.

public static DataView create(org.netbeans.api.db.explorer.DatabaseConnection


dbConn, String sqlString, int pageSize)

Create and populate a DataView Object. Populates 1st data page of default
size. The caller can run this in background thread and then create the GUI
components to render the DataView by calling DataView.createComponent()

Parameters:
dbConn - instance of DBExplorer DatabaseConnection
queryString - SQL query string
pageSize - default page size for this data view
Returns: a new DataView instance

public boolean hasExceptions()

Returns true if there were any exception in the last database call, false
otherwise.

public boolean hasResultSet()

Returns true if the statement executed has ResultSet, false otherwise.

public Collection<Throwable> getExceptions()

Returns Collection of a error messages of Throwable type, if there were any


exception in the last database call, empty otherwise

public int getUpdateCount()

Get updated row count for the last executed sql statement.
Returns: number of rows updated in last execution, -1 if no rows updated

public long getExecutionTime()

Get execution time for the last executed sql statement


Returns:
execution time for last executed sql statement in milliseconds

public JButton[] getEditButtons()

Returns editing tool bar items, an array of JButton

Вам также может понравиться