Connections to databases are managed using database drivers, which enable applications written in different programming languages to interact with the database management system. NetBeans IDE 6.0 comes bundled with the MySQL Connector/J driver, which is a pure Java implementation of the JDBC API, and communicates directly with the MySQL server using the MySQL protocol.
Begin by examining the functionality offered by the Database Explorer located in the IDE's Services window (Ctrl-5). The Database Explorer is represented by the Databases node (). From this interface you can connect to database servers, view current connections, add database drivers, as well as create, browse or edit database structures.
Now that you have the MySQL database server installed and configured, you can connect to it from the NetBeans IDE using the Database Explorer. Note that you are connecting to the database server. In the next step, you will create a database instance through this connection. Do the following:
- In the Database Explorer, expand the Drivers node, then right-click the MySQL (Connector/J driver) and choose Connect Using. The New Database Connection dialog displays.
- In the Database URL field, replace the default <HOST>:<PORT>/<DB> with a forward-slash (/) so that the entry now reads: jdbc:mysql:///.
- For User Name and Password, enter root and nbuser, respectively. Optionally, select the Remember password option.
- Click OK, then click OK again to accept the default schema and exit the dialog. A new Connection node displays in the Database Explorer under the Databases node:
You are now connected to the MySQL RDBMS in the IDE. Note that the new connection node icon appears whole () when you are connected to a database. Likewise, it appears broken () when there is no connection.
At later stages, when working with databases through the Database Explorer, you may need to manually connect to a database. You can do so by right-clicking the broken database connection node and choosing Connect.