Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 135F69FB437 for ; Tue, 26 Sep 2006 12:43:43 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 59443-08 for ; Tue, 26 Sep 2006 12:43:38 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from socrates.thinkhost.com (mailpipe.socrates.thinkhost.com [64.40.100.194]) by postgresql.org (Postfix) with ESMTP id ABDFC9FB421 for ; Tue, 26 Sep 2006 12:43:37 -0300 (ADT) Received: from geier (adsl-64-91-71-139-rb.lax.customer.centurytel.net [64.91.71.139]) by socrates.thinkhost.com (8.13.6/8.13.5) with SMTP id k8QFgfZH045946 for ; Tue, 26 Sep 2006 11:42:42 -0400 (EDT) (envelope-from jgeier@apt-cafm.com) Message-ID: <012701c6e182$855cd710$6700a8c0@geier> From: "Jeanna Geier" To: Subject: Beginner's Question: No pg_hba.conf entry for host...SSL Off Date: Tue, 26 Sep 2006 10:43:32 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0124_01C6E158.9C2C2BF0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 X-Antivirus: avast! (VPS 0639-2, 09/26/2006), Outbound message X-Antivirus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.03 tagged_above=0 required=5 tests=AWL, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200609/123 X-Sequence-Number: 15841 This is a multi-part message in MIME format. ------=_NextPart_000_0124_01C6E158.9C2C2BF0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi All- I am hoping for some help on this one... we are in the process of = implementing our program with SSL enabled on the Postgres side of = things. I can start and connect to the database from the command line ok = using my current configuration: C:\msys\1.0\local\pgsql\bin>psql -d apt -U postgres Welcome to psql 8.0.8, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256) Warning: Console code page (437) differs from Windows code page = (1252) 8-bit characters may not work correctly. See psql reference page "Notes for Windows users" for details. apt=3D# However, when I try to run our application to and connect to the = database, I am receiving the following error: Connection rejected: = FATAL: no pg_hba.conf entry for host "127.0.0.1", user "postgres", = database "apt", SSL off. Here is my pg_hba.conf file: # TYPE DATABASE USER CIDR-ADDRESS METHOD # IPv4 local connections: #host all all 127.0.0.1/32 trust # IPv6 local connections: hostssl all all 127.0.0.1/32 trust I know I need to add some code to enable the SSL connection but am not = exactly sure how to go about this and what I've tried thus far hasn't = worked... Below is an excerpt of our connection code: public class DatabaseConnection { private static String DB_IP; private static final String DB_PORT =3D "5432"; private static String DB_CATALOG =3D "apt"; private static final String DB_USER =3D "postgres"; private static final String DB_PASSWORD =3D "XXXX"; public static void initIPAddress(String address){ DB_IP =3D address; } public static void initCatalog(String catalog){ DB_CATALOG =3D catalog; } public static Connection initialize() throws SQLException { final Connection connection; Properties prop =3D new Properties(); String url; try{ Class.forName("org.postgresql.Driver"); //url =3D "jdbc:postgresql://64.34.162.40:5432/apt"; url =3D "jdbc:postgresql://" + DB_IP + ":" + DB_PORT + "/" +=20 DB_CATALOG; //prop.setProperty("user","postgres"); //prop.setProperty("password", "XXXX"); prop.setProperty("user", DB_USER); prop.setProperty("password", DB_PASSWORD); connection =3D DriverManager.getConnection(url, prop); connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED)= ; if(connection =3D=3D null){ throw new Exception(); } Thread maintainConn =3D new Thread(new Runnable(){ public void run(){ while(connection !=3D null){ try{ maintainConnection(connection); //10 minutes Thread.sleep(600000); } catch(InterruptedException ie){} } } }); maintainConn.setDaemon(true); maintainConn.start(); } catch(ClassNotFoundException cnf){ throw new SQLException(cnf.getMessage()); } catch(Exception e){ throw new SQLException(e.getMessage()); } return connection; } I've tried the following with the 'prop.setProperty("ssl","true) = parameter - added: private static final String DB_SSL_STATUS =3D "true"; & prop.setProperty("ssl", DB_SSL_STATUS); ... public class DatabaseConnection { private static String DB_IP; private static final String DB_PORT =3D "5432"; private static String DB_CATALOG =3D "apt"; private static final String DB_USER =3D "postgres"; private static final String DB_PASSWORD =3D "XXXX"; private static final String DB_SSL_STATUS =3D "true"; public static void initIPAddress(String address){ DB_IP =3D address; } public static void initCatalog(String catalog){ DB_CATALOG =3D catalog; public static Connection initialize() throws SQLException { final Connection connection; Properties prop =3D new Properties(); String url; try{ Class.forName("org.postgresql.Driver"); //url =3D "jdbc:postgresql://64.34.162.40:5432/apt"; url =3D "jdbc:postgresql://" + DB_IP + ":" + DB_PORT + "/" +=20 DB_CATALOG; //prop.setProperty("user","postgres"); //prop.setProperty("password", "XXXX"); //prop.setProperty("ssl", "true"); prop.setProperty("user", DB_USER); prop.setProperty("password", DB_PASSWORD); prop.setProperty("ssl", DB_SSL_STATUS); connection =3D DriverManager.getConnection(url, prop); connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED)= ; if(connection =3D=3D null){ throw new Exception(); } Thread maintainConn =3D new Thread(new Runnable(){ public void run(){ while(connection !=3D null){ try{ maintainConnection(connection); //10 minutes Thread.sleep(600000); } catch(InterruptedException ie){} } } }); maintainConn.setDaemon(true); maintainConn.start(); } catch(ClassNotFoundException cnf){ throw new SQLException(cnf.getMessage()); } catch(Exception e){ throw new SQLException(e.getMessage()); } return connection; } However, when I do that, it's throwing an exception from: connection =3D = DriverManager.getConnection(url, prop); and I'm getting an error message that says: "The connection attempt = failed." Any ideas from Java experts would be greatly appreciated! This is = something I need to get resolved rather quickly... Thanks much!! -Jeanna ------=_NextPart_000_0124_01C6E158.9C2C2BF0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi All-

