Re: Postgres and JDBC?!
From: EricF (efriedNoSpam_at_yahoo.com)
Date: 01/28/05
- Next message: znaps1: "Re: Access / inserting binary data with PreparedStatement"
- Previous message: Joe Weinstein: "Re: Access / inserting binary data with PreparedStatement"
- In reply to: tem2: "Postgres and JDBC?!"
- Next in thread: Dr.Adolf Daniel: "Re: Postgres and JDBC?!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: znaps1: "Re: Access / inserting binary data with PreparedStatement"
- Previous message: Joe Weinstein: "Re: Access / inserting binary data with PreparedStatement"
- In reply to: tem2: "Postgres and JDBC?!"
- Next in thread: Dr.Adolf Daniel: "Re: Postgres and JDBC?!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|