Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6944827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:21:28+00:00 2026-05-27T13:21:28+00:00

I’ve installed postgresql 9.1 for Windows but I can’t connect to it using JDBC.

  • 0

I’ve installed postgresql 9.1 for Windows but I can’t connect to it using JDBC.

I’ve downloaded the JDBC jar file and placed it in C:\Program Files\Java\jre7\lib\postgresql-9.1-901.jdbc4.jar, my CLASSPATH is: .;C:\Program Files\Java\jre6\lib\ext\QTJava.zip;C:\Program Files\Java\jre7\lib\postgresql-9.1-901.jdbc4.jar

This is my Java code to create the connection:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.util.*;
import java.io.*;

public class CreateInsert extends Object {
    public static void main (String args[]) {

        //Create the connection
        String driverName = "org.postgresql.Driver";
        String connectURL = "jdbc:postgresql://localhost/postgres";
        String USERNAME = "postgres";
        String PASSWORD = "password";
        Connection con = null;
        try {
            Class.forName("org.postgresql.Driver");
            con = DriverManager.getConnection(connectURL, USERNAME, PASSWORD);
        } catch (ClassNotFoundException e) {
            System.out.println("Error creating class: "+e.getMessage());
            System.out.println("The Driver was not found, Please check driver location, classpath, username/password and server url settings");
            System.exit(0);
        } catch (SQLException e) {
            System.out.println("Error creating connection: "+e.getMessage());
            System.exit(0);
        }
    }
}

And I get the error “Error creating class: org.postgresql.Driver”

Any ideas as to what’s wrong?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:21:29+00:00Added an answer on May 27, 2026 at 1:21 pm

    I’m using JCreator to compile and run.

    The CLASSPATH environment variable is only used when you use java.exe command without -cp, -classpath and -jar arguments. Any other way you use to execute the Java application ignores this environment variable. This includes executing the application inside an IDE like Eclipse, Netbeans and JCreator.

    In an IDE, you instead need to drop the JAR in the project and add it to the “Build Path” if not done automatically by the IDE yet, depending on the project’s structure. This is often a matter of rightclicking the JAR in project and choosing “Add to Build Path” somewhere in the context menu.

    Forget about using the CLASSPATH environment variable. It was a mistake by Sun. They thought to convince starters by avoiding to enter the -cp or -classpath arguments everytime for javac/java commands. But it end up to be only more confusing to starters as they interpret that environment variable as “the” classpath.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.