You should add jar file with JDBC driver to your dynamic java class path before connecting to database. I believe you can add only one file depending on your requirements. Check the versions difference here.
To avoid warning if a jar file already in the path add some check:
%# add class path (if not in the class path)
p = 'C:\Program Files\PostgreSQL\pgJDBC\postgresql-8.4.702.jdbc3.jar';