| From: | Ian Pilcher <i(dot)pilcher(at)comcast(dot)net> | 
|---|---|
| To: | pgsql-jdbc(at)postgresql(dot)org | 
| Subject: | Re: Problem w/ IDENT authentication | 
| Date: | 2004-07-26 15:46:53 | 
| Message-ID: | ce391e$3lm$1@sea.gmane.org | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-jdbc | 
Nick Fankhauser wrote:
> 
> How are you testing the user?
> 
> If you haven't already done it, I'd try adding:
> 
> System.out.println( System.getProperty("user.name") ) ;
> 
I've added a call to System.getProperty("user.name") to the servlet.
Here is the complete source code:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class HelloWorld extends HttpServlet
{
     public void doGet(HttpServletRequest request,
	    HttpServletResponse response)
     	    throws ServletException, IOException
     {
     	PrintWriter out = response.getWriter();
	out.println("Running as user '" +
		System.getProperty("user.name") + "'");
     	try
	{
	    Class.forName("org.postgresql.Driver");
	}
	catch (ClassNotFoundException cnfe)
	{
	    out.println("Error loading JDBC driver: " + cnfe);
	    return;
	}
	out.println("Successfully loaded JDBC driver");
	
	Connection db;
	
	try
	{
	    db = DriverManager.getConnection(
	    	    "jdbc:postgresql://127.0.0.1/tomcat4",
		    "tomcat4", "");
	}
	catch (SQLException sqle)
	{
	    out.println("Error connecting to database: " + sqle);
	    return;
	}
	
	out.println("Successfully connected to database");
	
	try
	{
	    db.close();
	}
	catch (SQLException sqle)
	{
	    out.println("Error closing database: " + sqle);
	    return;
	}
	
	out.println("Successfully closed database connection");
     }
}
And here is the output:
Running as user 'tomcat4'
Successfully loaded JDBC driver
Error connecting to database: org.postgresql.util.PSQLException: A 
connection error has occurred: org.postgresql.util.PSQLException: FATAL: 
IDENT authentication failed for user "tomcat4"
-- 
========================================================================
Ian Pilcher                                        i(dot)pilcher(at)comcast(dot)net
========================================================================
| From | Date | Subject | |
|---|---|---|---|
| Next Message | dgr | 2004-07-26 16:13:50 | SSL Connection Problems | 
| Previous Message | Tom Lane | 2004-07-26 15:17:59 | Re: Problem w/ IDENT authentication |