Problem with connection from win to linux

Поиск
Список
Период
Сортировка
Искать

Problem with connection from win to linux

От:
skala@gympoh.edu.sk
Дата:
Hello,

I have problem with connection on Postgres through JDBC driver, from my 
windows computer to linux server, where is a Postgres database.
Rexo is a linux server name.

Postmaster is running ok and it accepts tcp/ip connection. I have this tested 
through small PHP script, located on my win computer. PHP works well. But JDBC 
ends with error:
Connection refused. Check that the hostname and port is correct, and that the 
postmaster is running with the -i flag, which enables TCP/IP networking. 

I have testet three jdbc driver, but the error remains.

The pg_hba file is OK and I think, the postmaster.conf too, but PHP works.

Can anybody help me ? Thanks.

Michal

Here is servlet source:

/*
 * Created on 6.9.2004
*/
package j2src.michal;

import java.io.*;
import java.io.IOException;
import java.sql.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class DBTest extends HttpServlet {

    protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException 
{
        PrintWriter out = response.getWriter();
        try {
            Class.forName("org.postgresql.Driver");
            Connection con = DriverManager.getConnection
("jdbc:postgresql://rexo:5432/test", "root", "michal");
            PreparedStatement pr = con.prepareStatement("Select * from 
t_user");
            ResultSet result = pr.executeQuery();
            while (result.next()) {
                String pole = result.getString("login")+"
"; out.println(pole); } } catch (SQLException ex) { out.println(ex.getMessage()); } catch (ClassNotFoundException exnf) { out.println(exnf.getMessage()); } } } PHP script: "; $i++; endwhile; pg_Close($conn); ?>
FAQ