Solved

Webapp with postgresql

Posted on 2001-07-30
6
683 Views
Last Modified: 2008-03-04
Hi,
   I have set up my postgresql in a linux RH7.0 machine. And my Tomcat webapp is on a NT mechine.
   I have test the postmaster..it runs well. And same to the tomcat.
   My question is how can I establish the JDBC connection from Tomcat jsp page in Nt to the postgresql in Linux mechine?
   What do i need to do?
   1) where should I install the jdbc driver? Nt or Linux?
   2) how to set the port for the database?

Thanks.
0
Comment
Question by:mkngau
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 4

Expert Comment

by:sdussinger
ID: 6336551
1) The JDBC driver needs to be whereever the JSP page is. Since you have Tomcat running under NT, then NT is where the JDBC drivers should be installed.  They need to be installed somewhere so that your webapp can find them. You could put them into $TOMCAT_HOME/webapps/<yourwebapp>/WEB-INF/lib. That way when Tomcat starts, it'll add the jdbc jar file to the classpath for the webapp.

2) The default port for postgres is 5432. Assuming you haven't changed the default, this is the port to use. To connect from your JSP page:

     .
     .
     .

        String db = new String("jdbc:postgresql://localhost:8080/my_test");
        String usr = new String("username");
        String pwd = new String("password");

        Class.forName("org.postgresql.Driver");
                                     // Load database interface

        Connection conn =
            DriverManager.getConnection( db, usr, pwd );
     .
     .
     .

HTH.

--Steve
0
 
LVL 4

Expert Comment

by:sdussinger
ID: 6336553
Oops. Botched the previous code. The 8080 should read 5432, of course...

--Steve
0
 

Author Comment

by:mkngau
ID: 6336636
hi steve,
   thanks for the help. But, do I need to make changes in the pg_hba.conf ?
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:mkngau
ID: 6336669
hi,
  I'm using postgres 7.1.2 so which jdbc driver is suitable for me? where can I get it?
   The error message is
ClassNotFoundException: Unable to load class postgresql.Driver SQLException: No suitable driver
0
 
LVL 4

Accepted Solution

by:
sdussinger earned 100 total points
ID: 6340097
1) The pg_hba.conf that is provided when postgres is first installed has a security policy which allows access by localhost and Unix sockets (not IP sockets.)

You'll probably have to add the address of your NT box to the pg_hba.conf file. The entry would look something like:

host   all   192.168.1.1   255.255.255.255   trust

That would allow full access from the IP 192.168.1.1

2) The JDBC driver is in /usr/lib/pgsql/jdbc7.0-1.2.jar. You'll need to ensure that your servlet has this in its classpath in order to find the driver.

--Steve
0
 

Author Comment

by:mkngau
ID: 6342995
Thanks steve,
    Thank you for your help. I have solved my problem.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to change the nameserver on Ubuntu Server 6 76
how to include conditional log rotate in liunx. 17 70
NTPD Client Port Usage 12 65
Advice on ESXi 5.1 Health / Storage 1 45
The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question