Обсуждение: Problems connecting to database

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

Problems connecting to database

От
burferd
Дата:
I just started working with postgre.

I found a couple of connection examples on the net that I followed,
but I am still not able to connect to the database from within my
application.

I get the following error message:
Connection refused.
Check that the host name and port and that the postmaster is accepting
TCP/IP connections.

I'm using Netbeans 6.1 and I added the postgre jdbc drivers to the project.
It appears that I am getting the driver, but I am not connecting to the
database.

Here is what I am using to connect - I don't see why it is not connecting.

     String dbName = "jdbc:postgresql://localhost:5430/HostDB";
           Class.forName("org.postgresql.Driver");
            dbConn = DriverManager.getConnection( dbName, dbUser, dbPasswd
);

I can connect in pgAdminIII using the same user and password, so the
database recognizes the user.
The database name "HostDB" is the correct name and I'm using the default
port of 5430.

I'm not sure what the postmaster reference is telling me -
is there some flag on the database I need to set???

What else can I check?

Thanks


--
View this message in context: http://www.nabble.com/Problems-connecting-to-database-tp19616295p19616295.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.


Re: Problems connecting to database

От
burferd
Дата:
I found the problem - I thought I was using the default port, but I just
noticed that the
database is using a different port.

It connects just fine now.

Sorry for the unnecessary post.


burferd wrote:
>
> I just started working with postgre.
>
> I found a couple of connection examples on the net that I followed,
> but I am still not able to connect to the database from within my
> application.
>
> I get the following error message:
> Connection refused.
> Check that the host name and port and that the postmaster is accepting
> TCP/IP connections.
>
> I'm using Netbeans 6.1 and I added the postgre jdbc drivers to the
> project.
> It appears that I am getting the driver, but I am not connecting to the
> database.
>
> Here is what I am using to connect - I don't see why it is not connecting.
>
>      String dbName = "jdbc:postgresql://localhost:5430/HostDB";
>            Class.forName("org.postgresql.Driver");
>             dbConn = DriverManager.getConnection( dbName, dbUser, dbPasswd
> );
>
> I can connect in pgAdminIII using the same user and password, so the
> database recognizes the user.
> The database name "HostDB" is the correct name and I'm using the default
> port of 5430.
>
> I'm not sure what the postmaster reference is telling me -
> is there some flag on the database I need to set???
>
> What else can I check?
>
> Thanks
>
>
>

--
View this message in context: http://www.nabble.com/Problems-connecting-to-database-tp19616295p19616433.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.