pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
PROBLEM WITH DRIVER LOAD
2+ messages / 2 participants
[nested] [flat]

* PROBLEM WITH DRIVER LOAD
@ 2006-01-18 15:03 Wagner <wagner.and@gmail.com>
  2006-01-18 15:37 ` Re: PROBLEM WITH DRIVER LOAD Guillaume Cottenceau <gc@mnc.ch>
  0 siblings, 1 reply; 2+ messages in thread

From: Wagner @ 2006-01-18 15:03 UTC (permalink / raw)
  To: pgsql-jdbc

Hi, i'm new in jdbc and
my problem is, the driver doesn't load,
the code is:

public static void connect(){
        try{
            Class.forName("org.postgresql.Driver");
        }catch(ClassNotFoundException cnfex){
            System.err.println("driver load fail");

//the problem is here, i don't know what library i need and what i need to
do with the classpath to this works,
//when compile to bytecode the error message is:
/*
driver load fail
Exception in thread "main" java.lang.NullPointerException
    at DB.DBAccess.connect(DBAccess.java:45)
    at DB.DBAccess.begin(DBAccess.java:81)
    at Simulator.main(Simulator.java:23)
*/
        }

        String url = "jdbc:postgresql://localhost/projeto";
        Properties props = new Properties();
        props.setProperty("user","postgres");
        props.setProperty("password","postgres");

        try{
            Connection con = DriverManager.getConnection(url, props);
        }catch(SQLException sql){}

        try{
            statement = con.createStatement();
        }catch(SQLException sql){}


            /*try{
                con = DriverManager.getConnection("postgres:projeto:localhost",
"postgres", "usuario1");
            }
            catch(SQLException sql){}
        */

    }
If anyone have some idea about it thanks a lot, this is my last chance to
solve this problem,
i have tryed many other forms to solve this, but i still have the problem

--
******************************************************
"Ciência da computação está tão relacionada
aos computadores quanto a Astronomia aos
telescópios, Biologia aos microscópios, ou
Química aos tubos de ensaio. A Ciência não
estuda ferramentas. Ela estuda como nós
as utilizamos, e o que descobrimos com elas."
                                       (Edsger W. Dijkstra)
*******************************************************

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: PROBLEM WITH DRIVER LOAD
  2006-01-18 15:03 PROBLEM WITH DRIVER LOAD Wagner <wagner.and@gmail.com>
@ 2006-01-18 15:37 ` Guillaume Cottenceau <gc@mnc.ch>
  0 siblings, 0 replies; 2+ messages in thread

From: Guillaume Cottenceau @ 2006-01-18 15:37 UTC (permalink / raw)
  To: Wagner <wagner.and@gmail.com>; +Cc: pgsql-jdbc

Wagner <wagner.and 'at' gmail.com> writes:

> Hi, i'm new in jdbc and
> my problem is, the driver doesn't load,
> the code is:
> 
> public static void connect(){
>         try{
>             Class.forName("org.postgresql.Driver");
>         }catch(ClassNotFoundException cnfex){
>             System.err.println("driver load fail");
> 
> //the problem is here, i don't know what library i need and what i need to
> do with the classpath to this works,

As documented in multiple places, you have to put the
postgresql.jar in your classpath. This depends on your java
environment, but generally you can achieve this by using the
"-cp" argument to the "java" program you invoke.

-- 
Guillaume Cottenceau



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2006-01-18 15:37 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-01-18 15:03 PROBLEM WITH DRIVER LOAD Wagner <wagner.and@gmail.com>
2006-01-18 15:37 ` Guillaume Cottenceau <gc@mnc.ch>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox