Re: Beginner's Question: No pg_hba.conf entry for host...SSL Off - Mailing list pgsql-jdbc
From | Jeanna Geier |
---|---|
Subject | Re: Beginner's Question: No pg_hba.conf entry for host...SSL Off |
Date | |
Msg-id | 026801c6e1a1$aadca910$6700a8c0@geier Whole thread Raw |
In response to | Beginner's Question: No pg_hba.conf entry for host...SSL Off ("Jeanna Geier" <jgeier@apt-cafm.com>) |
List | pgsql-jdbc |
Hi Dave- Thanks for the reply!! I should probably have prefaced this message with a disclaimer that I'm attempting to establish an SSL connection to the database. :o) I did as you said: uncommented the host line and restarted the server... and I am still getting an error "The connection attempt failed." However, if I comment out the connection parameter I added for the SSL connection: //prop.setProperty("ssl", DB_SSL_STATUS); and run the project, it runs OK; but that sort of defeats my purpose of establishing an SSL connection to the database. :o) So, if I can get this running with the SSL connection working, I'm going to be in business! When the program gets to this line: connection = DriverManager.getConnection(url, prop); -- the url is correct, and 'prop' has the values of 'ssl=true','user=postgres','password=XXXX' - all correct, but it throws an exception. Guess it doesn't like the new SSL parameter for some reason - Any ideas out there? Thanks much, -Jeanna ----- Original Message ----- From: "Dave Cramer" <pg@fastcrypt.com> To: "Jeanna Geier" <jgeier@apt-cafm.com> Cc: <pgsql-jdbc@postgresql.org> Sent: Tuesday, September 26, 2006 2:11 PM Subject: Re: [JDBC] Beginner's Question: No pg_hba.conf entry for host...SSL Off > Jeanna, > > Uncomment the host line with 127.0.0.1 and restart the server, then the > code below should work. > > Dave > On 26-Sep-06, at 2:57 PM, Jeanna Geier wrote: > >> Hello- Sorry to re-post this, but I'm sort of stuck on this one and >> can't move forward until I get it resolved.... I've been googling some >> more and looking on some Java sites and trying out some different things >> with no luck. If anyone could offer me some assistance on this one, I >> would be greatly appreciative. >> >> We're using Postgres 8.0.8 and Java JDK 1.5.0_06 on Windows... >> >> If you need to know anything else, please let me know. >> >> Thanks in advance, >> -Jeanna >> >> ----- Original Message ----- From: Jeanna Geier >> To: pgsql-jdbc@postgresql.org >> Sent: Tuesday, September 26, 2006 10:43 AM >> Subject: [JDBC] Beginner's Question: No pg_hba.conf entry for host...SSL >> Off >> >> >> 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=# >> >> 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 = "5432"; >> private static String DB_CATALOG = "apt"; >> private static final String DB_USER = "postgres"; >> private static final String DB_PASSWORD = "XXXX"; >> >> public static void initIPAddress(String address){ >> DB_IP = address; >> } >> >> public static void initCatalog(String catalog){ >> DB_CATALOG = catalog; >> } >> >> public static Connection initialize() throws SQLException >> { >> final Connection connection; >> Properties prop = new Properties(); >> String url; >> >> try{ >> Class.forName("org.postgresql.Driver"); >> >> //url = "jdbc:postgresql://64.34.162.40:5432/apt"; >> url = "jdbc:postgresql://" + DB_IP + ":" + DB_PORT + "/" + >> DB_CATALOG; >> >> //prop.setProperty("user","postgres"); >> //prop.setProperty("password", "XXXX"); >> prop.setProperty("user", DB_USER); >> prop.setProperty("password", DB_PASSWORD); >> >> connection = DriverManager.getConnection(url, prop); >> connection.setTransactionIsolation >> (Connection.TRANSACTION_READ_COMMITTED); >> >> if(connection == null){ >> throw new Exception(); >> } >> >> Thread maintainConn = new Thread(new Runnable(){ >> public void run(){ >> while(connection != 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 = "true"; >> & >> prop.setProperty("ssl", DB_SSL_STATUS); >> >> ... >> public class DatabaseConnection { >> private static String DB_IP; >> >> private static final String DB_PORT = "5432"; >> private static String DB_CATALOG = "apt"; >> private static final String DB_USER = "postgres"; >> private static final String DB_PASSWORD = "XXXX"; >> private static final String DB_SSL_STATUS = "true"; >> >> public static void initIPAddress(String address){ >> DB_IP = address; >> } >> >> public static void initCatalog(String catalog){ >> DB_CATALOG = catalog; >> public static Connection initialize() throws SQLException >> { >> final Connection connection; >> Properties prop = new Properties(); >> String url; >> >> try{ >> Class.forName("org.postgresql.Driver"); >> >> //url = "jdbc:postgresql://64.34.162.40:5432/apt"; >> url = "jdbc:postgresql://" + DB_IP + ":" + DB_PORT + "/" + >> 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 = DriverManager.getConnection(url, prop); >> connection.setTransactionIsolation >> (Connection.TRANSACTION_READ_COMMITTED); >> >> if(connection == null){ >> throw new Exception(); >> } >> >> Thread maintainConn = new Thread(new Runnable(){ >> public void run(){ >> while(connection != 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 = >> 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 >> >> ---------------------------(end of broadcast)--------------------------- >> TIP 5: don't forget to increase your free space map settings >> > >
pgsql-jdbc by date: