Connecting to a Database
See Also
A database connection is represented by a database connection node (
)
under the Databases node in the Services window. To connect to a database, you need to provide a valid JDBC driver for your database in the NetBeans IDE.
When you create a database connection, you supply the details needed to connect to a specific database. These details include the location of the database, which driver to use, and the username and password information.
To create a new connection:
- Ensure that your database is running.
- Right-click the Databases node and choose New Connection.
Alternatively, you can initiate a connection directly from the list of registered drivers. If the database driver is already listed under the Drivers node, right-click this driver's instance node and
choose Connect Using.
- In the first step of the New Connection wizard, choose the driver for the database you are connecting to from the Driver drop-down list and confirm that the correct driver's file is provided in the Driver File field. Click Next.
You are passing the same steps when registering a new driver in the IDE.
- In the Customize Connection dialog box of the New Connection wizard, confirm that the correct driver is selected for your database.
- Depending on what database you are connecting to, provide the connection details for this database, such as database location (hostname or IP address), port, username and password, database name, service name, etc. For more information, see
To help you get started, the IDE fills the default details for some databases for you.
If in doubt, refer to the documentation for the driver that you are using.
- (Optional) Click the Remember Password checkbox to have the IDE remember your password.
If selected, you will not be prompted for the user name and password on subsequent connections to the database.
- Click Test Connection to test the connection to the database.
If the connection is successful, the database connection node appears as
a subnode of the Databases node. The
icon indicates that the database is connected.
When the database is connected, you can expand the database connection node to see the child folders
representing lists of tables, views and procedures.
For more, see Browsing Structures.
If the connection
attempt fails, the IDE displays a dialog box indicating it was unable to add the connection.
Check the connection information for the database in the New Database Connection dialog box.
To disconnect from the database:
- Right-click the database connection node and choose Disconnect.
Disconnected connections are marked with the
icon.
You cannot browse the database until you reconnect to the database.
- See Also
- Adding a JDBC Driver
- Connecting to a Java DB Database
- Using MySQL with the IDE
- Connecting to an Oracle Database XE
Legal Notices