Here we will learn to connect to any Database (Supported) using Eclipse IDE.
Open Eclipse IDE and Select Database Perspective (Windows >> Open Perspective >> Other).
Eclipse IDE would look like below.
Create Connection Profile: Here we will create profile for connecting to DB.
Method 1: Right click on “Database Connections” and click New.
Method 2: Click on “New Connection Profile” button in “Data Source Explorer” view.
Select DB (Oracle in this case) to connect from popup window. And provide connection profile name (JBT in this case).
Click Next. In next screen provide DB connection details as shown below.
Once provide you can check if connection to DB is successful or not by clicking “Test Connection” button as shown above.
If everything is fine it should show Ping Succeed popup window as below. If not then check connection related details.
After providing the connection related details click Finish. If everything is fine then a new Connection profile named JBT will be created in Data Source Explorer view as show below.
Step 4: Execute Query
Here we will learn to execute query to DB and see the DB results. To execute a query you will require “SQL Scrapbook“.
To open SQL scrapbook click scrapbook button on top.
It will open new SQL scrap book, from there you can execute sql query. To view the result of the query fired you will require “SQL Results” view which can be opened from Windows >> Show View >> Other.
Keyboard shortcuts for executing query.
- Execute All : CTRL+ALT+X
- Execute Selected Text : ALT+X
Execute Selected Text as one statement : ALT+C
Step 6: Execution Plan
Execution plan of the query can also be checked via Eclipse IDE. To view Execution plan “Execution Plan” view needs to be opened. Eclipse IDE can show execution plan in two ways.
- Text Explain Plan
- Graphic Explain Plan
Text Explain Plan
Select the query and right click and select “Execute Text Explain Plan” menu. It will display explain plan as shown below.
Graphic Explain Plan
Select the query and right click and select “Execute Graphic Explain Plan” menu. It will display explain plan as shown below.