pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ripon Al Wasim <riponc007@yahoo.com>
To: pgsql-jdbc@postgresql.org
Subject: Connection problem
Date: Sun, 3 Aug 2003 23:37:19 -0700 (PDT)
Message-ID: <20030804063719.39549.qmail@web14005.mail.yahoo.com> (raw)

hello,
I wanna connet between java and PostgreSQL. Here is the code:
 
import java.sql.*;
public class DBConnection
{
 public void connection()
 {
  String pgsqlDriver = "org.postgresql.Driver";
  //String pgsqlURL = "jdbc:postgresql://host:5432/mydb";
  String pgsqlURL = "jdbc:postgresql://192.168.0.165/testdb";
  String pgsqlUser = "User";
  String pgsqlPW = "password";
  String pgsqlQuery = null;
  Connection pgsqlConn = null;
  Statement pgsqlStatement = null;
  ResultSet pgsqlRSet = null;
  try
  {
    Class.forName(pgsqlDriver);
    pgsqlConn = DriverManager.getConnection(pgsqlURL, pgsqlUser, pgsqlPW);
    pgsqlStatement = pgsqlConn.createStatement();
    pgsqlQuery = "SELECT * FROM users;";
    pgsqlRSet = pgsqlStatement.executeQuery(pgsqlQuery);
  }
  catch (ClassNotFoundException cnfe)
  {
    System.out.println("Could not load database driver:" + cnfe.getMessage());
  }
  catch (SQLException sqle)
  {
    System.out.println("Could not connect to the database: " + sqle.getMessage());
  }
  finally
  {
    try
    {
   if ( pgsqlConn != null )
   {
   // Close the connection no matter what.
   pgsqlConn.close();
   }
    }
    catch (SQLException sqle)
    {
   System.out.println("Could not connect to the database(2): " + sqle.getMessage());
    }
  }//finally
 }//end connection()
 public static void main(String args[])
 {
  new DBConnection().connection();
 }
}//class
 
The code is compile well. But here is a runtime problem. The prolem is:
 
Could not load database driver :org.postgresql.Driver
 
Is there anybody to help me?
 
thanking u,
Ripon
 


---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

view thread (24+ messages)  latest in thread

Message-ID: <20030804063719.39549.qmail@web14005.mail.yahoo.com>
Permalink:  ../20030804063719.39549.qmail@web14005.mail.yahoo.com/
Also on:    postgresql.org/message-id/20030804063719.39549.qmail@web14005.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: riponc007@yahoo.com
  Subject: Re: Connection problem
  In-Reply-To: <20030804063719.39549.qmail@web14005.mail.yahoo.com>
  References: <20030804063719.39549.qmail@web14005.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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