Re: Struts to Postgresql db connection refused
On 9/13/05, David G. Friedman [EMAIL PROTECTED] wrote: Raj, Have you double checked that you can reach it from the command line on the server BEFORE trying it in Tomcat? I've encountered problems where a slight mistake in the MySQL configuration often causes this problem, not usually the web server. From the information you provided, try this at a command line (should work for a UNIX shell or Windows CMD.EXE, not sure about Macs): mysql -upostgres -ppostgresq -h192.168.1.22 -P5432 omsdb Connecting to PostgreSQL using the mysql command line tool ??!!?!! This will never work The right suggestion is to try connecting with : psql -h 192.168.1.22 -U postgres omsdb If connecting this way does not work , you need to : 1. configure postgres to allow TCP/IP connections (postgresql.conf) 2. add the ip adresses/networks that are allowed to connect (pg_hba.conf) The two files (pg_hba.conf and postgresql.conf) are located in the PostgreSQL's data directory . Cheers, Adrian Maier Regards, David -Original Message- From: R Rajendran [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 13, 2005 8:00 AM To: user@struts.apache.org Subject: Struts to Postgresql db connection refused Hi, When I connect Struts to Postgresql 8.0 database using DataSource object I get the following error messages: Source: DataSource dataSource = null; try { dataSource = getDataSource(request); conn = dataSource.getConnection(); stmt = conn.createStatement(); String sql = select * from stocks where + symbol =' + symbol + '; rs = stmt.executeQuery(select * from stocks where + symbol =' + symbol + '); }catch(){..} * struts-config.xml: data-source type=org.postgresql.jdbc2.optional.SimpleDataSource set-property property=driverClassName value=org.postgresql.Driver / set-property property=url value=jdbc:postgresql://192.168.1.22:5432/omsdb / set-property property=username value=postgres / set-property property=password value=postgres / /data-source * I am getting the following error message while running the struts application: INFO: Failed to create a non-pooled connection for null at jdbc:postgresql://localhost/null?prepareThreshold=0: org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. Tried starting Postmaser with -i option still not responding. Could anyone tell me how to resolve this issue. Thanks Raj - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts to Postgresql db connection refused
On 9/13/05, David G. Friedman [EMAIL PROTECTED] wrote: Raj, Have you double checked that you can reach it from the command line on the server BEFORE trying it in Tomcat? I've encountered problems where a slight mistake in the MySQL configuration often causes this problem, not usually the web server. From the information you provided, try this at a command line (should work for a UNIX shell or Windows CMD.EXE, not sure about Macs): mysql -upostgres -ppostgresq -h192.168.1.22 -P5432 omsdb Connecting to PostgreSQL using the mysql command line tool ??!!?!! This will never work The right suggestion is to try connecting with : psql -h 192.168.1.22 -U postgres omsdb If connecting this way does not work , you need to : 1. configure postgres to allow TCP/IP connections (postgresql.conf) 2. add the ip adresses/networks that are allowed to connect (pg_hba.conf) The two files (pg_hba.conf and postgresql.conf) are located in the PostgreSQL's data directory . Cheers, Adrian Maier Regards, David -Original Message- From: R Rajendran [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 13, 2005 8:00 AM To: user@struts.apache.org Subject: Struts to Postgresql db connection refused Hi, When I connect Struts to Postgresql 8.0 database using DataSource object I get the following error messages: Source: DataSource dataSource = null; try { dataSource = getDataSource(request); conn = dataSource.getConnection(); stmt = conn.createStatement(); String sql = select * from stocks where + symbol =' + symbol + '; rs = stmt.executeQuery(select * from stocks where + symbol =' + symbol + '); }catch(){..} * struts-config.xml: data-source type=org.postgresql.jdbc2.optional.SimpleDataSource set-property property=driverClassName value=org.postgresql.Driver / set-property property=url value=jdbc:postgresql://192.168.1.22:5432/omsdb / set-property property=username value=postgres / set-property property=password value=postgres / /data-source * I am getting the following error message while running the struts application: INFO: Failed to create a non-pooled connection for null at jdbc:postgresql://localhost/null?prepareThreshold=0: org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. Tried starting Postmaser with -i option still not responding. Could anyone tell me how to resolve this issue. Thanks Raj - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]