Connecting jsp pages to postgres sql

Real newbie question here...

Need a step by step tutorial to show me how to connect from jsp pages to postgres (7.4.3)
I have tomcat running now, jdk is 1.4.02 and existing jsp pages. I just need to get some data and display on website.

I am looking for::

what do i need to include at top of .jsp?
I have pg74.1jdbc2.jar in  $TOMCAT_HOME/common/lib
Postgres is ready to take tcp/ip connections and 'trust's' its own ip

general format of creating connection and how to send sql query to that connection.

TIA
Jerry
JerryNortonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ivanovnCommented:
To connect do something like this:

try
{
    Class.forName("org.postgresql.Driver").newInstance();
    Connection c = DriverManager.getConnection("jdbc:postgresql://hostname/dbname", "username", "passwd");
    Statement s = c.createStatement();
    ResultSet r = s.executeQuery("select * from test_table");
    r.close();
    s.close();
}
catch(SQLException e)
{
}

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JerryNortonAuthor Commented:
 Connection c = DriverManager.getConnection("jdbc:postgresql://hostname/dbname", "username", "passwd");

I'm able to run this on the local box, but only with jdbc:postgresql:dbname...
the //hostname/ piece i tried substituting //localhost/ and that didn't fly...and what i really need is something from another server, so need to access remotely (tcp/ip port 5432).
Tell me correct format for that and I'll be happy to accept your answer!

ivanovnCommented:
What error do you get when you try to connect to a remote database?

Try specifying the port number or IP address in the connection string.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PostgreSQL

From novice to tech pro — start learning today.