Monday, July 26, 2010

The NetBeans E-commerce Tutorial

For some time now I've been looking into Java EE. Again, first step into the unknown is the hardest.

After getting the new Netbeans (6.9) I have stumbled upon The NetBeans E-commerce Tutorial.
I think it is a great way to learn some aspects of Java EE and how to develop commercial software/webpages.

The tutorial shows how to setup a simple website for a grocery shop, that allows people to order their products. It shows how to eficiently use the IDE (NetBeans) and MySQL workbench to connect the database (MySQL) to the business logic (Java) and the webpage (JSP, HTML, CSS).

It also shows the whole process of developing a commerce application starting with a scenario, gathering customer's requirements, use-cases, mockups and so on. The code part is based on a design pattern called Model-View-Controller, which is explained in the tutorial but if you'd like to know more here's a good resource.


Over the next few posts I'd like to show how to do the above but using a PostgreSQL and pgAdmin III.

You can download PostgreSQL as well as the admin tool here. I have used a standard setup but included jdbc4 for installing.

You start by doing exacly what the tutorial says until "Communicating with the Database Server".
At this point you copy the postgresql-x.x.-xxx.jdbc4.jar file to the {glassfish}/lib directory.
Now you should restart glassfish server by :
  • going to services [tab]->servers->glassfish 3  right-clicking and selecting restart (or start if its offline),
  • or asadmin stop-domain domain1
    asadmin start-domain domain1
After that you right-click on the services [tab]->databases. Choose New Connection. Select PostgreSQL as a driver and fill out the rest of your form with necessary data. For me it looked like that :

 Sorry about the language on the right side but I was unable to change it to english. I think that the icons are explanatory though.
After you accept you will be prompted to choose the schema. Note that in my case I was unable to change the default schema after creating the connection (despite the option) so you might want to create one beforehand in pgAdmin.

After connecting you should be able to create tables, views and procedures in you database by Netbeans.

If it does not you might find some answers on this site which I used to figure it out in the first place or just post a comment here/mail me.

Soon I'll post how to create the necessary tables from Designing the Data Model.

No comments:

Post a Comment