Connecting to a Database in MyEclipse
Connecting to a database using the Database Explorer is a two step process. First, configure the Database Explorer driver for your database, and then open a database connection. Driver configuration is a one-time configuration task for each database you want to use. In this tutorial, you will learn to:
- Configure a JDBC database driver
- Create a database profile and connection
Duration Time: 15 Minutes
Don't have MyEclipse? Download Now
1. Configure the Database Connection
This tutorial uses an Oracle database as an example. The process of creating a connection is similar for all other JDBC drivers. To learn about JDBC visit the Sun website.
- Select Window>Open Perspective>MyEclipse Database Explorer. The first time you open the perspective, the Database Browser view shown on the left contains only the preconfigured MyEclipse Derby driver.
You need to create a new driver for each separate connection to a database.
- Click on the DB Browser view, and select New.
- Select Oracle (Thin driver) from the Driver Template drop-down.
- Type oracle in the Driver name field.
- Modify the template URL provided to the correct connection string. In this example, the local Oracle server is jdbc:oracle:thin:@localhost:1521:dbtest.
- Fill out the User name and Password fields with appropriate values for your server. If you do not want to save your password, there is no need to fill in the Password field.
- Click the Add JARs button.
- Browse to location of the JDBC driver JAR file or classes folder, select it, and click Open.
Note: In this case, the Oracle JDBC connector was found as part of the oracle installation files.
- Inspect the value of the Driver Class Name. The ojdbc6.jar file contains two possible driver classes that can be selected from the Driver classname drop-down.
- Select oracle.jdbc.driver.OracleDriver from the Driver classname drop-down, and click Finish.
A descriptive name that will appear Database Browser view.
The database connection string. Each database has its own URL structure, e.g. jdbc:oracle:thin://
The login name when creating a connection to the database.
The password when creating a connection to the database.
User managed JARs in this list are added to the Driver Manager's classpath. If the database driver is not available on the the Java Classpath (see above) it should be added here.
Driver Class Name
The fully qualified Java classname of the JDBC driver class. This class must be accessible on the combined classpath locations of the Java Classpath + Driver JARs lists.
Selecting this option instructs the Database Explorer to store the password locally. If this option is selected, you will not be prompted for your password when you attempt to connect.
Open on Eclipse Startup
Selecting this option will instruct the Database Explorer to automatically create this connection during the Eclipse startup process.
The new driver appears the DB Browser view.
Open a connection when MyEclipse is started or after any event that results in the database connection being dropped, such as a database server restart.
- Right click the driver, and select Open connection.
If the connection profile is configured with the Save Password option disabled, then the Open Database Connection wizard opens.
- Enter the password.
- Select the AutoCommit checkbox if you need changes to the database to be committed immediately. You can set the default auto-commit setting in the MyEclipse Database Explorer preferences.
- Click OK to initiate the database connection process. A new database connection opens and is displayed in the DB Browser.
Note: Connections remain open if you close the Database Browser view or switch to a different perspective.