How to view documents using Visual Studio

View documents in Visual Studio with an amazing tool

Xpath Axes

A very useful trick for automation

Review: Spire.DataExport for .NET

A great tool for exporting data in .NET

How to install Arch Linux, step by step, for VMware Workstation (Part I)

First part of a installation tutorial for this beloved OS

How to setup a local repository in Ubuntu

The steps to have a local repo in Ubuntu

Tuesday, August 20, 2013

Connect to an Oracle database with NetBeans

 
Recently, I had to connect to a remote Oracle database. The problem is that I didn't have any application to do it directly, so I had to do some research about it. I found some interesting instructions to connect with SQL*Plus, but with the little time I have, I could find any place to get the necessary files for that. You can try to find it at Oracle's official website, but I got tired of wasting my time. So, the most practical way to connect to an Oracle Database is with NetBeans. So, let's begin.

Note: I'll be using an example on Windows 7 and Windows Server 2008.


Requirements:
  • NetBeans installed. Get it here. I used 7.3.
  • An Oracle database where to connect to. If you don't have it, you'll have to install Oracle and set a new database (get what you need here). I'll assume you have one, although I'll write a tutorial for that soon. Anyway, it's pretty easy. I used Oracle 11g.
  • The Oracle JDBC driver: ojdbc6.jar. You can get it here (you'll need to register first).
Steps:

1. Open NetBeans.
2. Create a new project: Press Ctrl + Shift + N.
 
Now, Press Next and choose a name for the project. I chose Testools for this demostration. Press Finish.
3. In the left part of the screen, Open the Services tab.
4. Right click on Databases > New Connection.
5. Open the Driver dropdown menu, go to the bottom and select New Driver.
6. Click Add and select the .jar file you downloaded. Enter a name for the new connection (I used "Test Connection"). Then press OK.
7. Press Next and you'll see a dialog where you have to enter the data from youre Oracle database. I don't know if this is always the case, but the Service ID in my case was the name of the database.
Press Next. 
8. Select an Schema and press Next.
9. Select a name for the connection. I used "Testools connection" in this case. press Finish.
10. Now you can see youre new connection. If you expand it, you'll see all the databases and will be able to modify an manipulate them as you want. Pretty simple, isn't it?