#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2001
    Posts
    24
    Rep Power
    0

    Problems with JDBC and Postgresql


    Environment Info:
    OS: Windows 2000
    sdk: 1.4.1_03
    DB: Postgresql 7.3.3 running on RedHat 8.0 (accepting TCP connections)

    Hello,

    I am fairly new to JAVA and I am having some problems connecting to a Postgresql DB. I have downloaded the JDBC
    driver (pg73odbc3.jar) from http://jdbc.postgresql.com, placed it in e:\j2sdk1.4.1_03\jre\lib\ext and created a environment variable called CLASSPATH with the value: e:\j2sdk1.4.1_03\jre\lib\ext\pg73odbc3.jar.

    For some reason I am still getting a class not found exception when I run the code (the code is run from the command line). Does anyone have any ideas as to why I keep get this exception? I am running out of options and hoped someone here might be able to shed some light on my problem.

    Pertinent Code:
    Code:
                    try {
                        Class.forName("org.postgresql.Driver");                            
                        String url   = "jdbc:postgresql://192.168.1.101:5432/test";
                        Connection db = DriverManager.getConnection(url, "username", "password");                    
                    } catch (Exception e) {
                        System.err.println("Exception: " + e + "\n" + e.getMessage() );
                    }

    Thanks...
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    No es importante
    Posts
    2,065
    Rep Power
    14
    What operating system are you using? If you perform an echo %classpath% from the command line what do you get?
    ...
    Fix reference the directory where the pg83odbc3.jar file is with the cp -classpath argument when using javac and java.
    java -cp .\;e:\j2sdk...\...\ext\;
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2001
    Posts
    24
    Rep Power
    0
    I am using Windows 2000.
    When I try echo %classpath% I get:

    .;e:\j2sdk1.4.1_03\jre\lib\ext\pg73jdbc3.jar
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    No es importante
    Posts
    2,065
    Rep Power
    14
    Try adding the directory to your classpath at compilation time. Also, try adding just e:\j2sdk1.4.1_03\jre\lib\ext\ to your system classpath, reboot your system and verify that the classpath is in the environment variables.

IMN logo majestic logo threadwatch logo seochat tools logo