You can establish a connection to Oracle Database from the NetBeans IDE. For example, you can use Oracle Database 10g Express Edition (Oracle Database XE), a lightweight database that is free to develop, deploy, and distribute.
Before connecting to Oracle Database, ensure that you have downloaded the JDBC driver for the database. The recommended driver is ojdbc6.jar. For more information about Oracle JDBC drivers, refer to the Oracle JDBC information:
To connect to the Oracle Database XE from the IDE:
In the Services window, right-click the Databases node and choose New Connection.
In the Locate Driver step of the New Connection wizard, choose one of the following drivers for Oracle Database:
Oracle Thin. Oracle's JDBC Thin driver uses Java sockets to connect directly to Oracle Database. Because it is written in Java, this driver is platform independent and can also run from a Web Browser (applets).
Oracle OCI. Oracle's JDBC OCI drivers use Oracle Call Interface (OCI) and native libraries to interact with an Oracle database. The required libraries are part of the Oracle Database Instant Client, which needs to be installed and configured on your system.
Click Add to specify the location of the ojdbc6.jar file. This file contains packages for both types of Oracle DB drivers. However, if you want to use the OCI driver, you also need to have Oracle Instant Client installed on your machine. Click Next.
In the Customize Connection dialog box of the New Connection wizard, choose the driver name and how you want to specify the database: by a SID name (Oracle System ID), Service Name, or a TNS name.
Then, enter the hostname or IP address to which you want to connect. If you are connecting to a locally installed database instance, enter localhost or 127.0.0.1.
Provide the port number. The default port is 1521.
Depending on your choice of the driver, enter either the SID name, Service, or TNS name.
For example, the default SID for Oracle Database XE is XE.
Provide the database user name and password.
(Optional) Click Test Connection to see if the connection can be established.
Click OK. The IDE displays the connection to the database under the Databases
node in the Services window.
For more information on how to connect to Oracle Database from the NetBeans IDE, see:
Notes:
SID, or System ID, is a unique name of an Oracle database instance. For example, the default SID for Oracle Database XE is XE.
You can find the SID in the tnsnames.ora file, which is a configuration file that specifies various database properties used to connect to the database. The default location of tnsnames.ora is %ORACLE_HOME%\NETWORK\ADMIN directory.
You can also find the SID and Service Name values through the web-based database management interface. For example, go to Database Home Page for Oracle Database XE, choose Administration > About Database > Parameters. Find the values of the following properties: db_name, which is the database SID; service_names is the database Service Name. You must have database administrator rights to access this informaiton.
The sample URL to the Orace Database XE is jdbc:oracle:thin:@//localhost:1521/XE