Connecting PostgreSQL to Netbeans – Part 2

This is the continuation of the previous tutorial I had, Connecting PostgreSQL to Netbeans – Part 1. Now, we will be accessing our database in PostgreSQL via our Netbeans platform.

Stretch your patience with this one, especially in the coding part.

1. As you open your Netbeans, got to File > New Project > Categories: Java > Projects: Java Application. Then click Next.

2.  Fill in your Project Name, then click Finish.

3.  Go to your project, mine is named trylang. Right click Libraries, and  Add Library.

4. A pop-up will appear, choose PostgreSQL JDBC Driver.

5. Then clear the source file and fill it with the code that will eventually connect your database to your Netbeans. The code can be downloaded in this file hosting site. Warning: you have to replace the variables in the code with your own in your database; it’s because it will surely cause errors.

6. Finally, after pasting and editing the code, Run the code. Then you will get a pop-up window displaying the content of your table you created in PostgreSQL.

There you have it, you’ve just accessed your database in PostgreSQL using Netbeans. You could actually edit the columns of your table, and rerun the source code. You will then get an updated call.

Domo arigato! 😄

16 thoughts on “Connecting PostgreSQL to Netbeans – Part 2

  1. Pingback: Connecting PostgreSQL to Netbeans – Part 2 « DbRunas – Noticias y Recursos sobre Bases de Datos

  2. Pingback: PostgreSQL, Ubuntu, NetBeans IDE (Part 1) | Strategic HR

  3. Pingback: Hibernate, PostgreSQL, Ubuntu, NetBeans IDE (Part 1) | Strategic HR

  4. if i call the connection from main method(java) its working . but if i call the same method from jsp page(Struts application) I am getting Error: SQL Exception: driver not found , any idea on this . cross verified my class path and libs, everything is there.

Reply na, now na!

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s