TOTD #107: Connect to Oracle database using NetBeans

TOTD #106 explained how to install Oracle database 10g R2 on Mac OS X. This Tip Of The Day will explain how to connect Oracle database with NetBeans to leverage all the goodness provided by NetBeans for Java EE application development, Rails, and others.

  1. Download Oracle JDBC Drivers, specifically ojdbc14.jar. (ojdbc6.jar is recommended to be used with GlassFish v3).
  2. Using NetBeans 6.8 M1, in Services tab, right-click on "Databases" and select "New Connection..." as shown:


  3. Expand "Name:" and select "New Driver...":


  4. Click on "Add..." and choose the recently downloaded JDBC driver JAR file as shown below:



    and click on "OK".
  5. Enter the database values as shown below:



    The password is "hr" for the sample HR database. Clicking on "Show JDBC URL" also shows the complete JDBC URL. Click on "OK".

    You may have to unlock the "hr" user by giving the command:
    ALTER USER HR IDENTIFIED BY hr ACCOUNT UNLOCK;
    
    as explained in TOTD #106.
  6. Select the "HR" schema as shown below:



    and click on "OK". The complete list of schemas is now shown in the "Databases" node as shown below:

  7. Expand the "HR" node and the complete list of tables is visible now:



    Expanding each table shows you the complete definition as shown:

  8. Right-click on "COUNTRIES" table and select "View Data..."



    and the result is shown as:



    Additionally, you can execute any SQL command by selecting "Execute Command...":

A complete archive of all the TOTDs is available here.

Subsequent blogs will show how to write a Java EE application to access the Oracle database.

Technorati: totd oracle database netbeans

Comments:

i am getting error message "Unable to add connection to jdbc:oracle:thin:@localhost:1521:orcl using oracle.

Posted by pradeep on February 08, 2010 at 02:27 AM PST #

Pradeep, can you make sure Oracle instance is running ?

Posted by Arun Gupta on February 15, 2010 at 08:37 AM PST #

hi!

i was trying to connect to the oracle 10g with above procedure. I have performed till step no 5. in the User name and password field i have given is "system". even the url shows as it is in your step. but when i complete this process an click on ok an error message box displays stating something like this: "unable to add connection. cannot establish a connection to jdbc:oracle:thin@localhost:1521:orcl using oracle.jdbc.OracleDriver(IO exception: Connection
refused(DESCRIPTION=(TEMP=)(VSNNUM=169869568)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4)))))". THIS IS THE MESSAGE ERROR THAT DISPLAYS WHEN I CLICK ON THE OK BUTTON. WHAT IS THE ERROR?

Posted by kamlesh parekh on March 27, 2012 at 06:00 AM PDT #

Hi!
i am facing a problem that is when i am creating a dsn name. the drivers are not showing in my system dsn server name. please help.

Posted by guest on March 28, 2012 at 06:57 PM PDT #

I proud of your explanations..!!!!
Thank you very much..
Expecting the same from you..!!!

Posted by Ratheesh on May 31, 2012 at 04:28 AM PDT #

I am trying to connect with the same steps given above but I have an error that is:

cannot establish a connection to jdbc:oracle:thin:@localhost:1521:XE using oracle.jdbc.OracleDriver (IO Error: The Network adapter could not establish the connction)

Posted by Tameem on November 19, 2012 at 03:12 PM PST #

Cannot establish a connection to jdbc:oracle:thin:@localhost:1521:orcl using oracle.jdbc.OracleDriver (Io exception: 
is the error message that I'm getting after going through the following steps as above.

Posted by guest on February 20, 2013 at 06:12 AM PST #

Post a Comment:
Comments are closed for this entry.
About

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.


Java EE 7 Samples

Stay Connected

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today