This is my first, to do, geeky post, hope this should help you all. To start with, I have two systems, a Core i5 desktop running Windows 7 (64 bit) and an Atom Net book running Windows 8 + Ubuntu 12.04. I had been trying Servlet program on my desktop and it worked fine until I had to add database connectivity to it. I had Oracle 10g installed on my desktop but wasn’t able to get the database connected.
But things were working just fine on my net book(Ubuntu) I prefer Ubuntu for programming for the sole reason that setting up things on it is easy and quick ! As we are using Netbeans IDE at our college, I first installed it on Ubuntu. (You can download it from here and choose Linux(x64/x86) version)
Here are some steps to configure JDBC on Netbeans on Ubuntu. Once you download the .sh file, simply open terminal and type the following :
sudo chmod +x netbeans-*
Once done with this, a GUI wizard will start and will guide you for the rest of the setup. Setup again was a breeze and require minimum number of clicks. Once the installation is done, it’s time to configure JDBC.
I’m using the MySQL Database for this. I had been using JDBC in swings previously. Now open NetBeans and create a new Application. Choose Java Web –> Web Application. Now you will see a list of files in the left pane. Right click on your project name –> Properties. Also, to add new files like .html, servlet etc choose New from the same menu.
Now select Library –> Add Library. Now look for MySQL JDBC Driver. Select that driver and add.
Click OK and run your program. I hope you don’t need the program now ! Below is a screenshot of how records from database will be displayed once the JDBC has been configured.
As you saw, this was a very simple task. Once you spend this small amount of time, things will be much simpler. Hope this post helps you !
Happy Coding !