Thread: PLS HELP in connecting with jdbc driver

PLS HELP in connecting with jdbc driver

From
"Rohit Johry"
Date:
Hello,
 
I am a new user using the Postgre-sql for the first time please help me in establishing the connection between JDBC and POSTGRE.
 
POSTGRE >> 7.2.1
JAVA        >> 1.4.1_01
LINUX        >> 7.3
 
Having the CLASSPATH:
:/usr/share/pgsql/jdbc7.2dev-1.2.jar:/usr/lib/pgsql/pg72jdbc2.jar:/usr/java/j2sdk1.4.1_01/lib/*.jar
 
 
I got ERROR as
Sub : java.lang.ClassNotFoundException: org.postgresql:Driver
Rohit : java.sql.SQLException: No suitable driver
 
Here is my CODE       "JDBC_POSTGRE.java"
import java.sql.*;
 
class JDBC_POSTGRE
{
  public static void main(String args[])
  {
    Statement stmt1;
    ResultSet rs1;
    DatabaseMetaData dbmd1;
    try
    {
       try
       {
         Class.forName("org.postgresql.Driver");
         //Driver for POSTGRE-SQL :pg72jdbc2.jar
       }
       catch(Exception ex)
       {
         System.out.println("Sub : " + ex);
       }
       Connection conn1 = DriverManager.getConnection("jdbc:postgresql:AirTel_RTL", "", "");
       //AirTel_RTL is a database, user='', password=''
       stmt1 = conn1.createStatement();
       rs1 = stmt1.executeQuery("Select * from tonedata"); // 'tonedata' is a table in database
       while(rs1.next())
       {
         System.out.println(rs1.getInt("toneid") + "," + rs1.getString("tone_name") );
       }
    }
    catch(Exception e)
    {
      System.out.println("Rohit : "+e);
    }
  }
}
 
I am not professional in Linux.
Hoping you will replay me very soon.
 
With regards,
Rohit

Re: PLS HELP in connecting with jdbc driver

From
"Agrawal, Manish"
Date:
You need to install the JDBC driver in a specific location. Put the jar file
at <jdkhome>/jre/lib/ext

You should also see some other jar files there.

Manish
-----Original Message-----
From: Rohit Johry [mailto:rohit.johry@esteltelecom.com]
Sent: Wednesday, April 02, 2003 11:46 PM
To: pgsql-jdbc@postgresql.org
Subject: [JDBC] PLS HELP in connecting with jdbc driver


Hello,

I am a new user using the Postgre-sql for the first time please help me in
establishing the connection between JDBC and POSTGRE.

POSTGRE >> 7.2.1
JAVA        >> 1.4.1_01
LINUX        >> 7.3

Having the CLASSPATH:
:/usr/share/pgsql/jdbc7.2dev-1.2.jar:/usr/lib/pgsql/pg72jdbc2.jar:/usr/java/
j2sdk1.4.1_01/lib/*.jar


I got ERROR as
Sub : java.lang.ClassNotFoundException: org.postgresql:Driver
Rohit : java.sql.SQLException: No suitable driver

Here is my CODE       "JDBC_POSTGRE.java"
import java.sql.*;

class JDBC_POSTGRE
{
  public static void main(String args[])
  {
    Statement stmt1;
    ResultSet rs1;
    DatabaseMetaData dbmd1;
    try
    {
       try
       {
         Class.forName("org.postgresql.Driver");
         //Driver for POSTGRE-SQL :pg72jdbc2.jar
       }
       catch(Exception ex)
       {
         System.out.println("Sub : " + ex);
       }
       Connection conn1 =
DriverManager.getConnection("jdbc:postgresql:AirTel_RTL", "", "");
       //AirTel_RTL is a database, user='', password=''
       stmt1 = conn1.createStatement();
       rs1 = stmt1.executeQuery("Select * from tonedata"); // 'tonedata' is
a table in database
       while(rs1.next())
       {
         System.out.println(rs1.getInt("toneid") + "," +
rs1.getString("tone_name") );
       }
    }
    catch(Exception e)
    {
      System.out.println("Rohit : "+e);
    }
  }
}


I am not professional in Linux.
Hoping you will replay me very soon.

With regards,
Rohit


Re: PLS HELP in connecting with jdbc driver

From
"Scot P. Floess"
Date:
Don't use *.jar in your classpath...can't do that with java.  You must explicitly give the full path to each jar file

Rohit Johry wrote:
Hello,
 
I am a new user using the Postgre-sql for the first time please help me in establishing the connection between JDBC and POSTGRE.
 
POSTGRE >> 7.2.1
JAVA        >> 1.4.1_01
LINUX        >> 7.3
 
Having the CLASSPATH:
 
 
I got ERROR as
Sub : java.lang.ClassNotFoundException: org.postgresql:Driver
Rohit : java.sql.SQLException: No suitable driver
 
Here is my CODE       "JDBC_POSTGRE.java"
import java.sql.*;
 
class JDBC_POSTGRE
{
  public static void main(String args[])
  {
    Statement stmt1;
    ResultSet rs1;
    DatabaseMetaData dbmd1;
    try
    {
       try
       {
         Class.forName("org.postgresql.Driver");
         //Driver for POSTGRE-SQL :pg72jdbc2.jar
       }
       catch(Exception ex)
       {
         System.out.println("Sub : " + ex);
       }
       Connection conn1 = DriverManager.getConnection("jdbc:postgresql:AirTel_RTL", "", "");
       //AirTel_RTL is a database, user='', password=''
       stmt1 = conn1.createStatement();
       rs1 = stmt1.executeQuery("Select * from tonedata"); // 'tonedata' is a table in database
       while(rs1.next())
       {
         System.out.println(rs1.getInt("toneid") + "," + rs1.getString("tone_name") );
       }
    }
    catch(Exception e)
    {
      System.out.println("Rohit : "+e);
    }
  }
}
 
I am not professional in Linux.
Hoping you will replay me very soon.
 
With regards,
Rohit

-- 
Scot P. Floess - 27 Lake Royale - Louisburg, NC  27549 - 252-478-8087

Open Source Home Page
--------------------------------------
http://javapim.sourceforge.net
http://jplate.sourceforge.net
http://jwaretechniques.sourceforge.net

Open Source Project Host
-----------------------------------------------
http://sourceforge.net/projects/javapim
http://sourceforge.net/projects/jplate
http://sourceforge.net/projects/jwaretechniques