Обсуждение: How connect JDBC

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

How connect JDBC

От
Gabriel García
Дата:
I have a program's java, and I need read a Postgres database, How I can call
the database from java.
Thanks in advance.


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


Re: How connect JDBC

От
Peter T Mount
Дата:
Quoting Gabriel García <gaby3011@yahoo.com.ar>:

> I have a program's java, and I need read a Postgres database, How I can
> call
> the database from java.
> Thanks in advance.

Best thing is to check java.sun.com/jdbc/ and go through the basics.

I have the basic tutorial written and ready to upload except it's on the laptop
at home, so it's going to be Saturday morning before it go's online.

Peter

--
Peter Mount peter@retep.org.uk
PostgreSQL JDBC Driver: http://www.retep.org.uk/postgres/
RetepPDF PDF library for Java: http://www.retep.org.uk/pdf/

RE: How connect JDBC

От
"Raghunath T"
Дата:
Hey Gabriel,
    I think the following mail to you describes everything that you need
to connect to database with java. If something is not working, check your
pg_hba.conf file and start postmaster with the -i option. You could use the
following command for that
    pg_ctl -o "-i" start

Regards,
Raghunath T


-----Original Message-----
From:    Raghunath T
Sent:    Wed 4/4/2001 9:41 PM
To:    Gabriel García
Cc:
Subject:    RE: [JDBC] How connect JDBC

Hi,
    you'll have to first build the jdbc driver. Typically it would be
postgresql.jar.
    For this you go to postgresql-7.0.2/src/interfaces/jdbc and then type
make jdbc1 or make jdbc2 (if you need j2se support)
    This will give you postgresql.jar file
    update ur classpath env variable to include the full path of
postgresql.jar.
    Then in your code add
        Class.forName("org.postgresql.Driver");
        java.sql.Connection conn =
DriverManager.getConnection("jdbc:postgresql://<host ip>:<port
no>/dbname","<username>","<password>");
    host ip : is the ip address of the host. could be something like
172.20.20.1
    port : usually it is 5432 unless you are running postmaster on some
other port.
    If your java code is on the same machine as your database then you
need not give ip and port.
    You could just say "jdbc:postgresql:<dbname>"

    I hope this should be sufficient :-))


Regards,
Raghunath T
-----Original Message-----
From:    Gabriel García
Sent:    Wed 4/4/2001 9:18 PM
To:    pgsql-jdbc@postgresql.org
Cc:
Subject:    [JDBC] How connect JDBC

I have a program's java, and I need read a Postgres database, How I can call
the database from java.
Thanks in advance.


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster