X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B7912D1C4ED for ; Mon, 4 Aug 2003 21:18:52 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 51254-02 for ; Mon, 4 Aug 2003 18:17:37 -0300 (ADT) Received: from smtp6.mindspring.com (smtp6.mindspring.com [207.69.200.110]) by svr1.postgresql.org (Postfix) with ESMTP id DBF05D1C4E1 for ; Mon, 4 Aug 2003 18:18:41 -0300 (ADT) Received: from [192.168.167.45] (helo=wamui07.slb.atl.earthlink.net) by smtp6.mindspring.com with esmtp (Exim 3.33 #1) id 19jmj5-0000fF-00; Mon, 04 Aug 2003 17:18:43 -0400 Received: from [192.168.167.59] by EarthlinkWAM via HTTP; Mon Aug 04 17:18:43 EDT 2003 Message-ID: <2973583.1060031923212.JavaMail.nobody@wamui07.slb.atl.earthlink.net> Date: Mon, 4 Aug 2003 17:17:50 -0400 (GMT) From: "Scot P. Floess" To: Ripon Al Wasim , pgsql-jdbc@postgresql.org Subject: Re: Connection problem Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_5677_6691298.1060031923203" X-Mailer: Earthlink Web Access Mail version 3.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/35 X-Sequence-Number: 7874 ------=_Part_5677_6691298.1060031923203 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Do you have the appropriate postgres jar in your class path? Original message attached. ------=_Part_5677_6691298.1060031923203 Content-Type: TEXT/HTML; name=MESSAGE.HTML; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=MESSAGE.HTML
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 ------=_Part_5677_6691298.1060031923203--