Re: Postgres and JDBC?!

From: EricF (efriedNoSpam_at_yahoo.com)
Date: 01/28/05


Date: Fri, 28 Jan 2005 04:42:54 GMT

In article <ctb333$qd$1@oheron.kent.ac.uk>, "tem2" <tem2@kent.ac.uk> wrote:
>Hi
>
>Can anyone tell me how to establish a connection to the University Postgres
>database using JDBC. I've looked at loads of books and Web sites on the
>topic but I can't really get my head around it!
>
>This is what I've got but it's not working:
>
>import java.sql.*;
>
>public class Connect
>{
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
>
> String url = "jdbc:odbc:PostgreSQL";
> Connection con = DriverManager.getConnection(penguin.kent.ac.uk,
>"myusername", "mypassword");
>
>}
>
>Any help would be really helpful.
>
>Thanks in advance.

I'd start with Google but I don't have a clue why you are trying to use the
jdbc odbc bridge. You need a postgress driver ...

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

As well as the correct classpath to it.

You define a url and you don't use it. What you have for the url should be the
driver you try to load. Your url should look something like ...

jdbc:postgresql://host:port/database
host is probably the penguin.kent...string, Postgres usually has a default
port of 5432. Now what the database should be - better ask the professor.

Eric



Relevant Pages

  • Re: Postgres and JDBC?!
    ... > database using JDBC. ... I've looked at loads of books and Web sites on the ...
    (comp.lang.java.help)
  • Re: Postgres and JDBC?!
    ... > database using JDBC. ... I've looked at loads of books and Web sites on the ...
    (comp.lang.java.databases)
  • Re: Postgres and JDBC?!
    ... >Can anyone tell me how to establish a connection to the University Postgres ... >database using JDBC. ... I've looked at loads of books and Web sites on the ... Now what the database should be - better ask the professor. ...
    (comp.lang.java.help)
  • Re: Postgres PL/Python
    ... > I wonder if anyone on this list is using Python as Postgres ... It sounds like I have the whole Python ... code between database and clients when the clients are written in Python ...
    (comp.lang.python)
  • Re: Postrgres data restoration problem (which NG to post to?)
    ... I could not find a postgres group, nor a linux database group. ... what format is the backup in: is it a copy of the database ... Then, use psql to connect to template1, then restore the backup as ...
    (comp.os.linux.development.apps)