Обсуждение: Fatal: Database does not exist

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

Fatal: Database does not exist

От
"Suvanaket, Dear (MS)"
Дата:
 
Hi,
 
I get the error "FATAL: Database "xxx" does not exist" when trying to connect to the database using JDBC. The superuser "postgres" owns my database and tables. However, it seems I can only connect to the database when the username matches the name of the database I am connecting to. I can't connect to the database as the superuser postgres who owns the database. For example, if my database were named "Trudy", I can only connect with a user named "Trudy".
 
The Java code I'm using to connect looks something like this:
 
  try{
         //Register the JDBC driver for PostgreSQL.
         Class.forName(driverType);
              
         //Get a connection to the database
         Connection conn = DriverManager.getConnection(url, username, password);
         PreparedStatement ps =
             conn.prepareStatement(jsassql);
           ps.execute();
           conn.close();
      }
      catch(Exception e){
         e.printStackTrace();
      }
 
Is there anyway to fix the access so I can use a superuser other than the one named after the database?
 

Re: Fatal: Database does not exist

От
Scott Marlowe
Дата:
On Fri, Feb 27, 2009 at 2:41 PM, Suvanaket, Dear (MS)
<Dear.Suvanaket@ngc.com> wrote:
>
> Hi,
>
> I get the error "FATAL: Database "xxx" does not exist" when trying to
> connect to the database using JDBC. The superuser "postgres" owns my
> database and tables. However, it seems I can only connect to the database
> when the username matches the name of the database I am connecting to. I

What does your pg_hba.conf file say?