I am hoping for some help on this one... we are in = the=20 process of implementing our program with SSL enabled on the Postgres = side of=20 things. I can start and connect to the database from the command line ok = using=20 my current configuration:

   =20 C:\msys\1.0\local\pgsql\bin>psql -d apt -U = postgres
   =20 Welcome to psql 8.0.8, the PostgreSQL interactive=20 terminal.

    Type: \copyright for distribution=20 terms
        \h for help with SQL=20 commands
        \? for help with psql=20 commands
        \g or terminate with = semicolon=20 to execute query
        \q to=20 quit

    SSL connection (cipher: = DHE-RSA-AES256-SHA, bits:=20 256)

    Warning: Console code page (437) differs = from=20 Windows code page (1252)
        8-bit=20 characters may not work correctly. See psql = reference
   =20     page "Notes for Windows users" for=20 details.

    apt=3D#

However, when I try to = run our=20 application to and connect to the database, I am receiving the following = error:=20 Connection rejected: FATAL: no pg_hba.conf entry for host "127.0.0.1", = user=20 "postgres", database "apt", SSL off.

Here is my pg_hba.conf=20 file:

    # TYPE DATABASE USER CIDR-ADDRESS=20 METHOD
    # IPv4 local = connections:
   =20 #host all all 127.0.0.1/32 trust
    # IPv6 local=20 connections:
    hostssl all all 127.0.0.1/32 = trust

I=20 know I need to add some code to enable the SSL connection but am not = exactly=20 sure how to go about this and what I've tried thus far hasn't worked... = Below is=20 an excerpt of our connection code:

public class = DatabaseConnection=20 {
private static String DB_IP;

private static final String = DB_PORT =3D=20 "5432";
private static String DB_CATALOG =3D "apt";
private static = final=20 String DB_USER =3D "postgres";
private static final String = DB_PASSWORD =3D=20 "XXXX";

public static void initIPAddress(String = address){
DB_IP =3D=20 address;
}

public static void initCatalog(String=20 catalog){
DB_CATALOG =3D catalog;
}

public static = Connection=20 initialize() throws SQLException
{
final Connection=20 connection;
Properties prop =3D new Properties();
String=20 url;

try{
Class.forName("org.postgresql.Driver");

//url = =3D=20 "jdbc:postgresql://64.34.162.40:5432/apt";
url =3D = "jdbc:postgresql://" + DB_IP=20 + ":" + DB_PORT + "/" +=20
DB_CATALOG;

//prop.setProperty("user","postgres");
//prop.s= etProperty("password",=20 "XXXX");
prop.setProperty("user", = DB_USER);
prop.setProperty("password",=20 DB_PASSWORD);

connection =3D DriverManager.getConnection(url,=20 prop);
connection.setTransactionIsolation(Connection.TRANSACTION_READ_= COMMITTED);

if(connection=20 =3D=3D null){
throw new Exception();
}

Thread maintainConn = =3D new=20 Thread(new Runnable(){
public void run(){
while(connection !=3D=20 null){
try{
maintainConnection(connection);
//10=20 minutes
Thread.sleep(600000);
}
catch(InterruptedException=20 ie){}
}
}
});
maintainConn.setDaemon(true);
maintainConn.s= tart();
}
catch(ClassNotFoundException=20 cnf){
throw new = SQLException(cnf.getMessage());
}
catch(Exception=20 e){
throw new SQLException(e.getMessage());
}

return=20 connection;
}

I've tried the following with the 'prop.setProperty("ssl","true) = parameter=20 - added:

private static final String DB_SSL_STATUS =3D=20 "true";
&
prop.setProperty("ssl", = DB_SSL_STATUS);

...
public=20 class DatabaseConnection {
private static String = DB_IP;

private static=20 final String DB_PORT =3D "5432";
private static String DB_CATALOG =3D = "apt";
private static final String DB_USER =3D "postgres";
private = static=20 final String DB_PASSWORD =3D "XXXX";
private static final String = DB_SSL_STATUS=20 =3D "true";

public static void initIPAddress(String = address){
DB_IP =3D=20 address;
}

public static void initCatalog(String=20 catalog){
DB_CATALOG =3D catalog;
public static Connection = initialize()=20 throws SQLException
{
final Connection connection;
Properties = prop =3D=20 new Properties();
String=20 url;

try{
Class.forName("org.postgresql.Driver");

//url = =3D=20 "jdbc:postgresql://64.34.162.40:5432/apt";
url =3D = "jdbc:postgresql://" + DB_IP=20 + ":" + DB_PORT + "/" +=20
DB_CATALOG;

//prop.setProperty("user","postgres");
//prop.s= etProperty("password",=20 "XXXX");
//prop.setProperty("ssl", = "true");
prop.setProperty("user",=20 DB_USER);
prop.setProperty("password",=20 DB_PASSWORD);
prop.setProperty("ssl", = DB_SSL_STATUS);

connection =3D=20 DriverManager.getConnection(url,=20 prop);
connection.setTransactionIsolation(Connection.TRANSACTION_READ_= COMMITTED);

if(connection=20 =3D=3D null){
throw new Exception();
}

Thread maintainConn = =3D new=20 Thread(new Runnable(){
public void run(){
while(connection !=3D=20 null){
try{
maintainConnection(connection);
//10=20 minutes
Thread.sleep(600000);
}
catch(InterruptedException=20 ie){}
}
}
});
maintainConn.setDaemon(true);
maintainConn.s= tart();
}
catch(ClassNotFoundException=20 cnf){
throw new = SQLException(cnf.getMessage());
}
catch(Exception=20 e){
throw new SQLException(e.getMessage());
}

return=20 connection;
}


However, when I do that, it's throwing an = exception=20 from: connection =3D DriverManager.getConnection(url, prop);
and I'm = getting an=20 error message that says: "The connection attempt failed."

Any = ideas from=20 Java experts would be greatly appreciated! This is something I need to = get=20 resolved rather quickly...

Thanks = much!!
-Jeanna
------=_NextPart_000_0124_01C6E158.9C2C2BF0--